Proposals:Orientation: Difference between revisions
No edit summary |
|||
Line 42: | Line 42: | ||
* The DICOM Standard in PDF: | * The DICOM Standard in PDF: | ||
http://medical.nema.org/dicom/2004.html Look in particular at http://medical.nema.org/dicom/2004/04_04PU.PDF section C.7.6.2.1.1, page 275 for a description of the coordinate transformation details. | http://medical.nema.org/dicom/2004.html Look in particular at http://medical.nema.org/dicom/2004/04_04PU.PDF section C.7.6.2.1.1, page 275 for a description of the coordinate transformation details. | ||
= Some notes on the DICOM convention and current ITK usage = | |||
* DICOM | |||
Image Orientation (Patient) (0020,0037) | |||
The direction cosines of the first row and the first column with respect to | |||
the patient. | |||
Image Position (Patient) (0020,0032) | |||
The x, y, and z coordinates of the upper left hand corner (center of the first | |||
voxel transmitted) of the image, in mm. | |||
DICOM Plane Attribute Descriptions C.7.6.2.1.1 Image | |||
Position And Image Orientation | |||
The Image Position (0020,0032) specifies the x, y, and z coordinates of the | |||
upper left hand corner of the image; it is the center of the first voxel | |||
transmitted. | |||
Image Orientation (0020,0037) specifies the direction cosines of the | |||
first row and the first column with respect to the patient. These Attributes | |||
shall be provide as a pair. Row value for the x, y, and z axes respectively | |||
followed by the Column value for the x, y, and z axes respectively. | |||
The direction of the axes is defined fully by the patient's orientation. | |||
The x-axis is increasing to the left hand side of the patient. | |||
The y-axis is increasing to the posterior side of the patient. | |||
The z-axis is increasing toward the head of the patient. | |||
The patient based coordinate system is a right handed system, i.e. the vector | |||
cross product of a unit vector along the positive x-axis and a unit vector | |||
along the positive y-axis is equal to a unit vector along the positive z-axis. | |||
Note: If a patient lies parallel to the ground, face-up on the table, | |||
with his feet-to-head direction same as the front-to-back direction of the | |||
imaging equipment, the direction of the axes of this patient based coordinate | |||
system and the equipment based coordinate system in previous versions of this | |||
Standard will coincide. The Image Plane Attributes, in conjunction with the | |||
Pixel Spacing Attribute, describe the position and orientation of the image | |||
slices relative to the patient-based coordinate system. | |||
In each image frame the Image Position (Patient) (0020,0032) specifies the | |||
origin of the image with respect to the patient-based coordinate system. | |||
Reference Coordinate System (RCS) and the Image Orientation (Patient) | |||
(0020,0037) attribute values specify the orientation of the image frame rows | |||
and columns. The mapping of pixel location (i,j) to the RCS is calculated as | |||
follows: | |||
P_x = [ X_x \delta_i Y_x \delta_j 0 S_x ] [i ] | |||
P_y [ X_y \delta_i Y_y \delta_j 0 S_y ] [j ] | |||
P_z [ X_z \delta_i Y_z \delta_j 0 S_z ] [0 ] | |||
1 [ 0 0 0 1 ] [1 ] | |||
where : | |||
Pxyz - The coordinates of the voxel (i,j) in the frame's image plane | |||
in units of mm. | |||
Sxyz - The three values of the Image Position (Patient) (0020,0032) attributes. It is the location in mm from the origin of the RCS. | |||
Xxyz - The values from the row (X) direction cosine of the Image Orientation | |||
(Patient) (0020,0037) attribute. | |||
Yxyz - The values from the column (Y) direction cosine of the Image Orientation (Patient) (0020,0037) attribute. | |||
i - Column index to the image plane. The first column is index zero. | |||
\delta_i - Column pixel resolution of the Pixel Spacing (0028,0030) attribute in units of mm. | |||
j - Row index to the image plane. The first row index is zero. | |||
\delta_j - Row pixel resolution of the Pixel Spacing (0028,0030) attribute in units of mm. | |||
Additional constraints apply: | |||
1) The row and column direction cosine vectors shall be orthogonal, i.e. their | |||
dot product shall be zero. | |||
2) The row and column direction cosine vectors shall be normal, i.e. the dot product of each direction cosine vector with itself shall be unity. | |||
The direction cosine for slices (k) is determined by the cross product of the | |||
two provided direction cosines. The coordinate system is right handed and the | |||
direction cosine must be unit magnitude. | |||
Determination of whether consecutive slices were acquired in a +Z or a -Z | |||
direction requires comparison of the Image Position (Patient) tag values | |||
of at least two slices. | |||
* Some other useful DICOM tags include: | |||
Pixel Spacing (0028,0030) Physical distance in the patient between the | |||
center of each pixel, specified by a numeric pair - adjacent row spacing | |||
(delimiter) adjacent column spacing in mm. | |||
Slice Thickness (0018,0050) Nominal slice thickness, in mm. | |||
Note that the value of Slice Thickness can be equal to, larger than, or | |||
smaller than, the distance between adjacent slices. | |||
* DICOM on Diffusion MRI | |||
Diffusion Gradient Orientation (0018, 9089) - The direction cosines of the | |||
diffusion gradient vector with respect to the patient. Required if Frame Type (0008,9007) Value 1 of this frame is ORIGINAL. May be present otherwise. | |||
* Current ITK Usage and sources of confusion | |||
It seems unfortunate to have a letter code selection for axes | |||
that is opposite to that used by DICOM and hence the scanner manufacturers. | |||
itkSpatialOrientation.h - | |||
// Coordinate orientation codes have a place-value organization such that | |||
// an ImageDimension-al sequence of subcodes says both which varies | |||
// fastest | |||
// through which varies slowest, but also which end of the frame of | |||
// reference | |||
// is considered zero for each of the coordinates. For example, 'RIP' | |||
// means | |||
// Right to Left varies fastest, then Inferior to Superior, and Posterior | |||
// to | |||
// Anterior varies the slowest. | |||
I take this to mean R implies the fastest varying axis runs from Right to | |||
Left. DICOM would give this the code L, as described here: | |||
C.7.6.1.1.1 Patient Orientation The Patient Orientation (0020,0020) relative to the image plane shall be specified by two values that designate the anatomical direction of the positive row axis (left to right) and the positive column axis (top to bottom). The first entry is the direction of the rows, given by the direction of the last pixel in the first row from the first pixel in that row. The second entry is the direction of the columns, given by the direction of the last pixel in the first column from the first pixel in that column. Anatomical direction shall be designated by the capital letters: A (anterior), P (posterior), R (right), L (left), H (head), F (foot). Each value of the orientation attribute shall contain at least one of these characters. If refinements in the orientation descriptions are to be specified, then they shall be designated by one or two additional letters in each value. Within each value, the letters shall be ordered with the principal orientation designated in the first character. | |||
Example code for this is available here : http://www.dclunie.com/medical-image-faq/html/part2.html | |||
Consider a DICOM file with direction cosines: | |||
1.000000 0.000000 0.000000 0.000000 0.000000 -1.000000 | |||
Interpretation in DICOM terms: | |||
orientation is CORONAL, it turns out slices running from A to P. | |||
unit vector along row is L i.e. a unit vector along the row points from patient Right to Patient Left. | |||
unit vector along column is I (i.e. columns from the Superior to the Inferior) | |||
row : L | |||
columns : I | |||
slices : P | |||
Three letter code for (column index, row index, slice index is) ILP. | |||
This indicates the origin is at the superior, right, anterior corner of the | |||
volume, and that the axes run from superior to inferior, from right to left, | |||
from anterior to posterior. | |||
This is the OPPOSITE CONVENTION TO THAT DESCRIBED BY METAIO | |||
AnatomicalOrientation tag. | |||
From : http://caddlab.rad.unc.edu/software/MetaIO/MetaIO-Introduction.pdf | |||
AnatomicalOrientation MET_STRING Specify anatomic ordering of axis. For | |||
example, RAS mean x-axis is Right to Left, y-axis is Anterior to Posterior, | |||
and Z-axis is Superior to Inferior. Use only [R|L] | [A|P] | [S|I] per axis. | |||
Note that data described as RAS using this convention is not the same as data | |||
described as RAS using the DICOM convention. | |||
Similarly, the InsightSNAP tool in InsightApplications (which has a great IO | |||
loader by the way), uses the following: | |||
When it says LPS it means the x axis is RUNNING FROM left to right, | |||
the y axis is running from Posterior to Anterior, the z axis is running from | |||
Superior to Inferior. | |||
This is exactly the same as what DICOM means when it says RAI. |
Revision as of 18:59, 5 March 2005
Proposal
itkImage should contain information regarding the orienttaion of the image volume.
Coordinate Systems
Coordinate systems are an important part of any medical application. Medical scanners create regular, "rectangular" arrays of points and cells. The topology of the arrays is implicit in the representation. The geometric location of each point is also implicit.
vtk and itk Image
vtk and itk store meta-information that can be used to convert between image coordinates (i-j-k) and world coordinates (x-y-z). Each image has an origin that is a 3-D (n-D for itk) vector. The origin (x-y-z) specifies the world coordinate of the first point in memory. The spacing specifies the distance between points along each axis. Using the spacing and origin, the transformation between i-j-k and x-y-z is a fast, simple computation. x(yz) = origin + i(jk) * spacing; i(jk) = (x(yz) - origin) / spacing;
Limitations of the current Image
Many image processing and segmentation algrothms do not need additional spatial information. But, registration and modeling techniques need to respect the orientation of the image arrays.
Proposed Extension to itk::Image
By adding an itk::Matrix containing direction cosines, the i-j-k -> x-y-z transformation could include the orientation in the computation. Adding the matrix will not change the existing API. All index to point calculations are confined to itk::Image. The transformations in matrix form are: XYZ = To * Rc * Ss * IJK where To is a translate to the origin, Rc is the matrix of direction cosines and Ss is a scale matrix of spacings. There are performance considerations, so the implementation may cache some internal matrices and state.
Questions Raised by Proposal
- The coordinate frame in which the direction cosines are measured needs to be identified somehow. Should the itk::Image allow many possible spaces, and then explicitly identify which space is being used in a given Image? This flexibility would reflect the fact that different coordinate systems are used in different formats (NIFTY-1's right-anterior-superior versus DICOM's left-posterior-superior).
- Or, should ITK pick exactly one space (say, RAS) and convert orientation information from different formats into that space?
- If you pick exactly one space, how can can that match the otherwise dimensional generality of ITK? fMRI volumes can "live" in 4D x-y-z-t, and other images may live in higher dimensional spaces.
- Vector and Tensor data has a coordinate frame associated with it: the frame in which the vector and tensor coefficients are measured. Should there any assumption or restriction that the measurement frame of vector/tensor data is identical to the space in which the direction cosines are expressed? It may simplify things.
- But if there is this assumption, then are operations which rotate an image (during, say, a rigid regisitration) responsible for performing the corresponding coordinate transform on the vector and tensor values in the image?
- If there is not this assumption, then does the orientation of the vector/tensor measurementt (a third coordinate frame!) have to be identified? Relative to which space: image or world? Doesn't this require adding a second itk::Matrix?
- If the raster ordering of the axes in the itk::Image is permuted, should the columns of the itk::Matrix be correspondingly permuted?
External References
- Current ITK SpatialOrientation header:
- How NRRD handles orientation information:
http://teem.sourceforge.net/nrrd/format.html#space
- Some info on Analyze format:
http://wideman-one.com/gw/brain/analyze/formatdoc.htm
- Info from Tosa Yasunari about how Freesurfer handles coordinates:
http://www.nmr.mgh.harvard.edu/~tosa/#coords
- A lot of good documentation is included in the nifti1.h header file:
http://nifti.nimh.nih.gov/pub/dist/src/nifti1.h
- The DICOM Standard in PDF:
http://medical.nema.org/dicom/2004.html Look in particular at http://medical.nema.org/dicom/2004/04_04PU.PDF section C.7.6.2.1.1, page 275 for a description of the coordinate transformation details.
Some notes on the DICOM convention and current ITK usage
- DICOM
Image Orientation (Patient) (0020,0037) The direction cosines of the first row and the first column with respect to the patient.
Image Position (Patient) (0020,0032) The x, y, and z coordinates of the upper left hand corner (center of the first voxel transmitted) of the image, in mm.
DICOM Plane Attribute Descriptions C.7.6.2.1.1 Image Position And Image Orientation The Image Position (0020,0032) specifies the x, y, and z coordinates of the upper left hand corner of the image; it is the center of the first voxel transmitted.
Image Orientation (0020,0037) specifies the direction cosines of the first row and the first column with respect to the patient. These Attributes shall be provide as a pair. Row value for the x, y, and z axes respectively followed by the Column value for the x, y, and z axes respectively.
The direction of the axes is defined fully by the patient's orientation. The x-axis is increasing to the left hand side of the patient. The y-axis is increasing to the posterior side of the patient. The z-axis is increasing toward the head of the patient. The patient based coordinate system is a right handed system, i.e. the vector cross product of a unit vector along the positive x-axis and a unit vector along the positive y-axis is equal to a unit vector along the positive z-axis.
Note: If a patient lies parallel to the ground, face-up on the table, with his feet-to-head direction same as the front-to-back direction of the imaging equipment, the direction of the axes of this patient based coordinate system and the equipment based coordinate system in previous versions of this Standard will coincide. The Image Plane Attributes, in conjunction with the Pixel Spacing Attribute, describe the position and orientation of the image slices relative to the patient-based coordinate system. In each image frame the Image Position (Patient) (0020,0032) specifies the origin of the image with respect to the patient-based coordinate system.
Reference Coordinate System (RCS) and the Image Orientation (Patient) (0020,0037) attribute values specify the orientation of the image frame rows and columns. The mapping of pixel location (i,j) to the RCS is calculated as follows:
P_x = [ X_x \delta_i Y_x \delta_j 0 S_x ] [i ] P_y [ X_y \delta_i Y_y \delta_j 0 S_y ] [j ] P_z [ X_z \delta_i Y_z \delta_j 0 S_z ] [0 ] 1 [ 0 0 0 1 ] [1 ]
where :
Pxyz - The coordinates of the voxel (i,j) in the frame's image plane in units of mm.
Sxyz - The three values of the Image Position (Patient) (0020,0032) attributes. It is the location in mm from the origin of the RCS.
Xxyz - The values from the row (X) direction cosine of the Image Orientation (Patient) (0020,0037) attribute.
Yxyz - The values from the column (Y) direction cosine of the Image Orientation (Patient) (0020,0037) attribute.
i - Column index to the image plane. The first column is index zero.
\delta_i - Column pixel resolution of the Pixel Spacing (0028,0030) attribute in units of mm.
j - Row index to the image plane. The first row index is zero.
\delta_j - Row pixel resolution of the Pixel Spacing (0028,0030) attribute in units of mm.
Additional constraints apply:
1) The row and column direction cosine vectors shall be orthogonal, i.e. their dot product shall be zero.
2) The row and column direction cosine vectors shall be normal, i.e. the dot product of each direction cosine vector with itself shall be unity.
The direction cosine for slices (k) is determined by the cross product of the
two provided direction cosines. The coordinate system is right handed and the
direction cosine must be unit magnitude.
Determination of whether consecutive slices were acquired in a +Z or a -Z direction requires comparison of the Image Position (Patient) tag values of at least two slices.
- Some other useful DICOM tags include:
Pixel Spacing (0028,0030) Physical distance in the patient between the center of each pixel, specified by a numeric pair - adjacent row spacing (delimiter) adjacent column spacing in mm.
Slice Thickness (0018,0050) Nominal slice thickness, in mm. Note that the value of Slice Thickness can be equal to, larger than, or smaller than, the distance between adjacent slices.
- DICOM on Diffusion MRI
Diffusion Gradient Orientation (0018, 9089) - The direction cosines of the diffusion gradient vector with respect to the patient. Required if Frame Type (0008,9007) Value 1 of this frame is ORIGINAL. May be present otherwise.
- Current ITK Usage and sources of confusion
It seems unfortunate to have a letter code selection for axes that is opposite to that used by DICOM and hence the scanner manufacturers.
itkSpatialOrientation.h -
// Coordinate orientation codes have a place-value organization such that // an ImageDimension-al sequence of subcodes says both which varies // fastest // through which varies slowest, but also which end of the frame of // reference // is considered zero for each of the coordinates. For example, 'RIP' // means // Right to Left varies fastest, then Inferior to Superior, and Posterior // to // Anterior varies the slowest.
I take this to mean R implies the fastest varying axis runs from Right to Left. DICOM would give this the code L, as described here:
C.7.6.1.1.1 Patient Orientation The Patient Orientation (0020,0020) relative to the image plane shall be specified by two values that designate the anatomical direction of the positive row axis (left to right) and the positive column axis (top to bottom). The first entry is the direction of the rows, given by the direction of the last pixel in the first row from the first pixel in that row. The second entry is the direction of the columns, given by the direction of the last pixel in the first column from the first pixel in that column. Anatomical direction shall be designated by the capital letters: A (anterior), P (posterior), R (right), L (left), H (head), F (foot). Each value of the orientation attribute shall contain at least one of these characters. If refinements in the orientation descriptions are to be specified, then they shall be designated by one or two additional letters in each value. Within each value, the letters shall be ordered with the principal orientation designated in the first character.
Example code for this is available here : http://www.dclunie.com/medical-image-faq/html/part2.html
Consider a DICOM file with direction cosines:
1.000000 0.000000 0.000000 0.000000 0.000000 -1.000000
Interpretation in DICOM terms: orientation is CORONAL, it turns out slices running from A to P. unit vector along row is L i.e. a unit vector along the row points from patient Right to Patient Left. unit vector along column is I (i.e. columns from the Superior to the Inferior)
row : L columns : I slices : P
Three letter code for (column index, row index, slice index is) ILP. This indicates the origin is at the superior, right, anterior corner of the volume, and that the axes run from superior to inferior, from right to left, from anterior to posterior.
This is the OPPOSITE CONVENTION TO THAT DESCRIBED BY METAIO
AnatomicalOrientation tag.
From : http://caddlab.rad.unc.edu/software/MetaIO/MetaIO-Introduction.pdf AnatomicalOrientation MET_STRING Specify anatomic ordering of axis. For example, RAS mean x-axis is Right to Left, y-axis is Anterior to Posterior, and Z-axis is Superior to Inferior. Use only [R|L] | [A|P] | [S|I] per axis.
Note that data described as RAS using this convention is not the same as data described as RAS using the DICOM convention.
Similarly, the InsightSNAP tool in InsightApplications (which has a great IO
loader by the way), uses the following:
When it says LPS it means the x axis is RUNNING FROM left to right,
the y axis is running from Posterior to Anterior, the z axis is running from
Superior to Inferior.
This is exactly the same as what DICOM means when it says RAI.