[vtkusers] Problem rotating vtkImageSlice

Richard Frank rickfrank at me.com
Sun Aug 28 18:52:15 EDT 2016


Hi David

I have a preop CT typically 600 - 900 slices.  The intra-op ct ( DICOM says modality is XA , essentially a lower res non - HU calibrated spin volume) is from a c-arm right before surgical procedure. I need to align the intra op with the preop. This is manual registration by moving 3 orthogonal slice pairs to create a 6 DOF registration matrix. My initial implementation of the slices ( Axial, sagittal, etc) has them all "facing" the user. Rolling the scroll wheel moves through the slices.

This is all parallel projection.

We have a dual volume renderer written in OpenCL that shows the alignment in 3D of the two ( fixed, moving ) volumes.

Now I would like to, for simplicity, align the 
slices so the world coordinates line up with my ijkLPS transform.
In the case of direction cosines == identity, HFS position, my sagittal slice can be aligned with world coordinates by turning it so the patient is head pointing out of screen (+Z Inferior - Superior), face down ( + Y Anterior to Posterior) ( +X Left to Right). 

The I would move the slice to proper location in space based on image position patient. ( one coordinate is always 0 ) And then move the camera so the slice normal is aligned with the camera view vector.

This is all working correctly with our 3D views and associated surgical equipment. I thought I would be able to manipulate the slices in space as any other actor ( rotate, translate, etc) but perhaps that's not possible? When I try to rotate the image slice ( which is a Prop3D) the image seems to be resliced  as you say, instead of the prop being rotated.

Thanks 

Rick Frank

> On Aug 28, 2016, at 5:41 PM, David Gobbi <david.gobbi at gmail.com> wrote:
> 
> Okay, let me try to understand this.  Please let me know if I'm wrong on any of the following points.
> 
> 1) You have a CT scan, consisting of several slices (I assume around 100 slices) with uniform spacing.
> 
> 2) You have a single XA image.  An XA is a projection image, in contrast to CT which is a tomographic image.
> 
> 3) You need to find the direction-of-projection through the CT volume such that it matches the XA.
> 
> This is generally done by creating a DRR a MIP of the CT.  I'm not sure how you plan to achieve this by rotating a slice.
> 
>  - David
> 
>> On Sun, Aug 28, 2016 at 3:09 PM, Richard Frank <rickfrank at me.com> wrote:
>> I thought I coil rotate the image slice in 3 space as defined here 
>> 
>> http://www.vtk.org/doc/nightly/html/classvtkImageSlice.html#details
>> 
>> Rick Frank
>> 
>>> On Aug 28, 2016, at 3:42 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>> 
>>> Then remind me again why you're using vtkImageResliceMapper instead of vtkImageSliceMapper?
>>> 
>>>> On Sun, Aug 28, 2016 at 1:23 PM, Richard Frank <rickfrank at me.com> wrote:
>>>> I'm just trying to rotate the plane in 3 space, not reslicing...
>>>> 
>>>> Rick Frank
>>>> 
>>>>> On Aug 28, 2016, at 3:16 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>>>> 
>>>>> If you only had one input slice, then why would you be surprised that reslicing at 90 degrees gives an output that is only one pixel wide?
>>>>> 
>>>>>> On Sun, Aug 28, 2016 at 12:53 PM, Richard Frank <rickfrank at me.com> wrote:
>>>>>> Hi
>>>>>> 
>>>>>> I'm using the VTK example which creates an in memory single cyan slice.....
>>>>>> 
>>>>>> Thanks
>>>>>> 
>>>>>> Rick Frank
>>>>>> 
>>>>>>> On Aug 28, 2016, at 2:42 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>>>>>> 
>>>>>>> Check the extent of the input image to make sure all of the slices were loaded.
>>>>>>> 
>>>>>>>> On Sun, Aug 28, 2016 at 12:37 PM, Richard Frank <rickfrank at me.com> wrote:
>>>>>>>> Hi David,
>>>>>>>> 
>>>>>>>> Sorry about the attachment.
>>>>>>>> 
>>>>>>>> Well, I'm pretty far along with my work on this, so I'd like to try the vtkPlane orientation as a solution if possible.
>>>>>>>> 
>>>>>>>> using the example code,  If I create a vtkPlane, set its origin to 0,0,0 and set its normal to 1 0 0 (instead of 0,0,1) and call 
>>>>>>>>  imageResliceMapper->SetSlicePlane(plane);
>>>>>>>> 
>>>>>>>> I see a thin line. Seems correct. If I change the interactor style to Trackball camera, and rotate the camera around it seems the image is only 1 unit wide however.
>>>>>>>> 
>>>>>>>> Is there something else I need to do to get the image to map to a plane with different orientation?
>>>>>>>> 
>>>>>>>> THanks
>>>>>>>> Rick Frank
>>>>>>>> 
>>>>>>>>> On Aug 28, 2016, at 12:51 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>>>>>>>> 
>>>>>>>>> Hi Frank,
>>>>>>>>> 
>>>>>>>>> It looks like you are doing a data transformation when you should be doing a view transformation.  Don't rotate the actor if your goal is to rotate the view.  When you rotate the actor, you are changing the relationship between data coordinates and world coordinates. 
>>>>>>>>> 
>>>>>>>>> If you want a sagittal view, then you can rotate the view by moving the VTK camera.  The mapper has a method SliceFacesCameraOn() that can be used to make the mapper automatically extract a slice in the correct orientation.
>>>>>>>>> 
>>>>>>>>> Also, please limit the width of inlined images to around 1000 pixels or less.  Large inlined images make your email hard to read on my system (I wish that gmail would auto-shrink oversized inlined images, but unfortunately it displays them full-size, even if they're several times the size of the display).
>>>>>>>>> 
>>>>>>>>>  - David
>>>>>>>>> 
>>>>>>>>>> On Sun, Aug 28, 2016 at 9:56 AM, Richard Frank <rickfrank at me.com> wrote:
>>>>>>>>>> Hi David,
>>>>>>>>>> 
>>>>>>>>>> Thanks for the reply. I'm still a bit confused about what I've tried and why it doesn't work....
>>>>>>>>>> 
>>>>>>>>>> So, I have 3 slice views and in the screenshot the Axial View is lined up appropriately (image position patient is in the correct place, and each slice is in correct place etc) with the world coordinates by using the image reslice axis and camera etc to align the DICOM coordinates and the VTK World coordinates.
>>>>>>>>>> 
>>>>>>>>>> I now want to orient the sagittal slice so that it aligns with the world coordinates.
>>>>>>>>>> 
>>>>>>>>>> (see screen shots)
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> I believe I need to rotate the slice (if I could rotate the actor) about Z 90 CCW and then about its new X 0- degrees and then move the camera about world Y 90 and the roll the camera 90 to get the sagittal voxels DICOM aligned with the World Coordinates. 
>>>>>>>>>> 
>>>>>>>>>> I tried various parameters for the resliceMapper->SetSlicePlane() but the slice just dissapears off screen somewhere so I must be getting sometime wrong.
>>>>>>>>>> 
>>>>>>>>>> How would I use the SetSlicePlane to achieve this?
>>>>>>>>>> 
>>>>>>>>>> Thanks
>>>>>>>>>> 
>>>>>>>>>> Rick
>>>>>>>>>> 
>>>>>>>>>>> On Aug 27, 2016, at 02:51 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>> You should also try vtkImageSliceMapper instead of vtkImageResliceMapper,
>>>>>>>>>>> perhaps its behavior will better suit your requirements.
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>>> On Sat, Aug 27, 2016 at 11:51 AM, David Gobbi <david.gobbi at gmail.com> wrote:
>>>>>>>>>>>> Hi Rick,
>>>>>>>>>>>> 
>>>>>>>>>>>> You're seeing this because you are doing an out-of-plane rotation on an image that has only one slice.  The rotation is around the image origin, which (in this case) is at the bottom-left corner of the image.
>>>>>>>>>>>> 
>>>>>>>>>>>> The vtkImageResliceMapper has a SetSlicePlane() method:
>>>>>>>>>>>> http://www.vtk.org/Wiki/VTK/Image_Rendering_Classes#vtkImageResliceMapper
>>>>>>>>>>>> You must rotate this SlicePlane when you rotate the vtkImageSlice.
>>>>>>>>>>>> 
>>>>>>>>>>>>  - David
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>>> On Sat, Aug 27, 2016 at 10:54 AM, Richard Frank <rickfrank at me.com> wrote:
>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>> 
>>>>>>>>>>>>> If I build the example 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> VTK/Examples/Cxx/Images/ImageSlice
>>>>>>>>>>>>> 
>>>>>>>>>>>>> and add
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  imageSlice->RotateX(1);
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Which should, I think, rotate the image actor about its X axis by 1 degree, I instead get
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> which seems incorrect.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> I can rotate about Z.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Is there something I'm not doing correctly, or is this a bug?
>>>>>>>>>>>>> 
>>>>>>>>>>>>> I also tried RotateWXYZ(1,1,0,0) and get the same result.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> This is VTK 7
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Rick
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160828/5c7ed2fe/attachment.html>


More information about the vtkusers mailing list