[vtkusers] Reslice+Users Transform

David Gobbi david.gobbi at gmail.com
Thu Mar 27 11:48:09 EDT 2014


Hi Simone,

You are correct, the problem is probably with the transform.
But there are so many things that can go wrong when you
are building a transform, and you are the only person who
knows all the details about your data.

So I cannot solve this problem for you, all I can do is give
you some advice:

1) Make sure that you understand what coordinate systems
the images are using, and what coordinate systems the
transform is using.

2) The ResliceTransform is the transform from output data
coordinates to input data coordinates.  For your data, you
must set it to the transformation that goes from your ultrasound
image to your MR image.

3) Also note that the ResliceTransform works in "data coordinates",
which means that it takes into account the Origin and Spacing of
the data.  For medical images, the Origin and Spacing are almost
always in millimetres.  So, the ResliceTransform takes you from
one coordinate system that is measured in millimetres, to another
coordinate system that is measured in millimetres.

I notice that when you read the NIFTI files, you do not use the
sform or the qform that is stored in the NIFTI header.   Depending
on your data and your transform, you might have to take either the
sform or the qform into account.

  David


On Thu, Mar 27, 2014 at 9:08 AM, strioso <tonti.simone at gmail.com> wrote:
> Hi guys,
>
> I have some problems with vtkImageReslice. I have two volumes(MR and US) and
> I want to realign these two volumes. To do this I use vtkImageReslice with
> transform matrix calculated before like this:
>
>     static double t[16] = {
>         0.84537937, 0.51377839, -0.14616932, 64.103854,
>         0.37424072, -0.76492788, -0.52424155, 23.099208,
>         -0.38115298, 0.38848049, -0.83893107, -109.90416,
>         0, 0, 0, 1 };
>     vtkSmartPointer<vtkMatrix4x4> m = vtkSmartPointer<vtkMatrix4x4>::New();
>     m->DeepCopy(t);
>     vtkSmartPointer<vtkTransform> transform =
> vtkSmartPointer<vtkTransform>::New();
>     transform->SetMatrix(m);
>
>
>     vtkImageData *input=0;
>     //Lettura NIFTI
>     vtkSmartPointer<vtkNIFTIImageReader>
> readerMR=vtkSmartPointer<vtkNIFTIImageReader>::New();
>     vtkSmartPointer<vtkNIFTIImageReader>
> readerUS=vtkSmartPointer<vtkNIFTIImageReader>::New();
>     readerMR->SetFileName(inputFilenameMR.c_str());
>     readerUS->SetFileName(inputFilenameUS.c_str());
>     readerMR->Update();
>     readerUS->Update();
>     input=readerUS->GetOutput();
>
>     //Reslicing
>     vtkSmartPointer<vtkImageReslice> reslice =
> vtkSmartPointer<vtkImageReslice>::New();
>     //MR image to be resliced
>     reslice->SetInputConnection(readerMR->GetOutputPort());
>     //transformation matrix
>     reslice->SetResliceTransform(transform);
>     // input US to provide dimension and spatial resolution
>     reslice->SetInformationInput(input);
>     // interpolation mode
>     reslice->SetInterpolationModeToCubic();
>     reslice->Update();
>
> Make and build are made with no errors but the output reslice volume is
> empty! Why?! Could someone help me? I try several solutions but all of these
> gave the same problem. I think the problem is transformation matrix or
> something connected because if I remove
> "reslice->SetResliceTransform(transform);" the code works fine and the
> output reslice volume isn't empty.
> Thanks to all!
>
> Simone


More information about the vtkusers mailing list