[vtkusers] changing medical data orientation/spacing/etc

Mark Roden mmroden at gmail.com
Mon Apr 23 17:29:43 EDT 2012


Hi all,

Following up on my previous implementation of DICOM coordinates using
VTK (http://vtk.1045678.n5.nabble.com/Re-DICOM-patient-position-and-direction-cosines-td3252184.html),
I've hit a bit of a snag.

In my old code, I would just determine if the axes of a given image
were the identity matrix; if they were, then the image was considered
'good to go', as that's the way that vtk, by default, organizes its
images.  If not, I would perform a series of flips to get everything
working.

However, I've encountered some data where the direction cosines are
not unitary.  Here is some sample data that also does not use unitary
direction cosines:
http://pubimage.hcuge.ch:8080/DATA/ANONYMIZE.zip

How can I get vtk to report the correct pixel coordinates in 'real
space' (ie, using those direction cosines and the location of the
upper left coordinate)?  That is, for that sample data, these tags
show the upper left coordinate, and then the direction cosines of the
plane as a six-element matrix:

	(0020,0032)	Image Position (Patient)	DS	3	62.35790634\85.53748322\-35.137291
	(0020,0037)	Image Orientation
(Patient)	DS	6	-0.9888614402\-0.1455734703\-0.03100683618\0.1455115848\-0.9893446527\0.00485240052

Normally, 0020,0037 will be
	(0020,0037)	Image Orientation (Patient)	DS	6	0\1\0\0\0\-1
or
	(0020,0037)	Image Orientation (Patient)	DS	6	1\0\0\0\1\0
or some other combination of 1's and 0's.

The problem is, with these direction cosines, I can't just treat the
data as I otherwise would.  That means that any derivative data (such
as an RTStruct) would be pointing to the incorrect coordinates-- a bad
thing, as it would direct a radiation beam to the wrong anatomy.

I can get the direction cosines from the vtkImageData, that's doable.

I was thinking that the next thing I can do is invert that
vtkMatrix4x4, and then use that matrix as a transform (probably by
dropping the origin to 0,0,0, so that the rotation isn't about the
bottom left corner, but now we're in territory where I'm not sure how
VTK will behave viz producing proper pixel coordinates).

Is that the right approach?  How can I get a vtkImageData out of that?
 I only need to do this once when I load the image, so a vtkReslice
seems like complete overkill, and would slow down my program as it
constantly recalculates everything.

I'm using 5.10.0rc-1 from git, and will have to keep using that
version until gdcm is updated to reflect the changes in vtk 6.0's API.

Thanks,
Mark



More information about the vtkusers mailing list