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?
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.
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?
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.