Expert automated registration

Hi everyone,

I’m working on a project about registration of MR and CT images of pelvis. The only module that works for me without providing initial manual transformation is Expert Automated module which registers when the CT is the fixed Volume and MR is the moving. When I put MR as the fixed volume not only I don’t get an alignment but also the field of view changes. I’m attaching the result of both. I need to know what is the reason and how do I know which parameters and in which way should I change them to improve my results? I appreciate any help.

Expert automated registration is a very basic registration method, which require extensive parameter tuning. I would recommend to use SlicerElastix extension instead. Its default registration presets work without the need for any parameter adjustments. See more information here.

Thanks very much for your reply. I have tried Elastix and Brainsfit but no luck. I get this line in my Errorlog: Stop condition from optimizer.RegularStepGradientDescentOptimizerv4: Step too small after 481 iterations. Current step (0.00078125) is less than minimum step (0.001).
Does this mean that the optimization is stuck in an extrema ?

By comparing the volumes in the slicer I see that the coronal and sagittal views need a simple translation but the axial views seem flipped or very far away to me (please find attached the picture). I have tried transforming the right/left axes in the transform matrix of Transform module and also centering the volumes but the registration still does not work.

Is there any way to do changes on the axial view only? like rebuilding or flipping the slices?

When I do manual transform I have to put the Inferior Superior scroll bar of translation on -206.0000mm to be able to match the geometry. Does this distant seem out of reach for the registration algorithms to work ?

It is good, it means that the solution converged. It might not have been the global optimum, though.

Brainsfit requires parameter tuning, so I would recommend to start with Elastix.

For all automatic intensity-based image registration you need to prealign the images, to have not more than a 5-10 mm and 5-10 degrees error. You can use landmark registration for this. Make sure to harden the transform on the images before you start the automatic registration.


Your comments are amazing Andras, thank you for your time.

I wonder if it’s possible to change the sequence of slices so that when the registration puts the images together the axial view would also match up? for example if the axial view now shows me 159th slide when I fit the image to the window, I would like it to show me the 39th slide first on top.

Also trying other methods to be able to compare for my thesis, I have a model of the pelvis in the CT image which I would like to register on the MRI image. In the FAQ page of registration mentions that “You can run surface and image registrations separately and then combine the transforms”. I’m not sure if I understand correctly! does this mean first to make a model out of the MRI image (which I found not easy) and do the surface registration with the CT model. Second do the registration between CT and MRI images and finally combine the transform of these two steps ?

Slicer does not rely on order of slices, it only matters where the slices are mapped in the physical space (using IJKToRAS transform). If you want to make sure that two volumes have the same geometry (same IJK voxel is located at the same physical RAS position) then you can use “Resample scalar/vector/DWI volume” module and use one volume as reference to resample the other volume.

Bone segmentation on MRI is hard, so probably you don’t want to do surface registration.

1 Like


I applied gradient anisotropic diffusion to both CT and MRI of one of the patients and I got the perfect automatic registration via Elastix for when MRI was the fixed image and CT moving. I inverted the transform and applied manually to CT and got the perfect registration however when I do this with Elastix on fixed CT I don’t get the right transform. What could be the reason for this and is there a way to tune it?

As gradient anisotropic diffusion was successful for automatic registration I would like to use fuzzy edge detection on CT and MRIs to be able to help other registrations that Elastix doesn’t work. For that I need to do the edge detection on the individual slices in Matlab but looking at the MatlabBridge tutorial it uses voxels in the matlab file for further codings. I’m confused on how to get to pixels(on individual slices) for edge detection and again back to voxel for slicer to view the images. I appreciate if you can guide me on this. Thank you.

There could be many reasons. Asymmetric extent (one image is larger than the other), number of samples, voxel size, etc.

In general, you need both the forward and inverse transform, so it does not matter what direction you compute. If image resampling time is an issue (resampling an image takes longer time if the inverse transform needs to be computed) then you can precompute and store the inverse transform in a grid transform.

I would not recommend applying any additional preprocessing, unless it is absolutely unavoidable. It makes the registration time longer, introduces several new variables and overall increases complexity of the algorithm and so the uncertainty of the end result.

1 Like

Hi Andras,

I cropped CT and MRI’s to exclude extra darkness in the MRIs and also the table from CT images. At the same time made voxels isotropic and increased spacing scale (in CropVolume module) in both modalities so that image dimensions and voxel sizes get close together. Doing these changes, finally rigid registration with Elastix was successful. I experimented with many isotropic voxel sizes between CT and MRI to find this optimum registration. But I have pelvis CT and MRI’s of other patients(with original same voxel sizes and dimensions only better contrasts) that just register with no manipulation needed so I want to optimize registration parameters for images that need manipulation to get registered but I don’t know how to interpret the above trick in terms of registration parameters! Would you give me a hint on this?

To try other ways, I masked the pelvis area to give as ROI to Elastix but it wasn’t successful as cropping the images. Shouldn’t masking and cropping give the same result?

Registration should not very sensitive to voxel size, because sampling is done in physical space and the sample is interpolated similarly how you interpolate when you resample the images before registration.

Cropping the images to approximately to the same region helps the registration for many reasons (helps automatic initial alignment, optimal center of rotation position, ensures image samples are taken from relevant regions). It is also very important to crop or mask any regions that are incorrect in any of the images (e.g., if an image has a black border than that border must be removed or masked).

Masking can help with suppressing irrelevant regions in the image, but does not have all the other benefits of cropping, so it is not a replacement of cropping. Masking is rather can be used in addition to cropping as a further refinement. For example, for cases when you cannot remove all irrelevant parts with a rectangular cropping region (e.g., you have removed a tumor from the center of the image or some interventional tools are visible in one of the image then you can mask out those small regions inside the volume).

1 Like


The cropping and masking that works for my other image registrations don’t work on one of the CT/MRI pairs. I used Volume Rendering to see them relative to each other , they seem close together but I don’t really understand what’s wrong with them. I attach them here and appreciate if you could take a quick look.

The scan order in CT is Axial and in MRI is Coronal. Can this difference make a problem?

Every time I perform the registration with slightly different cropping or voxel sizes I get a different transformation matrix but the result looks the same to my eyes. How can I explain this?

Rigid registration of these data sets work well, using SlicerElastix:

  • Prealign the volumes (for example, you can use 3 landmark points and SlicerIGT extension’s Fiducial Registration wizard module)
  • Define a ROI that contains the common region between the CT and MRI
  • Crop the CT and the MRI using this common ROI using Crop volume module (you will have a cropped MRI and cropped CT)
  • Apply bias field correction to the cropped MRI (slightly improves the end result)
  • Register the cropped CT with the cropped bias-corrected MRI using SlicerElastix, using “generic rigid (all)” preset

Deformable registration is challenging, maybe because of the large difference in rectal and bladder filling, but maybe further reducing the region of interest and tuning registration parameters could help.


Hi Andras,

Would you tell me how did you capture all the three views in this video? The screen capture module only allows individual slice views at a time. and in the layout toolbar I found side by side option which only has red and yellow slice views and not three.

Thanks so much.

You can enable “Capture all views” option to capture all views.

Yes I tried that but the 3D view will also be included. I don’t want the 3D view in the video.

There are several layouts where you can move the splitter between the 3D view and the slice views. Choose one of those and move the slider towards the 3D view until it disappears. You can also define a layout that contains only slice views.

1 Like

Hi Andras,

Hope you’re doing well. I finally could find the automatic registration with Elastix using NMI and it doesn’t need cropping of images.
Now I want to compare this result with other ways of registration i.e. fiducial + default elastix MI. I got expert identified landmarks for my images. when I use the rigid transform the RMS value is 5.7 for when the CT fiducials are in “From fiducials” menu but when I do the other way around RMS value will be 53. What could be wrong?
Also going from rigid to similarity and warping the RMS value decreases. Should I choose warping because RMS value is smaller? and is this a good idea to compare this result with my automatic rigid registration to see if I needed a non-rigid registration after all?

It is hard to guess what’s happening. The best would be if you could save the scene as mrb, upload it somewhere, and post the link here. Or at least attach a few screenshots

If you register targets in soft tissues then warping registration is generally more appropriate and expected to result in smaller residual error reported by the fiducial registration module.

Target registration error can be computed by applying the computed transform to the ground truth fiducials of the moving image and compute RMS error with the ground truth fiducials of the fixed image.

1 Like

Thank you. I learned from the registration case library how to assess the landmarks in relation to each other and it seems if there is symmetry between landmarks on the right and left the RMS value can’t be calculated very accurately so I deleted some of the landmarks. I did a Mutual Information registration with elastix after the fiducial registration so I need to add the transform parameters from the fiducial registration to the elastix parameters to be able to compare it with transform parameters from other techniques . I don’t know how to change the resulting transform from fiducial registration to the elastix format. would you tell me how to do it?

Elastix typically computes a grid transform (it can output a custom linear and bspline transform, but we cannot import those reliably into Slicer), while you typically use fiducial registration to compute a linear transform or thin-plate spline transform. You don’t change the format of these transforms, but you can concatenate them (by applying and then hardening one transform on te other) and store them in a single transform node.