Reputation: 21
I'm calculating the distance between slices using Image Position (0020,0032), and I get the distance in millimeter, how can I convert it into pixel?
The "pixel spacing" tag in DICOM present the physical distance between pixel, but it's only for the row and column of the image. If I want to calculate the distances between slices in pixel, which value in this tag should I use?
Upvotes: 2
Views: 3768
Reputation: 12530
I'll need to repeat myself here:
See an in depth answer here: https://stackoverflow.com/a/15116116/136285
Technically this question is an exact duplicate of:
But for completeness let's describe the algorithm here again:
The DICOM standard is online at http://dicom.nema.org/. The "Image
Orientation Patient" tag gives the direction cosines for the rows and
columns for the three axes defined above. Your typical axial slices will
have a value 1/0/0/0/1/0
: rows increase from left to right, columns
increase from posterior to anterior. This is your everyday "looking up
from the bottom of the head with the eyeballs up" image.
In your images, IOP = 0.999794\0.000000\-0.020289\-0.020127\-0.126071\-0.991817
. So this is a
slightly-rotated coronal acquisition: rows increase from left to right,
and columns increase from head to foot.
The "Image Position Patient"
tag gives the coordinates of the first
voxel in the image in the "RAH" coordinate system, relative to some
origin.
The steps it takes when reconstructing a volume are these, first, calculate the slice normal from IOP:
normal[0] = cosines[1]*cosines[5] - cosines[2]*cosines[4];
normal[1] = cosines[2]*cosines[3] - cosines[0]*cosines[5];
normal[2] = cosines[0]*cosines[4] - cosines[1]*cosines[3];
You only have to do this once for all slices in the volume. Next, for each slice, calculate the distance along the slice normal using the IPP tag ("dist" is initialized to zero before reading the first slice) :
for (int i = 0; i < 3; ++i) dist += normal[i]*ipp[i];
Then order the slices according to the value "dist". Finally, once you've read in all the slices, calculate the z-spacing as the difference between the "dist" values for the first two slices (or use an average, or even a more complex algorithm to detect missing slices).
Original reference:
Upvotes: 2
Reputation: 183
PS3.3 C.7.6.2 Image Plane Module contains the tags that can be used to calculate the spacing between slices. In general you can use Slice Thickness (0018,0050) and use it with the assumption that there is no dead space between slices. In practice I calculate the distances between the Image Position Patient (0020,0032) of each slice.
Upvotes: 0