I have done a registration in the general registration module (BRAINS) and saved the transformation matrix in a text file. Using the transforms module, I now apply the same linear transformation to the original moving image of the registration, expecting it to match the output image of the registration but they do not. Can someone please help me understand why this happens?
What kind of transform did you create (linear, linear+bspline, …)?
If you apply the transform to the moving image right after registration, is the alignment correct?
By the images not matching you mean that in Slicer they don’t appear aligned?
Can you reproduce this with built-in sample data sets (MRBrainTumor1, MRBrainTumor2)?
Can you upload sample input data and results?
I created a linear transformation and no the alignment is not correct. I am viewing them on matlab. My goal is to use the same transformation (from the registration) on an image of a different modality, but I was suspicious that slicer was not giving me the correct transformation. That is why I decided to apply the linear transformation (from the registration) to the original moving image, expecting it to match (be aligned) to the output image of the registration, but they do not. I will try to do reproduce this with the sample data sets.
Are the images aligned correctly in Slicer, right after the registration is complete? If not then you need to tune the registration parameters or try using another registration module. For example, install Elastix extension and try “General registration (Elastix)” module. You may also try labdmark based registration (you define matching set of landmarks in both images and compute transform based on that), using Landmark registration module in Slicer core or Fiducial registration wizard module in SlicerIGT extension.
What kind of images you are trying to align? What anatomical part?
I think I figured out the problem- I am just going to manually change the transformation values in the transforms module. But, now I am having trouble saving (in .mhd format) the transformation after I apply the transformation. When I upload the transformed image, I view the the old image (before it was transformed). Is there some bug present in saving transformations in the transforms module?
I figured out that I need to “harden” the transform and then I can save it
If your software ignores image origin, orientation, or spacing then you must resample the transformed moving image in the fixed image’s coordinate system. See details here: https://www.slicer.org/wiki/Registration:Resampling
The goal of my project is to find the minimum margin between lesion and ablation zone from pre-ablation CT scan and post-ablation CT scan. To do that I need the registration post to pre CT scan.
I’m using Elastix to registre post-ablation CT scan to pre-ablation CT scan. I have liver lesion and ablation zone segmentation as a label for both pre and post scan.
For registration I resample CT scans and labels (lesion segmentation) into 512512512.
For some patients the registration is good but for others is not good. Therefore, I load the registred CT scan and pre -ablation CT scan to correct the registrarion manually in the 3D slicer.
I’ve saved the correct registration CT scan and label in nii.gz format.
The problem is here:
When I load the Correction regitration CT and its label in 3D slicer and also in ITK snap, they are similar.
But when I load correction registation CT and pre-label CT scan, they are not the same in 3D slicer and ITK snap anymore.
Can anyone give me a hint where could be a problem?
From this much information we cannot guess what is happening.
What do you exactly when you “correct the registrarion manually in the 3D slicer”?
Do you apply the registration transform on the CT scan?
Do you resample the CT scan?
Can you post screenshots to show what you mean by “they are not the same in 3D slicer and ITK snap anymore”?
Does all the data show up at the position you expect in 3D Slicer?
Does ITK-Snap display correct if you saved everything in .nrrd format?
Is there any specific processing or analysis step that you want to do in ITK-Snap instead of Slicer or you are just interested in general why position is different in ITK-Snap and Slicer?
Can you share an example scene (save as .mrb file - by clicking on the package icon in Sava data window)? Make sure no patient information is included - you can download public datasets from TCIA.
Thank you for your quick reply, I’ll answer your questions one by one:
I go to Data icon and in Transform hierarchy, right-click on old registration (which I want to correct it) and select instert transform which creates new nodes called LinearTransform_3. Then click the Transforms, select the LinearTransform_3 and play with the Translation option until the registration will be correct. then I click on Harden transform for both CT registration and label and then save them.
Yes, I apply the registration on CT scans
when I load the correct registration which I’ve saved in the 3D slicer and ITK snap, they are the same (the slices and the location), but when I load the pre-label scan on top of them, the location of the label is not the same.
Yes, in 3D slicer everything is perfect as I did registration manually and save them.
yes, I also try to save them in .nrrd format, it has the same problem.
Yes, I need to load the images in the python and find the minimum margin between the liver lesion and the ablation zone.
I’ll try to make an example scene as well.
Thanks,
Marjaneh
There does not seem to be anything wrong with your workflow, so the example scene would be very useful.
You can get minimum margin by exporting segmentations to models, running Model to model distance module (provided by Model to model distance extension), get the point scalars as numpy array, and get the minimum value (or histogram, etc.). It can all be python-scripted within Slicer, probably in 20-30 lines.
Thanks for your reply.
I had a discussion with @JoostJM in our office, and we found the problem. The origin of manual registration was different from the pre-label scan. And 3D slicer could recorrect for that while ITK cannot. So I need to change the origin of manual registration into the original pre-image.