[Neuroimaging] DICOM Orientation and World<-->Image coordinate transformation

Athanasios Anastasiou athanastasiou at gmail.com
Tue Sep 6 07:50:34 EDT 2016


Hello Matthew

Thank you for your response.

As per the DICOM pages:

    #M = numpy.zeros((4,4))
    #M[0:3,0]=numpy.array(tumourImageData[n].ImageOrientationPatient[0:3])
* tumourImageData[n].PixelSpacing[0]
    #M[0:3,1]=numpy.array(tumourImageData[n].ImageOrientationPatient[3:]) *
tumourImageData[n].PixelSpacing[1]
    #M[0:3,3]=tumourImageData[n].ImagePositionPatient
    #M[3,3]=1.0
    #M=numpy.matrix(M)

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
matrix.

Specific Data:

ImageOrientationPatient:
['0.999857', '0.00390641', '0.0164496', '-0.00741602', '0.975738',
'0.218818']

ImagePositionPatient:
['-127.773', '-105.599', '-94.5758']

PixelSpacing:
['0.4688', '0.4688']


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 (
https://www.slicer.org/slicerWiki/index.php/Coordinate_systems).

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
AA










On Tue, Sep 6, 2016 at 12:48 AM, Matthew Brett <matthew.brett at gmail.com>
wrote:

> Hi,
>
> 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
> having
> > 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
> which
> > 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
> the
> > 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?
>
> Best,
>
> Matthew
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20160906/59b6504d/attachment.html>


More information about the Neuroimaging mailing list