diff --git a/docker/Dockerfile b/docker/Dockerfile index 9e3943c..8bf0df7 100755 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -65,7 +65,7 @@ RUN cd /opt/code && \ # matplotlib is used by rgb.py and provides various visualization tools including colormaps # pydicom is used by dicom2mrd.py to parse DICOM data -RUN pip3 install --no-cache-dir matplotlib==3.8.2 pydicom==2.4.3 +RUN pip3 install --no-cache-dir matplotlib==3.8.2 pydicom==3.0.1 # Cleanup files not required after installation RUN apt-get clean && \ diff --git a/environment.yml b/environment.yml index 3a3ce95..628cecb 100644 --- a/environment.yml +++ b/environment.yml @@ -11,7 +11,7 @@ dependencies: - libxml2=2.9.12 # For ismrmrd - h5py=3.7.0 # For ismrmrd - matplotlib=3.8.2 # used by rgb.py and provides various visualization tools including colormaps - - pydicom=2.4.3 # used by dicom2mrd.py to parse DICOM data + - pydicom=3.0.1 # used by dicom2mrd.py to parse DICOM data - numpy=1.26.0 - git=2.30.2 - dos2unix=7.4.2 # For fixing line ending issues from Windows \ No newline at end of file diff --git a/environment_windows.yml b/environment_windows.yml index 0790b24..83cebd1 100644 --- a/environment_windows.yml +++ b/environment_windows.yml @@ -11,7 +11,7 @@ dependencies: - libxml2=2.9.12 # For ismrmrd - h5py=3.7.0 # For ismrmrd - matplotlib=3.8.2 # used by rgb.py and provides various visualization tools including colormaps - - pydicom=2.4.3 # used by dicom2mrd.py to parse DICOM data + - pydicom=3.0.1 # used by dicom2mrd.py to parse DICOM data - numpy=1.26.0 - git=2.30.2 - dos2unix=7.4.2 # For fixing line ending issues from Windows \ No newline at end of file diff --git a/mrd2dicom.py b/mrd2dicom.py index 4d80a7d..07d0a44 100644 --- a/mrd2dicom.py +++ b/mrd2dicom.py @@ -89,6 +89,7 @@ def main(args): xml_header = xml_header.decode("utf-8") mrdHead = ismrmrd.xsd.CreateFromDocument(xml_header) + filesWritten = 0 for group in groups: if ( (group == 'config') or (group == 'config_file') or (group == 'xml') ): continue @@ -117,6 +118,7 @@ def main(args): dicomDset = pydicom.dataset.Dataset.from_json(base64.b64decode(meta['DicomJson'])) else: dicomDset = pydicom.dataset.Dataset() + dicomDset = pydicom.dataset.Dataset() # Enforce explicit little endian for written DICOM files dicomDset.file_meta = pydicom.dataset.FileMetaDataset() @@ -276,7 +278,10 @@ def main(args): # Write DICOM files fileName = "%02.0f_%s_%03.0f.dcm" % (dicomDset.SeriesNumber, dicomDset.SeriesDescription, dicomDset.InstanceNumber) print(" Writing file %s" % fileName) - dicomDset.save_as(os.path.join(args.out_folder, fileName)) + dicomDset.save_as(os.path.join(args.out_folder, fileName), enforce_file_format=True) + filesWritten += 1 + + print("Wrote %d DICOM files to %s" % (filesWritten, args.out_folder)) return if __name__ == '__main__':