# What does the B-spline transformation mean in Elastix?

**URL:** <https://discourse.slicer.org/t/what-does-the-b-spline-transformation-mean-in-elastix/30935>\
**Category:** Support\
**Tags:** registration\
**Created:** [August 2, 2023, 2:28pm UTC](https://discourse.slicer.org/t/what-does-the-b-spline-transformation-mean-in-elastix/30935 "2023-08-02T14:28:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drake](https://avatars.discourse-cdn.com/v4/letter/d/5fc32e/32.png) [@Drake](https://discourse.slicer.org/u/Drake)\
**Post date:** [August 2, 2023, 2:28pm UTC](https://discourse.slicer.org/t/what-does-the-b-spline-transformation-mean-in-elastix/30935/1 "2023-08-02T14:28:16Z")

</div>

Hello,  
I registered the MRI and the CT of the same subject using Elastix module. (MRI is the reference image and CT is movable image. ） The result contains B-spline transform:

![图片2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/2/02e965c15d29fa72ede9ed54dc259ffb64a8ed1f.png)

And it seems the B-spline transformation alone is non-rigid (shown as the figure below):

 ![图片1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/b/db657681737039ac26ca310897f799a3da0482ab.jpeg)

I also use SPM to do the registration, and just got a linear matrix. And I have validated the correctness of the result.

What does the B-spline transformation here really mean?  
Does it correspond to the “reslice” step of registration? Or maybe it really means a free-form deformation? if so, why does a whithin-subject transformation contain non-rigid transformation?

These questions have been bothering me for days.

Thanks!  
Drake

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 2, 2023, 2:45pm UTC](https://discourse.slicer.org/t/what-does-the-b-spline-transformation-mean-in-elastix/30935/2 "2023-08-02T14:45:02Z")

</div>

> [@Drake](#):
>
> What does the B-spline transformation here really mean?

It means that B-spline transformation parameters are adjusted by the registration optimizer while trying to align the moving and fixed image. B-spline is a warping transformation that uses a sparse grid of control points and b-spline interpolation to compute displacement vectors between the control points.

> [@Drake](#):
>
> Does it correspond to the “reslice” step of registration?

It is not related to reslice. You can use any kind of transform for reslicing (resampling) a volume.

> [@Drake](#):
>
> Or maybe it really means a free-form deformation?

Free-form deformation usually refers to warping an image with a dense displacement field, where each point of the fixed image may mapped to anywhere in 3D space. B-spline uses a sparse set of control points, so I would not consider it free-form deformation.

> [@Drake](#):
>
> why does a whithin-subject transformation contain non-rigid transformation?

There can be many reasons, including changes in shape of the patient (different posture, different jaw position, different padding of the scanner pushing soft tissue around, internal swelling, different filling of internal structures, patient gains/loses weight, etc.), different cropping of images (e.g., nose is cut off in one image but not in the other) or image artifacts. Visual inspection should clearly answer this question.

If you prefer to use a rigid transformation - for example: you want to register a bones in two images that were taken at almost the same time - then you can choose a rigid registration preset that does not attempt to get better alignment by warping.

---

<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:** [August 2, 2023, 2:56pm UTC](https://discourse.slicer.org/t/what-does-the-b-spline-transformation-mean-in-elastix/30935/3 "2023-08-02T14:56:05Z")

</div>

Slicer relies on [ITK](https://itk.org) for registration primitives. See the [ITK book](https://itk.org/ItkSoftwareGuide.pdf) for more details.

---

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [August 2, 2023, 3:03pm UTC](https://discourse.slicer.org/t/what-does-the-b-spline-transformation-mean-in-elastix/30935/4 "2023-08-02T15:03:11Z")

</div>

> [@Drake](#):
>
> why does a whithin-subject transformation contain non-rigid transformation?

Humans are squishy!

More info on elastix: [https://elastix.lumc.nl/download/elastix-5.1.0-manual.pdf](https://elastix.lumc.nl/download/elastix-5.1.0-manual.pdf)  
On using b-splines for medical image registration: [http://image.diku.dk/imagecanon/material/Rueckert-IEEETMI1999.pdf](http://image.diku.dk/imagecanon/material/Rueckert-IEEETMI1999.pdf)

---

<div class="post-metadata">

**Author:** ![Drake](https://avatars.discourse-cdn.com/v4/letter/d/5fc32e/32.png) [@Drake](https://discourse.slicer.org/u/Drake)\
**Post date:** [August 3, 2023, 1:50am UTC](https://discourse.slicer.org/t/what-does-the-b-spline-transformation-mean-in-elastix/30935/5 "2023-08-03T01:50:56Z")

</div>

Thank you so much for your reply!!

I did want to register skull in two images and also try the ‘generic rigid(all)’ preset, that I’m not sure correct or not. But the results still contain B-spline transformation, it also made me confused.

By the way，

1. Does the result world-to-world transformation matrix (RAS space), rather than voxel-to-voxel (image space)?
2. If I just want to use the B-spline results to transform the skull COR from CT scan into MRI space in codes, what information or document can I access to? I only know the GUI method for B-spline transformation now.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 3, 2023, 4:35am UTC](https://discourse.slicer.org/t/what-does-the-b-spline-transformation-mean-in-elastix/30935/6 "2023-08-03T04:35:56Z")

</div>

> [@Drake](#):
>
> try the ‘generic rigid(all)’ preset, that I’m not sure correct or not. But the results still contain B-spline transformation

You’ve found a bug! (result of some recent code refactoring) When you selected the rigid preset, it got reverted to the default preset because the two presets had the same ID. The issue is now [fixed](https://github.com/lassoan/SlicerElastix/commit/d98ebdeec1552ffc78b54821e6cdc9379e4ddd5c), update SlicerElastix extension to get the updated version of the extension (only on latest Slicer Stable Release or very latest Slicer Preview Release).

> [@Drake](#):
>
> voxel-to-voxel (image space)

It is up to each library and application to decide how to organize the voxels in memory and assign IJK coordinates to voxels. However, medical imaging file formats unambiguously specify where the voxels are in physical space. Therefore specifying transformation in voxel space is not an option, but registration methods must always provide transformation in physical space.

> [@Drake](#):
>
> what information or document can I access to?

You have access to all information (most notably the computed transform) and you can do anything with it (save to ITK transform file, use it to resample the moving image, warp segmentations, models, markups with the transform, etc. each by a few lines of Python script). You can find examples in the Slicer script repository, in Slicer forum posts, tests, and examples, which you can find using Google, you can often get fully functional Python code by asking Bing chat, and you can of course also ask specific questions here from us.
