GetGDCMSeriesFileNames: ordering of the returned files

Same as the title, I had a CT series, after running the ‘GetGDCMSeriesFileNames’, the files were returned according to the file name, instead of the z coordinates. I just wonder, how the files are ordered in function ‘GetGDCMSeriesFileNames’? It would be better to show me the source code or any samples.

Hello @KrisHan999,

The files are returned in order according to the z coordinate obtained from the Image Position (Patient), 0020|0032, DICOM tag. The code itself is deep in the bowls of the toolkits (SimpleITK->ITK->GDCM code).

Please check the files’ DICOM tag values and see if they are what you expect them to be.

1 Like

Thanks for your response. However, I installed the newest version of the python package, but the results are not exactly as you said. Please check the 2 CT series as in https://drive.google.com/file/d/1Zex3h9hfubG9zAUYsYBG2T758V5xzaHU/view?usp=sharing. The two cases in the line, one is in ascending order, the other is in descending order of z coordinates. I think whether the ordering is determined by the PatientPosition, ‘Head-First’ or ‘Feet-First’.

What’s more, for the GetDirection() function, how the direction for z-axis is determined?

Thanks again.

Slices are sorted by Image Position (Patient) along the slice normal. For series named “Couch-replaced CT Series” Image Orientation (Patient) is -1\0\0\0\1\0, the (seldom) orientation is

-1  0  0
 0  1  0
 0  0 -1

X: from left to right
Y: from anterior to posterior
Z: from superior to inferior

Another series has Image Orientation (Patient) 1\0\0\0\1\0, identity
X: from right to left
Y: from anterior to posterior
Z: from inferior to superior

how the direction for z-axis is determined

Z-axis is right-handed cross product of “X” and “Y” defined in Image Orientation (Patient).

Patient Position (0018,5100) specifies the position of the patient relative to the imaging equipment space for annotation purposes only. It is not used at all in particular case.

Edit: for clarity, even if the orientation (RAI-code: LAS) is unusual, there are no problems with the volume, axis are correct.

Edit: another illustration (with images from ITK-Snap)

las

2 Likes