Reputation: 10996
I am implementing a method to spatially sort DICOM slices in a volume. The way I am doing it is to sort by the position along the slice normal. This is computed as:
slice_normal = [0, 0, 0]
dir_cosines = ds[0x0020, 0x0037] # Direction cosines
slice_normal[0] = dir_cosines[1] * dir_cosines[5] - dir_cosines[2] * dir_cosines[4]
slice_normal[1] = dir_cosines[2] * dir_cosines[3] - dir_cosines[0] * dir_cosines[5]
slice_normal[2] = dir_cosines[0] * dir_cosines[4] - dir_cosines[1] * dir_cosines[3]
image_pos = ds[0x0020, 0x0032] # IPP
distance_along_normal = 0
for i in range(len(slice_normal)):
distance_along_normal += slice_normal[i] * image_pos[i]
Now this value distance_along_normal
should be equal to the slice location(0x0020, 0x1041)
, except in my case it has the opposite sign. So the slice ordering seems to be reversed than what it should be. I would like to know ehat else must I need to take something else into account to compute the correct slice ordering.
Upvotes: 0
Views: 1086
Reputation: 641
There is no reason to expect that the sign or the value of the offset calculated by your implementation should be the same as the sign or the value of the Slice Location (0020,1041)
value. As per DICOM specification
Slice Location (0020,1041) is defined as the relative position of the image plane expressed in mm. This information is relative to an unspecified implementation specific reference point.
Note that the direction of location is not specified at all, and it is explicitly said that the origin is arbitrary, which means that the only thing guaranteed to match between your calculation and the Slice Location
is the distance (absolute value of the difference) of the positions of any 2 slices.
Also note that Slice Location
is Type 3 - it does not have to be provided at all.
With regards to slice ordering - the presentation order is your decision. If you want spatial ordering, you need to decide the criteria for your ordering. For example, should axial slices be presented beginning from the head, or from the feet? That is your call completely and it will depend on the application (intended use) of your software.
If you do NOT care for the geometry, you can present images ordered for example by Instance Number (0020,0013)
. But there is no guarantee the ordering will have any geometrical meaning (although it usually has).
Upvotes: 4