# Scaling in Surface Registration

**URL:** <https://discourse.slicer.org/t/scaling-in-surface-registration/4607>\
**Category:** Support\
**Created:** [October 31, 2018, 6:03pm UTC](https://discourse.slicer.org/t/scaling-in-surface-registration/4607 "2018-10-31T18:03:40Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marzieh\_Golabbakhsh](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@Marzieh\_Golabbakhsh](https://discourse.slicer.org/u/Marzieh_Golabbakhsh)\
**Post date:** [October 31, 2018, 6:03pm UTC](https://discourse.slicer.org/t/scaling-in-surface-registration/4607/1 "2018-10-31T18:03:40Z")

</div>

Hi  
I use the following module:

Registration/ CMF Registration/ Surface Registration to register two stl models.

My understanding(after looking up the linearTransform marices) is here it only uses Rotation and Translation in calculating linearTransforms either with affine or RigidBody transforms.

but I need scaling too!

What should I do?

---

<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:** [October 31, 2018, 7:04pm UTC](https://discourse.slicer.org/t/scaling-in-surface-registration/4607/2 "2018-10-31T19:04:44Z")

</div>

There are other modules for surface registration:

- SlicerIGT extension’s _Model registration_ module: uses ICP and supports rigid and similarity (rigid+scaling) transforms
- _SegmentRegistration_ extension’s _Segment registration_ module: uses distance map based registration and supports rigid and deformable (warping) transforms. You need to import your models into segmentation node using Segmentations module (takes 3-4 mouse clicks).

---

<div class="post-metadata">

**Author:** ![Marzieh\_Golabbakhsh](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@Marzieh\_Golabbakhsh](https://discourse.slicer.org/u/Marzieh_Golabbakhsh)\
**Post date:** [November 1, 2018, 6:19pm UTC](https://discourse.slicer.org/t/scaling-in-surface-registration/4607/3 "2018-11-01T18:19:13Z")

</div>

> [@lassoan](#):
>
> uses distance map based registration

Thanks for your reply. I found “Distance Map Based Registration” in Registration/Label Registration. Is this the one you referred?  
I think I can not use stl files and maybe I have to use LabelMapVolume? Is there a way I can convert stl or wrl files to LabelMappVolume in Slicer?

---

<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:** [November 1, 2018, 9:08pm UTC](https://discourse.slicer.org/t/scaling-in-surface-registration/4607/4 "2018-11-01T21:08:51Z")

</div>

> [@Marzieh\_Golabbakhsh](#):
>
> Thanks for your reply. I found “Distance Map Based Registration” in Registration/Label Registration

You need “Segment registration” module (in Registration category). The module is provided by SegmentRegistration extension.

> [@Marzieh\_Golabbakhsh](#):
>
> I think I can not use stl files and maybe I have to use LabelMapVolume? Is there a way I can convert stl or wrl files to LabelMappVolume in Slicer?

You need to import your models into segmentation node using Segmentations module (takes 3-4 mouse clicks). Then you can use Segment Registration module to register them.

---

<div class="post-metadata">

**Author:** ![Marzieh\_Golabbakhsh](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@Marzieh\_Golabbakhsh](https://discourse.slicer.org/u/Marzieh_Golabbakhsh)\
**Post date:** [November 5, 2018, 8:11pm UTC](https://discourse.slicer.org/t/scaling-in-surface-registration/4607/5 "2018-11-05T20:11:22Z")

</div>

> [@lassoan](#):
>
> Segment Registration module

After using this module, when I go to save the files:  
I have for example: PreAlignmentMoving2FixedLinearTransform\_3.h file.  
However, Affine Transform and Deformable Transform have status “Not Modified”

And I am not even sure if the modification that I see is results of a complete alignment or not!

---

<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:** [November 5, 2018, 10:13pm UTC](https://discourse.slicer.org/t/scaling-in-surface-registration/4607/6 "2018-11-05T22:13:58Z")

</div>

Are the segments aligned before registration? Do they look aligned after the registration?

What are the next steps of your workflow? Do you want to save the transforms and/or the transformed segments? In what format (nrrd, ITK, DICOM,…)?

---

<div class="post-metadata">

**Author:** ![Marzieh\_Golabbakhsh](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@Marzieh\_Golabbakhsh](https://discourse.slicer.org/u/Marzieh_Golabbakhsh)\
**Post date:** [November 6, 2018, 2:58pm UTC](https://discourse.slicer.org/t/scaling-in-surface-registration/4607/7 "2018-11-06T14:58:20Z")

</div>

> [@lassoan](#):
>
> Are the segments aligned before registration? Do they look aligned after the registration?

The segments move close to each other after registration but they are not aligned. I feel they are only rotated and translated. They are on top of each other after registration.

> [@lassoan](#):
>
> What are the next steps of your workflow? Do you want to save the transforms and/or the transformed segments? In what format (nrrd, ITK, DICOM,…)?

I need to save the transform and be able to apply it to new data. Also I want to save the transformed segments too. I prefer nrrd for now but I can also work with other formats as long as I can open them with Slicer and work with them.

It is helpful also if I have access to parameters of the Transform and Registration and can understand how parameters will affect my registration.

Thanks

---

<div class="post-metadata">

**Author:** ![Marzieh\_Golabbakhsh](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@Marzieh\_Golabbakhsh](https://discourse.slicer.org/u/Marzieh_Golabbakhsh)\
**Post date:** [November 12, 2018, 4:53pm UTC](https://discourse.slicer.org/t/scaling-in-surface-registration/4607/8 "2018-11-12T16:53:03Z")

</div>

> [@lassoan](#):
>
> Are the segments aligned before registration? Do they look aligned after the registration?
> 
> What are the next steps of your workflow? Do you want to save the transforms and/or the transformed segments? In what format (nrrd, ITK, DICOM,…)?

To clarify my problem:

I think I don’t have scaling in my transformed model although I used segment registration module.  
I think they are just pre-aligned with translation and rotation and not aligned with deformed or affine transformation.  
I want to know why this happens?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [November 12, 2018, 7:03pm UTC](https://discourse.slicer.org/t/scaling-in-surface-registration/4607/9 "2018-11-12T19:03:33Z")

</div>

Rigid registration by definition does not include scaling. Segment Registration however performs deformable registration as well, which does. You need to make sure that the deformable transform is applied on your segmentation.

It is also possible that the registration fails. If you open the Python Interactor do you see any red text in there? If so, can you please post the log? You can find it in About / Report a problem.

---

<div class="post-metadata">

**Author:** ![Marzieh\_Golabbakhsh](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@Marzieh\_Golabbakhsh](https://discourse.slicer.org/u/Marzieh_Golabbakhsh)\
**Post date:** [November 13, 2018, 3:18pm UTC](https://discourse.slicer.org/t/scaling-in-surface-registration/4607/10 "2018-11-13T15:18:54Z")

</div>

> [@cpinter](#):
>
> Rigid registration by definition does not include scaling. Segment Registration however performs deformable registration as well, which does. You need to make sure that the deformable transform is applied on your segmentation.
> 
> It is also possible that the registration fails. If you open the Python Interactor do you see any red text in there? If so, can you please post the log? You can find it in About / Report a problem.

This is my log:

```auto
Python 2.7.13 (default, Dec 20 2017, 00:16:35)

[GCC 4.6.4] on linux2

&gt;&gt;&gt;

Performing registration workflow

Cropping moving volume

Pre-aligning segmentations

Fixed segment bounds: [21.5, 87.5, 204.856399536133, 384.85639953613304, -139.567398071289, 84.432601928711]

Moving segment bounds: [18.5, 75.5, 65.85639953613301, 217.856399536133, 69.432601928711, 213.432601928711]

Moving to fixed segment translation: [7.5, 153.00000000000003, -169.0]

Resampling fixed volume

Creating contour labelmaps

Performing distance based registration

Traceback (most recent call last):

File &quot;/home/marzieh/.config/NA-MIC/Extensions-26813/SlicerProstate/lib/Slicer-4.8/qt-scripted-modules/DistanceMapBasedRegistration.py&quot;, line 249, in onApplyButton

logic.run(self.parameterNode)

File &quot;/home/marzieh/.config/NA-MIC/Extensions-26813/SlicerProstate/lib/Slicer-4.8/qt-scripted-modules/DistanceMapBasedRegistration.py&quot;, line 356, in run

(bbMin,bbMax) = self.getBoundingBox(fixedLabelNodeID, movingLabelNodeID)

File &quot;/home/marzieh/.config/NA-MIC/Extensions-26813/SlicerProstate/lib/Slicer-4.8/qt-scripted-modules/DistanceMapBasedRegistration.py&quot;, line 501, in getBoundingBox

unionLabelImage = (cast.Execute(fixedLabelImage) + cast.Execute(movingLabelImage)) &gt; 0

File &quot;/home/marzieh/Downloads/Slicer-4.8.1-linux-amd64/lib/Python/lib/python2.7/site-packages/SimpleITK/SimpleITK.py&quot;, line 4254, in __add__

return Add( self, other )

File &quot;/home/marzieh/Downloads/Slicer-4.8.1-linux-amd64/lib/Python/lib/python2.7/site-packages/SimpleITK/SimpleITK.py&quot;, line 11002, in Add

return _SimpleITK.Add(*args)

RuntimeError: Exception thrown in SimpleITK Add: /home/kitware/Dashboards/Package/Slicer-481-package/ITKv4/Modules/Core/Common/include/itkImageToImageFilter.hxx:241:

itk::ERROR: AddImageFilter(0x7f469c0): Inputs do not occupy the same physical space!

InputImage Origin: [-9.4500000e+01, -5.3800000e+02, -3.0900000e+02], InputImage_1 Origin: [-8.2500000e+01, -3.7100000e+02, -1.6900000e+02]

Tolerance: 1.0000000e-06

Setting up result visualization

Performing registration workflow

Cropping moving volume

Pre-aligning segmentations

Fixed segment bounds: [29.0, 95.0, 357.85639953613304, 537.856399536133, -308.567398071289, -84.567398071289]

Moving segment bounds: [26.0, 83.0, 218.85639953613304, 370.85639953613304, -99.567398071289, 44.432601928710994]

Moving to fixed segment translation: [7.5, 153.0, -169.0]

Resampling fixed volume

Creating contour labelmaps

Performing distance based registration

Traceback (most recent call last):

File &quot;/home/marzieh/.config/NA-MIC/Extensions-26813/SlicerProstate/lib/Slicer-4.8/qt-scripted-modules/DistanceMapBasedRegistration.py&quot;, line 249, in onApplyButton

logic.run(self.parameterNode)

File &quot;/home/marzieh/.config/NA-MIC/Extensions-26813/SlicerProstate/lib/Slicer-4.8/qt-scripted-modules/DistanceMapBasedRegistration.py&quot;, line 356, in run

(bbMin,bbMax) = self.getBoundingBox(fixedLabelNodeID, movingLabelNodeID)

File &quot;/home/marzieh/.config/NA-MIC/Extensions-26813/SlicerProstate/lib/Slicer-4.8/qt-scripted-modules/DistanceMapBasedRegistration.py&quot;, line 501, in getBoundingBox

unionLabelImage = (cast.Execute(fixedLabelImage) + cast.Execute(movingLabelImage)) &gt; 0

File &quot;/home/marzieh/Downloads/Slicer-4.8.1-linux-amd64/lib/Python/lib/python2.7/site-packages/SimpleITK/SimpleITK.py&quot;, line 4254, in __add__

return Add( self, other )

File &quot;/home/marzieh/Downloads/Slicer-4.8.1-linux-amd64/lib/Python/lib/python2.7/site-packages/SimpleITK/SimpleITK.py&quot;, line 11002, in Add

return _SimpleITK.Add(*args)

RuntimeError: Exception thrown in SimpleITK Add: /home/kitware/Dashboards/Package/Slicer-481-package/ITKv4/Modules/Core/Common/include/itkImageToImageFilter.hxx:241:

itk::ERROR: AddImageFilter(0xa6c97a0): Inputs do not occupy the same physical space!

InputImage Origin: [-1.0200000e+02, -6.9100000e+02, -4.7800000e+02], InputImage_1 Origin: [-9.0000000e+01, -5.2400000e+02, -3.3800000e+02]

Tolerance: 1.0000000e-06

Setting up result visualization

```
