vtkImageResliceMapper and an image transform

Hi All,

I have a question: I need to reslice a DICOM volume, and I have been using successfully the vtkImageResliceMapper class to do so. I am looking now to apply a linear transform to the image volume and then to slice it. The class vtkImageReslice, which is used internally by the vtkImageResliceMapper, seems to support this use case as the documentation reads “You can use both the ResliceAxes and the ResliceTransform at the same time, in order to extract slices from a volume that you have applied a transformation to”. The class vtkImageResliceMapper does not seem though to expose the method SetResliceTransform() of the vtkImageReslice object, nor a reference to the object itself.

I am wondering whether there might be other convenient ways of achieving this that I am missing ?

Would deriving a class from vtkImageResliceMapper which exposes the Set ResliceTransform() of the vtkImageReslice object be a good idea?

Thanks for any appreciated suggestion,

Best Regards,

Andrea

Hi Andrea,

The vtkImageResliceMapper has an internal object called ResliceMatrix, and yes, you could create your own subclass to expose it via a GetResliceMatrix() method. Actually, the mapper calls reslice->SetResliceAxes(this->ResliceMatrix), it never calls reslice->SetResliceTransform().

You’ll have to be careful, though, because the ResliceMatrix was never meant to be exposed.

The way ResliceMatrix is computed depends on whether vtkImageResliceMapper::ResampleToScreenPixels is On or Off. This controls whether we want to map image coords to screen coords or to slice coords. I won’t go into the gritty details, but if you want to use the ResliceMatrix yourself, you must call ResampleToScreenPixelsOff().

I think the ideal solution would be to take the code from vtkImageResliceMapper that computes the matrix and move it into its own class that could be used from anywhere. The new class would take a slice plane (a vtkPlane) and compute a ResliceMatrix (vtkMatrix4x4). The tricky part of this class would be deciding on what additional constraints would be used in order to make the solution unique.

David

Hi David,

Thanks for the appreciated tips. I am looking at the source code of the class and I will experiment with subclassing.

I have a last question: the call reslice->SetResliceAxes(this->ResliceMatrix) and a potential call to reslice->SetResliceTransform() seem to be complementary and compatible with each other in principle from the documentation of vktImageReslice. I was hoping to make calls to the second and not to interfere with the internal working on the vtkImageeResliceMapper. Does this sound reasonable ?

In any case … I will experiment, thanks for the appreciated tips,

Best Regards,

Andrea

If you make your own vtkImageReslice object, then you can use SetResliceAxes() to apply the ResliceMatrix from the mapper, and then use SetResliceTransform() to apply an additional transform of your own. But the order in which these are applied might be the opposite of what you want. In other words, you might use SetResliceTransform() to apply the ResliceMatrix, after converting it to a vtkTransform, and then use SetResliceAxes() to add your own transformation. The order in which transformations is applied is very important, so which ordering you choose will depend on what you need to achieve.

Thank you for the tips and caveats. I will study the source code and experiment.

I will report back any useful learning, but it might be a while.

Best Regards,

Andrea

Leaving a message with an update in case someone reading this post has a similar problem to solve: in order to simplify things I ended up using a pipeline where as a first stage vtkImageReslice is used to resample the image. Specifically the inverse of the 4x4 image transform read from the DICOM series is set as argument of SetResliceAxes() - the output of vtkImageReslice at this point produces the transformed image. The vtkImageResliceMapper can then be applied to this image for display purposes, i.e. for generating image slices. Possibly the step of using vtkImageReslice could be avoided by customizing the vtkImageResliceMapper as discussed above, but I didn’t have time to do it.