Skip to content

Commit

Permalink
Pydicom change dcm_read to dcmread
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaudier committed Oct 31, 2024
1 parent 5caa259 commit 7894042
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bin/gt_dicom_rt_struct_to_image
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def gt_dicom_rt_struct_to_image(list_roi, filename_struct, filename_img, roi, cr
gt.logging_conf(verbose=(verbose or list_roi),logfile=logfile)

# read dicom struct
structset = pydicom.read_file(filename_struct, force=True)
structset = pydicom.dcmread(filename_struct, force=True)

# print roi names
roi_names = gt.list_roinames(structset)
Expand Down
8 changes: 4 additions & 4 deletions gatetools/dvh.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_dvh(self):
logger.info('Test_DVH test_dvh')
tmpdirpath = tempfile.mkdtemp()
filenameStruct = wget.download("https://gitlab.in2p3.fr/opengate/gatetools_data/-/raw/master/rtstruct.dcm?inline=false", out=tmpdirpath, bar=None)
structset = pydicom.read_file(os.path.join(tmpdirpath, filenameStruct))
structset = pydicom.dcmread(os.path.join(tmpdirpath, filenameStruct))
filenameDose = wget.download("https://gitlab.in2p3.fr/opengate/gatetools_data/-/raw/master/rtdose.dcm?inline=false", out=tmpdirpath, bar=None)
doseImage = gt.read_3d_dicom([os.path.join(tmpdirpath, filenameDose)])
transformImage = gt.applyTransformation(input=doseImage, neworigin=[-176, -320, -235])
Expand All @@ -123,7 +123,7 @@ def test_dvh_volume(self):
logger.info('Test_DVH test_dvh_volume')
tmpdirpath = tempfile.mkdtemp()
filenameStruct = wget.download("https://gitlab.in2p3.fr/opengate/gatetools_data/-/raw/master/rtstruct.dcm?inline=false", out=tmpdirpath, bar=None)
structset = pydicom.read_file(os.path.join(tmpdirpath, filenameStruct))
structset = pydicom.dcmread(os.path.join(tmpdirpath, filenameStruct))
filenameDose = wget.download("https://gitlab.in2p3.fr/opengate/gatetools_data/-/raw/master/rtdose.dcm?inline=false", out=tmpdirpath, bar=None)
doseImage = gt.read_3d_dicom([os.path.join(tmpdirpath, filenameDose)])
transformImage = gt.applyTransformation(input=doseImage, neworigin=[-176, -320, -235])
Expand All @@ -141,7 +141,7 @@ def test_dvh_compute_v(self):
logger.info('Test_DVH test_dvh_compute_v')
tmpdirpath = tempfile.mkdtemp()
filenameStruct = wget.download("https://gitlab.in2p3.fr/opengate/gatetools_data/-/raw/master/rtstruct.dcm?inline=false", out=tmpdirpath, bar=None)
structset = pydicom.read_file(os.path.join(tmpdirpath, filenameStruct))
structset = pydicom.dcmread(os.path.join(tmpdirpath, filenameStruct))
filenameDose = wget.download("https://gitlab.in2p3.fr/opengate/gatetools_data/-/raw/master/rtdose.dcm?inline=false", out=tmpdirpath, bar=None)
doseImage = gt.read_3d_dicom([os.path.join(tmpdirpath, filenameDose)])
transformImage = gt.applyTransformation(input=doseImage, neworigin=[-176, -320, -235])
Expand All @@ -156,7 +156,7 @@ def test_dvh_compute_d(self):
logger.info('Test_DVH test_dvh_compute_d')
tmpdirpath = tempfile.mkdtemp()
filenameStruct = wget.download("https://gitlab.in2p3.fr/opengate/gatetools_data/-/raw/master/rtstruct.dcm?inline=false", out=tmpdirpath, bar=None)
structset = pydicom.read_file(os.path.join(tmpdirpath, filenameStruct))
structset = pydicom.dcmread(os.path.join(tmpdirpath, filenameStruct))
filenameDose = wget.download("https://gitlab.in2p3.fr/opengate/gatetools_data/-/raw/master/rtdose.dcm?inline=false", out=tmpdirpath, bar=None)
doseImage = gt.read_3d_dicom([os.path.join(tmpdirpath, filenameDose)])
transformImage = gt.applyTransformation(input=doseImage, neworigin=[-176, -320, -235])
Expand Down
20 changes: 10 additions & 10 deletions gatetools/image_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def separate_series(dicomFiles):
#Load dicom files
for file in dicomFiles:
try:
seriesInstanceUID = pydicom.read_file(file)[0x0020, 0x000e].value
seriesInstanceUID = pydicom.dcmread(file)[0x0020, 0x000e].value
except pydicom.errors.InvalidDicomError:
ds = pydicom.read_file(file, force=True)
ds = pydicom.dcmread(file, force=True)
ds.file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian
seriesInstanceUID = ds[0x0020, 0x000e].value
print(seriesInstanceUID)
Expand All @@ -125,9 +125,9 @@ def separate_accessionNumber_series(series):
for serie in series.keys():
for file in series[serie]:
try:
accessionNumber = pydicom.read_file(file)[0x0020, 0x0012].value
accessionNumber = pydicom.dcmread(file)[0x0020, 0x0012].value
except pydicom.errors.InvalidDicomError:
ds = pydicom.read_file(file, force=True)
ds = pydicom.dcmread(file, force=True)
ds.file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian
accessionNumber = ds[0x0020, 0x0012].value
new_key = str(serie) + "_" + str(accessionNumber)
Expand All @@ -145,9 +145,9 @@ def separate_sequenceName_series(series):
for serie in series.keys():
for file in series[serie]:
try:
sequenceName = pydicom.read_file(file)[0x0018, 0x0024].value
sequenceName = pydicom.dcmread(file)[0x0018, 0x0024].value
except pydicom.errors.InvalidDicomError:
ds = pydicom.read_file(file, force=True)
ds = pydicom.dcmread(file, force=True)
ds.file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian
sequenceName = ds[0x0018, 0x0024].value
new_key = str(serie) + "_" + str(sequenceName)
Expand All @@ -165,9 +165,9 @@ def read_dicom(dicomFiles):
#Load dicom files
for file in dicomFiles:
try:
files.append(pydicom.read_file(file))
files.append(pydicom.dcmread(file))
except pydicom.errors.InvalidDicomError:
ds = pydicom.read_file(file, force=True)
ds = pydicom.dcmread(file, force=True)
ds.file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian
files.append(ds)

Expand Down Expand Up @@ -242,9 +242,9 @@ def read_3d_dicom(dicomFile, flip=False):
"""
files = []
try:
files.append(pydicom.read_file(dicomFile[0]))
files.append(pydicom.dcmread(dicomFile[0]))
except pydicom.errors.InvalidDicomError:
ds = pydicom.read_file(dicomFile[0], force=True)
ds = pydicom.dcmread(dicomFile[0], force=True)
ds.file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian
files.append(ds)

Expand Down
2 changes: 1 addition & 1 deletion gatetools/roi_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ class Test_ROI(LoggedTestCase):
def test_roi(self):
tmpdirpath = tempfile.mkdtemp()
filenameStruct = wget.download("https://gitlab.in2p3.fr/opengate/gatetools_data/-/raw/master/rtstruct.dcm?inline=false", out=tmpdirpath, bar=None)
structset = pydicom.read_file(os.path.join(tmpdirpath, filenameStruct))
structset = pydicom.dcmread(os.path.join(tmpdirpath, filenameStruct))

# roi names
roi_names = list_roinames(structset)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'click',
'numpy',
'scipy',
'pydicom',
'pydicom>=3.0.0',
'tqdm',
'colored',
'itk>=5.2.0',
Expand Down

0 comments on commit 7894042

Please sign in to comment.