Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DICOM Images read with GDCMSeriesFileNames or list of paths

I am using SimpleITK to analyse Dynamic PET Data. I have a folder with 148 * N images (with N the number of frames of my Dynamic PET) and I want to separate the images of each frames. Firstly, I created one subfolder for each frame with the corresponding images.

>folder #Folder of dynamic data
   >subfolder1 #Subfolder with images of Frame 1
      >image1, image2, ..., image148
   >subfolder2 #Subfolder with images of Frame 2
      >image149 image 150, ..., image296

I was reading my images as following:

series_reader = sitk.ImageSeriesReader()
image = sitk.ReadImage(series_reader.GDCMSeriesFileNames(path_subfolder1))

Creating all these subfolders is not very user-friendly so I try to store all the paths of the images in lists :

frame1 = [image1, ..., image148]
frame2 = [image149, ..., image296]
...
frame_list = [frame1, frame2, ..., frameN]

And reading images like this:

image = sitk.ReadImage(frame_list[0])

The problem is that when I am looking at the value of a voxel located in the same coordinates (x, y, z), I don't get the same value with the 2 methods. It seems that with series_reader.GDCMSeriesFileNames() SimpleITK retrieve some information about the DICOM image like the Origin.

Which information are retrieved by SimpleITK to create his images with series_reader.GDCMSeriesFileNames() that I need to have the exactly same image? Or is there another way to have the same image using list of paths?

P.S. : In this post, all the variables named with 'image' are the paths to the images not a SimpleITK Image object.

Edit : In my case, all of my frames have got the same series number so I can't use series_reader.GDCMSeriesFileNames(path_folder, series_ID)

like image 517
Timothée ZARAGORI Avatar asked Feb 01 '26 23:02

Timothée ZARAGORI


1 Answers

There is no need to split the series into separate directories. You can get the list of seriesIDs in a directory with the itk::simple::ImageSeriesReader::GetGDCMSeriesIDs method.

You can easily create a map for seriesID to file lists with the following one liner: series_dic = { series_id: reader.GetGDCMSeriesFileNames(path, series_id) for series_id in reader.GetGDCMSeriesIDs(path) }

By using the GetGDCMSeriesFileNames method you should get all the files is the proper order sorted by their physical locations, with your manual method you are not.

If this automatic approach does not work for your particular scanner or acquisition process, you will have to manually load the DICOMS dictionaries, separate them by series_id, and then properly sort them based on the proper DICOM tags for your acquisition.

like image 65
blowekamp Avatar answered Feb 04 '26 14:02

blowekamp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!