Is instance number used to collect dicom series?

Usually, I use Instance Number to collect dicom series, just like:

imgs[ key ] = dicomImg

where key is the Instance Number, and dicomImg is the dicom information (header/pixel array).

However, sometimes, I find that the Instance Number of two dicom in one sery may be equal, which means I can store only one dicom file if Instance Number is used as the key.

My question is: what information should be used to collect dicom series?

Any suggestion is appreciated~~~

Why do you want to collect DICOMs like that? If it is a series, read it as a series and keep the 3D/4D image in memory. If you need header information, you can access image.GetMetaDataDictionary() (or something similar). Instance number does not have to correspond with spatial or temporal position.

@dzenanz Thank you for your kindly reply.

If it is a series, read it as a series and keep the 3D/4D image in memory

Yes, it is a series, and it is a dynamic sery (x-y-z-time). I want to keep it as a 4d array.

To save it to a 4d array, how to sort these dicom files? I know patient position is a useful information to sort files. However, some dicom files would have the same position in dynamic sery. In this situation, how to sort the files with the same position?

Here is an example of how to read a DICOM series using ITKPython:
https://examples.itk.org/src/io/gdcm/readdicomseriesandwrite3dimage/documentation
This example is written for 3D images, but 4D should be very similar. Maybe it is enough to change Dimension = 3 into Dimension = 4.

1 Like

@dzenanz Thank you very much for the kindly example. And I want to know more details about how to sort the 4D dynamic image.

For 3D sery, I know the patient position is used to sort files.

But for 4D dynamic sery, which tag is used to decide the order of time? Acquisition DateTime? Or something else?

The library (GDCM/ITK) should do the sorting for you. Have you tried it? If it does not work, and you need to provide the tag, there are many possible options.