[Neuroimaging] DICOM Orientation and World<-->Image coordinate transformation
athanastasiou at gmail.com
Tue Sep 6 07:50:34 EDT 2016
Thank you for your response.
As per the DICOM pages:
#M = numpy.zeros((4,4))
ImageOrientationPatient is a flat 1x6 vector as it is coming out of the
image but more importantly it contains direction cosines which means that
it may not constitute a "proper" rotation matrix. The determinant of that
matrix is 0.0. Scaling apart, it would still have to be a "valid" rotation
['0.999857', '0.00390641', '0.0164496', '-0.00741602', '0.975738',
['-127.773', '-105.599', '-94.5758']
Now, if I read this correctly, all the points are offset by
ImagePositionPatient, scaled by pixel spacing (and so far so good), the
FIRST ROW (i.e. X) points mostly downwards (rotation of almost 90 degrees
around the X axis in the world system), and the FIRST COLUMN (i.e. Y) now
points left. To interpert the rotations, I am taking the direction cosines
as angle differences between the scanner space (x,y,z) and image space
(i,j,k) as depicted in (
Come to think of it, these very small angles might be the reason for the
non-zero Z coordinate in the ROI.
What am I doing wrong?
All the best
On Tue, Sep 6, 2016 at 12:48 AM, Matthew Brett <matthew.brett at gmail.com>
> On Sun, Sep 4, 2016 at 12:12 PM, Athanasios Anastasiou
> <athanastasiou at gmail.com> wrote:
> > Hello everyone
> > I am trying to convert between world and image coordinates and I am
> > some difficulty, particularly with inversing the transform.
> > I need this specifically, as I would like to extract the pixels that have
> > been prescribed (manually) by a ROI. I can access the grayscale values
> > are in some pixel space and I can access the ROI data which however is
> > expressed in 'mm' and thus in world coordinates.
> > As per http://nipy.org/nibabel/dicom/dicom_orientation.html I have all
> > data to construct the matrix that converts pixel to world coordinates
> but I
> > am interested in the opposite direction (i.e. from world (ROI) to image
> > (pixels)).
> > My immediate reaction was to invert the transformation matrix. However,
> I am
> > getting an error that the matrix is "singular".
> Yes, inverting is what you want to do. The error is telling you
> about some error in the affine matrix.
> Would you mind giving more details on where you got the entries for
> your affine matrix? What are your ImageOrientationPatient and
> ImagePositionPatient fields? I assume you got the third column of the
> matrix by taking the cross-product of the first two? What matrix do
> you end up with?
> Neuroimaging mailing list
> Neuroimaging at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Neuroimaging