Hi all,
Maybe someone here would know-
I want to get the series IDs of each patient.
the sitk.ImageSeriesReader.GetGDCMSeriesIDs
need all dicom files are included in the file_path
. But, what if the folder structure is:
contents
folders1
img1.dcm
img2.dcm
...
folders2
img1.dcm
img2.dcm
folders ...
img1.dcm
img2.dcm
...
How can I get the Series IDs for each folder and save all Series IDs to a key ?
path_home = ‘TCGA-train’
path_dir = os.path.join(path_home,‘dataset’)
print (path_dir), len(path_dir)
paths = [path_dir +"/"+ x for x in os.listdir(path_dir)]
imgOriginal = {}
print (paths)
for k in range(len(num_count)):
reader = sitk.ImageSeriesReader()
filenamesDICOM = reader.GetGDCMSeriesFileNames(paths[k])
reader.SetFileNames(filenamesDICOM)
idx_slash_paths = paths[k].rfind('/')
idx_patient = paths[k][idx_slash_paths+1:]
imgOriginal[idx_patient] = reader.Execute()
print (idx_patient)
break
print (imgOriginal.keys())