From 76af69c5726a91cf1edce1c8c3724363d4e62419 Mon Sep 17 00:00:00 2001 From: Thomas BAUDIER Date: Fri, 22 Nov 2024 09:30:09 +0100 Subject: [PATCH] Be sure sequence name is in the dicom tag --- gatetools/image_convert.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gatetools/image_convert.py b/gatetools/image_convert.py index 5e2dafa..f784a4e 100644 --- a/gatetools/image_convert.py +++ b/gatetools/image_convert.py @@ -144,12 +144,16 @@ def separate_sequenceName_series(series): #Load dicom files for serie in series.keys(): for file in series[serie]: + sequenceName = "" try: - sequenceName = pydicom.dcmread(file)[0x0018, 0x0024].value + ds = pydicom.dcmread(file) + if Tag(0x18, 0x24) in ds: + sequenceName = ds[0x0018, 0x0024].value except pydicom.errors.InvalidDicomError: ds = pydicom.dcmread(file, force=True) ds.file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian - sequenceName = ds[0x0018, 0x0024].value + if Tag(0x18, 0x24) in ds: + sequenceName = ds[0x0018, 0x0024].value new_key = str(serie) + "_" + str(sequenceName) if new_key not in files: files[new_key] = []