# Combining surface registration and model-to-model distance functionalities

**URL:** https://discourse.slicer.org/t/combining-surface-registration-and-model-to-model-distance-functionalities/18347
**Category:** Development
**Created:** [June 26, 2021, 7:24am UTC](https://discourse.slicer.org/t/combining-surface-registration-and-model-to-model-distance-functionalities/18347 "2021-06-26T07:24:06Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![seanchoi0519](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/seanchoi0519/32/10354_2.png) [@seanchoi0519](https://discourse.slicer.org/u/seanchoi0519)
#### Post date: [June 26, 2021, 7:24am UTC](https://discourse.slicer.org/t/combining-surface-registration-and-model-to-model-distance-functionalities/18347/1 "2021-06-26T07:24:06Z")

</div>

I have an established workflow and I’d like to streamline & combine the functionalities of - ALPACA, model-to-model distance, and shape-population-viewer (in order).

For example, if possible, I’d like to take the product of ALPACA (aligned models) and automatically feed them into model-to-model distance for distance computation, in 1 click.

I noticed that Model-to-model distance module does not have .py file so I cannot edit/make changes. How can I best approach this? Any advice would be appreciated.

Model-to-model documentation: [Documentation/Nightly/Extensions/ModelToModelDistance - Slicer Wiki](https://www.slicer.org/wiki/Documentation/Nightly/Extensions/ModelToModelDistance)

---

<div class="post-metadata">

### Author: ![seanchoi0519](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/seanchoi0519/32/10354_2.png) [@seanchoi0519](https://discourse.slicer.org/u/seanchoi0519)
#### Post date: [June 26, 2021, 1:54pm UTC](https://discourse.slicer.org/t/combining-surface-registration-and-model-to-model-distance-functionalities/18347/2 "2021-06-26T13:54:16Z")

</div>

Andras, thanks for this piece of code - I was able to successfully integrate it into my code without having to use model-to-model & shape population viewer.

There are just a few changes I’d like to make - it looks like with this piece of code it can only show a positive difference (for ex. the area where it’s the target model has been trimmed too much with respect to the source model, but not vice versa). How can I make it show a negative difference?

Also how can I alter the colour range? For example -0.5 to 0.5 similar to how it’s done in shape population viewer

thanks a lot

---

<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: [June 26, 2021, 2:31pm UTC](https://discourse.slicer.org/t/combining-surface-registration-and-model-to-model-distance-functionalities/18347/3 "2021-06-26T14:31:24Z")

</div>

The distance filter computes signed distance by default, so probably you just need to tune the color mapping.

---

<div class="post-metadata">

### Author: ![seanchoi0519](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/seanchoi0519/32/10354_2.png) [@seanchoi0519](https://discourse.slicer.org/u/seanchoi0519)
#### Post date: [June 26, 2021, 9:27pm UTC](https://discourse.slicer.org/t/combining-surface-registration-and-model-to-model-distance-functionalities/18347/4 "2021-06-26T21:27:13Z")

</div>

Thanks for the tip Andras. Would you know what piece of code I need to change the “Displayed Range” section? I’ve tried setScalarRange however it does not seem to change anything.

 ![Screen Shot 2021-06-27 at 8.15.17 AM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/9/5944418f5bda8aa6056f1d2a4107e78447d284f0.png)

Any advice would be great

---

<div class="post-metadata">

### Author: ![seanchoi0519](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/seanchoi0519/32/10354_2.png) [@seanchoi0519](https://discourse.slicer.org/u/seanchoi0519)
#### Post date: [June 26, 2021, 11:22pm UTC](https://discourse.slicer.org/t/combining-surface-registration-and-model-to-model-distance-functionalities/18347/5 "2021-06-26T23:22:27Z")

</div>

I would like to change it to “Manual” and range (-0.2, 0.2) through code.

---

<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: [June 26, 2021, 11:37pm UTC](https://discourse.slicer.org/t/combining-surface-registration-and-model-to-model-distance-functionalities/18347/6 "2021-06-26T23:37:01Z")

</div>

There are several color presets that display different colors for positive/negative values. You can also create custom ones as shown in [these examples](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#create-custom-color-table).

---

<div class="post-metadata">

### Author: ![seanchoi0519](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/seanchoi0519/32/10354_2.png) [@seanchoi0519](https://discourse.slicer.org/u/seanchoi0519)
#### Post date: [June 27, 2021, 5:02am UTC](https://discourse.slicer.org/t/combining-surface-registration-and-model-to-model-distance-functionalities/18347/7 "2021-06-27T05:02:21Z")

</div>

Thank you, I’ve created a custom one by editing the .txt. file.  
Would you know how I can programatically alter the “Scalar Range Mode” and the “Displayed Range” as shown in the screenshot above?

---

<div class="post-metadata">

### Author: ![seanchoi0519](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/seanchoi0519/32/10354_2.png) [@seanchoi0519](https://discourse.slicer.org/u/seanchoi0519)
#### Post date: [June 27, 2021, 10:53am UTC](https://discourse.slicer.org/t/combining-surface-registration-and-model-to-model-distance-functionalities/18347/8 "2021-06-27T10:53:07Z")

</div>

Issue resolved: this code worked.

```
display.SetScalarRangeFlag(0) // returns 'manual'
display.SetScalarRange(-0.1, 0.1) // 'changes the range manually'
```
