How to understand the coordinate system of dicom

What you describe is often true, but not always.

First of all, DICOM does not provide spacing, because the spacing between slices may vary (e.g., spacing may be larger in areas that are farther from the main region of interest). When the slices are ordered then the spacing between each neighbor must be checked and if it is constant then that value can be used as spacing between slices, otherwise interpolation is needed to reconstruct a 3D image.

DICOM does not provide Z_direction, because it may vary across the slices (e.g., in case of rotational acquisition of cardiac MRI). Also note that slice normal may be different from the vector that connects the origin of a slice to the origin of the next slice (e.g., tilted-gantry acquisition of brain CTs).

Also, instance number may not be always match the spatial order of slices and may not be contiguous, so you must not rely on it in any way when you reconstruct a volume. Getting instance number from physical position is not always available because slices may intersect and so there are positions that belong to many instances.

You may also need to group the slices before you can reconstruct a 3D volume from them. A 4D volume, such as a time sequence is stored in DICOM as a list of overlapping slices (many slices being located at the same physical position). You need to find out what is the DICOM tag that splits the series into reasonable sets of non-overlapping slices. The grouping tag may be acquisition time, content time, trigger time, repetition time, and about a dozen more - which one is used depends on the image modality, acquisition protocol, and vendor implementation.

If you use ITK’s DICOM sorter then it performs checks while computing the origin, spacing, and axis directions and it throws an exception if they vary across the series. If they vary then you can choose to exclude the image from analysis or reconstruct a volume from it by grouping and interpolation (e.g., 3D Slicer can reconstruct a volume from slices with arbitrary spacing and orientation, even if they intersect or there are large gaps between them, and it can also automatically group slices to load them as a 4D volume).

1 Like