# MRI/CT registration

**URL:** <https://discourse.slicer.org/t/mri-ct-registration/38217>\
**Category:** Support\
**Created:** [September 4, 2024, 7:14pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217 "2024-09-04T19:14:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kowsar\_Sheikhi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kowsar_sheikhi/32/77800_2.png) [@Kowsar\_Sheikhi](https://discourse.slicer.org/u/Kowsar_Sheikhi)\
**Post date:** [September 4, 2024, 7:14pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/1 "2024-09-04T19:14:38Z")

</div>

Hi,

Do you have any suggestions for MRI/CT image registration?  
Both images are in DICOM format and have been cropped to focus on the ROI. I have tried using the Brain and Elastix methods, but they didn’t work well (perhaps I made a mistake, as they finished with errors).

 ![registraton-3dslicer.PNG](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/d/5df7dbeef96495bfc09ae441bd5685287001dc12.jpeg)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 4, 2024, 8:52pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/2 "2024-09-04T20:52:00Z")

</div>

It’s a bit hard to tell from the screenshot, but they look like they should be able to be registered. Perhaps you can post the error messages (use the Help-\>report a bug dialog to get the full log file).

A registration issue could be the knee angle being different in which case you may need to do the bones independently or something.

---

<div class="post-metadata">

**Author:** ![Kowsar\_Sheikhi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kowsar_sheikhi/32/77800_2.png) [@Kowsar\_Sheikhi](https://discourse.slicer.org/u/Kowsar_Sheikhi)\
**Post date:** [September 5, 2024, 12:42pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/3 "2024-09-05T12:42:50Z")

</div>

I manually created the transformations for them and centralized both. All transformations have been saved as LinearTransform. I tried using Elastix with the LinearTransform and received the following error:

 ![Elastix.PNG](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/2/a28fb9690a087fe6ef5cf1b321d95cbbb5b2c2b2.jpeg)

I also tried the general registration (Brains) with the same LinearTransform, but the result was not the clear registration I wanted:

 ![Brains](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/3/63e32342d3ce2ae5f0bd90b5207139c0ab467791.png)

They are human knees, and because they are changing, I used the MomentsAlign transform mode.

3DSlicer 5.6.2

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 5, 2024, 1:09pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/4 "2024-09-05T13:09:08Z")

</div>

You’ll need to look at the error messages (the full details are not visible in these screenshots). I suggest you practice with other datasets (e.g. sample data from the [registration library](https://www.slicer.org/wiki/Documentation/Nightly/Registration/RegistrationLibrary)) and then apply what you learn to these.

---

<div class="post-metadata">

**Author:** ![Kowsar\_Sheikhi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kowsar_sheikhi/32/77800_2.png) [@Kowsar\_Sheikhi](https://discourse.slicer.org/u/Kowsar_Sheikhi)\
**Post date:** [September 5, 2024, 1:15pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/5 "2024-09-05T13:15:33Z")

</div>

Thanks! I have done some registrations before, but all of them were from the same modality (MRI/MRI or CT/CT). Now, when I try CT/MRI registration, it doesn’t work.

Do you know if there is any SOP or document available for CT/MRI registration?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 5, 2024, 1:20pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/6 "2024-09-05T13:20:27Z")

</div>

Well it should “just work” for many situations as you can see from the examples I sent you. Please be sure to study the [documentation](https://slicer.readthedocs.io/en/latest/user_guide/registration.html) and try to see what’s different with your data.

---

<div class="post-metadata">

**Author:** ![Kowsar\_Sheikhi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kowsar_sheikhi/32/77800_2.png) [@Kowsar\_Sheikhi](https://discourse.slicer.org/u/Kowsar_Sheikhi)\
**Post date:** [September 9, 2024, 2:55pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/7 "2024-09-09T14:55:22Z")

</div>

I have tried all the registration modes based on the documentation page, but the problem persists, and I still couldn’t register my images.

I would appreciate it if anyone could help me with this issue.  
Thanks!

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 9, 2024, 3:00pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/8 "2024-09-09T15:00:15Z")

</div>

If the examples work correctly, but your data doesn’t work then you’ll need to figure out what’s different about your data. Is it data you can share publicly?

---

<div class="post-metadata">

**Author:** ![Matteboo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/matteboo/32/66548_2.png) [@Matteboo](https://discourse.slicer.org/u/Matteboo)\
**Post date:** [September 9, 2024, 3:39pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/9 "2024-09-09T15:39:52Z")

</div>

You can get a more detailled error message by looking at the elastix log. To do this:

- check “Keep temporary files” in the “Advanced” tab
- Launch your registration
- Once it failed, click on “show temp folder”
- Open the elastix.txt file and scroll down to find the error

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 11, 2024, 7:22pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/11 "2024-09-11T19:22:06Z")

</div>

Okay, thanks for sharing the data - I can see now what’s going on and give you some suggestions.

First there’s a big difference in both resolution and field of view. So with the default settings BRAINSFit was giving this kind of message (you can see them in the python console).

```auto
[VTK] All samples map outside moving image buffer. The images do not sufficiently overlap. They need to be initialized to have more overlap before this metric will work. For instance, you can align the image centers by translation.
[VTK] General Registration (BRAINS) completed with errors

```

This is because the MR covers a lot of anatomy above and below the join space, while the microCT only covers the joint area. Also the microCT is about 10x smaller pixels than the MR. So I used the CropVolume module with an 8x spacing multiplier to get a low res version, than use the microCT’s ROI to crop the MR with a 1x multiplier.

Then in the BRAINSFit it completed but with a poor result, so I changed the percentage of sample from the default of 0.002 to 1. This uses more of the image to do the optimization and can really impact the result (although with big images it will take longer.

I also tried setting the Max Iterations in the Advanced Optimization Settings to 15000 from 1500 but I don’t think this had as much impact.

After that things look reasonable to me:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/a/aa7730ebcad81da6e6ca5dca5a2caa9364f18a9d.jpeg)

For reference here’s what the cropped volumes looked like before registration:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/9/e97d3dfadd0ac7efd4157e2c8262ac8288e607d9.jpeg)

---

<div class="post-metadata">

**Author:** ![Kowsar\_Sheikhi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kowsar_sheikhi/32/77800_2.png) [@Kowsar\_Sheikhi](https://discourse.slicer.org/u/Kowsar_Sheikhi)\
**Post date:** [September 12, 2024, 12:46pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/12 "2024-09-12T12:46:33Z")

</div>

Thank you so much for your help!! Now I can see the registered images! 🙂

Another question:  
Is it now possible to see the Python code and functions behind the registration process?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 12, 2024, 1:45pm UTC](https://discourse.slicer.org/t/mri-ct-registration/38217/13 "2024-09-12T13:45:36Z")

</div>

You can perform all these operations in python, and there are lots of examples of how this works. [Script repository — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#registration)
