# TWO .stl file alignment and measurement

**URL:** https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259
**Category:** Support
**Tags:** registration, segmentation
**Created:** [September 2, 2019, 1:10pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259 "2019-09-02T13:10:55Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [April 21, 2021, 3:37pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/21 "2021-04-21T15:37:33Z")

</div>

> [@seanchoi0519](#):
>
> Would you also mind providing a screen recording of you using the Module-to-Module distance & shape population viewer?

There is the screen capture of the resultant alignment run through Model to Model distance:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/1/f16975645321b77496cfb6fb73c7ab6805e7a53d.png)

There is no tutorial, since there is not much to the module. You specify the reference model from which the distances will be calculated (fixed in this case) and then the target and choose to create a new model file as output. I slightly modified the visualization so anything within -1 to 1mm range is rendered green.

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [April 21, 2021, 3:39pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/22 "2021-04-21T15:39:28Z")

</div>

> [@seanchoi0519](#):
>
> I just had one more question - what is “Run CPD non-rigid registration” for specifically?  
> To me, “Run rigid alignment” seems to get most of the alignment done.

Depending on the question, you may skip the deformable registration. Rigid will only rotate and translate the mesh. Whereas deformable will non-linearly deform the mesh to match the others. Whether you need deformable or not depends on what you want to measure.

---

<div class="post-metadata">

### Author: ![manjula](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/manjula/32/80981_2.png) [@manjula](https://discourse.slicer.org/u/manjula)
#### Post date: [April 21, 2021, 3:44pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/23 "2021-04-21T15:44:05Z")

</div>

> [@seanchoi0519](#):
>
> Would you also mind providing a screen recording of you using the Module-to-Module distance & shape population viewer

I learned via this tutorial,

[![](https://img.youtube.com/vi/Qen8ou5QsAw/maxresdefault.jpg "5A 3D Craniofacial Quantification of Changes-Compute the Surface Distances using a Color Map") ](https://www.youtube.com/watch?v=Qen8ou5QsAw)

---

<div class="post-metadata">

### Author: ![manjula](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/manjula/32/80981_2.png) [@manjula](https://discourse.slicer.org/u/manjula)
#### Post date: [April 21, 2021, 3:46pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/24 "2021-04-21T15:46:27Z")

</div>

thank you for testing. Yes i managed to get the same with your settings. i was not using the settings properly as I was confused with the tooltips. Many thanks for the help.

---

<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: [April 21, 2021, 4:31pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/25 "2021-04-21T16:31:23Z")

</div>

Thank you. Some great points here.  
If you wouldn’t mind, I had a couple follow-up questions.

1. Is it possible for me to modify the -1 to 1mm threshold? For example I would like to be a little more precise, down to maybe within -0.3 to 0.3mm range.

2. Is it possible for me to see the difference of the “inside” of the model? I’ve tried reducing the opacity however it doesn’t seem to do much. For example, I have 2 tooth models - one of them has a hollow cavity preparation (it has been drilled), while the other has not. The model to model distance allows me to see the outside surface, however, I would like to see the distance INSIDE of the tooth as well if possible. Please see attached for reference.

---

<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: [April 21, 2021, 4:33pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/26 "2021-04-21T16:33:29Z")

</div>

Thanks manjula. Everything is fine with model-to-model distance, but somehow when I load the vtk file for shape population viewer, I get a weird result and am thinking I must be doing something wrong. Would you be able to have a look

 ![Screen Shot 2021-04-22 at 2.27.13 AM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/6/d6cd5bab6ddd85770ccb82a9ed1945cee6cbba15.jpeg) ![Screen Shot 2021-04-22 at 2.25.57 AM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/e/eee82bdc64848c1e38a19c1bb1644f191f892a76.jpeg)

---

<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: [April 21, 2021, 4:37pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/27 "2021-04-21T16:37:03Z")

</div>

Ok I see. Thank you. I should be able to get away with just the rigid function!

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [April 21, 2021, 4:47pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/28 "2021-04-21T16:47:23Z")

</div>

> [@seanchoi0519](#):
>
> Is it possible for me to modify the -1 to 1mm threshold? For example I would like to be a little more precise, down to maybe within -0.3 to 0.3mm range.

I am not familiar with population shape viewer module. Instead I used the Models module’s Scalar Tab, after running the Model to Model Distance. There you can modify what values to be displayed by playing around with the Scalar Range Mode, and the Displayed Range settings.

---

<div class="post-metadata">

### Author: ![manjula](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/manjula/32/80981_2.png) [@manjula](https://discourse.slicer.org/u/manjula)
#### Post date: [April 22, 2021, 10:01am UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/29 "2021-04-22T10:01:21Z")

</div>

> [@seanchoi0519](#):
>
> hape population viewer, I get a weird result and am thinking I must

@seanchoi0519

 ![Screenshot_32](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/f/1f43ff49fdccecb524feb16412bceabe70a6c300.png)

@muratmaga Thank you for the help with ALPACA and as you can see I am now able to get good results.

---

<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: [April 23, 2021, 2:38pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/30 "2021-04-23T14:38:54Z")

</div>

Thanks a lot for all your help

---

<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: [April 23, 2021, 2:41pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/31 "2021-04-23T14:41:33Z")

</div>

Hello Arthur. This would be a great change as it would simplify the alignment process drastically.  
Would you guys have any plans to work on this?

I am trying to see if I can create a UI where I can simply drag and drop two .ply models (without the need for landmark transfer) and get the alignment done in a single step.

Any input would be appreciated.

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [April 23, 2021, 3:05pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/32 "2021-04-23T15:05:51Z")

</div>

Because ALPACA as a module is currently being reviewed in a paper, we are unlikely to make a change like that interim. Most likely that interactive alignment of meshes would be a separate module.

---

<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: [April 23, 2021, 3:12pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/33 "2021-04-23T15:12:56Z")

</div>

I see thank you. I’m so glad I ran into ALPACA, it really works like magic.  
In the meanwhile, as my research project is due this coming July, would you guys mind if I attempt to make progress myself?

Any direction & pointers as to how I can achieve it would be appreciated. I’m looking to

1. Replace the file selectors by node selectors (ex. drag & drop 3D models)
2. Remove the need for .fcsv file

I have some basic programming knowledge so I am not sure if I can achieve it, but as Andras has mentioned, it is likely a trivial change so I hope I will be able to make some progress.

Thank you in advance

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [April 23, 2021, 3:13pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/34 "2021-04-23T15:13:55Z")

</div>

Source code of alpaca is here: [SlicerMorph/ALPACA.py at master · SlicerMorph/SlicerMorph · GitHub](https://github.com/SlicerMorph/SlicerMorph/blob/master/ALPACA/ALPACA.py)

@smrolfe and @agporto can help with your questions.

---

<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: [April 23, 2021, 3:30pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/35 "2021-04-23T15:30:54Z")

</div>

Thank you. I had a read through the code and it seems like I may have to modify

io.read\_point\_cloud function to another function that will take the node as the input instead of file path. Please correct me if I’m wrong.

Would also love to implement a drag & drop function somehow!

@smrolfe @agporto can’t thank you enough - any advice would be appreciated

---

<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: [April 23, 2021, 4:22pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/36 "2021-04-23T16:22:27Z")

</div>

This is great @seanchoi0519, thanks for jumping in 👍

Here’s an example of how the drag-and-drop works in python. If you search through the code for the qt methods it uses you’ll see how this integrates with other ways drops are handled.

> <https://github.com/Slicer/Slicer/blob/0094e9a35bd266cc8b0e677858dabce797c9928f/Modules/Scripted/DICOM/DICOM.py#L504>

---

<div class="post-metadata">

### Author: ![agporto](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/agporto/32/8319_2.png) [@agporto](https://discourse.slicer.org/u/agporto)
#### Post date: [April 23, 2021, 6:12pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/37 "2021-04-23T18:12:04Z")

</div>

Hi Sean,  
A while ago, I started working on a module for pointcloud registration that I didn’t have time to finish. Perhaps that would be a good starting point (and I can help you a bit in updating it).  
It can be found at :

> <https://github.com/agporto/PointCloud-Registration/blob/main/PointCloudRegistration.py>

With regard to the io.read\_point\_cloud function, you can load a model from the scene with something like this:  
m = getNode(“Segment\_1”)  
p = arrayFromModelPoints(m)  
cloud = o3d.geometry.PointCloud()  
cloud.points = o3d.utility.Vector3dVector(p)  
Anyway, if you want to start working on this, I can either give you access to the repo or you can create a branch and I can make some commits to it.

---

<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: [April 29, 2021, 3:26pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/38 "2021-04-29T15:26:07Z")

</div>

Hello,

Thank you all for the feedbacks. I’ve spent some time to digest the code from the scripts this past week - however, I will admit that as a dental student with only basic coding background, it has not been easy creating modifications.

By any chance, would any of you be interested in developing & creating extensions to the ALPACA with some funding? I do have some grants available that I can apply for from my university - and if it means accelerating the timeline of this project & improving the quality of the final product, I am happy to look into this. The funding amount varies from $500-$1000 USD.

Here are some of the functionalities that I’m looking for:

1. Enable drag-and-drop feature (something similar to attached pic)
2. Upon drag-and-drop and alignment, highlight areas for correction - (for ex. red = needs to be trimmed down, blue = must be added). I think this is possible via shape population viewer already - would be nice to integrate this with ALPACA.
3. General UI simplification (ex. remove unnecessary toolbar items). I was thinking slicelet could be appropriate for this?
4. Bonus: provide a score (%) based on total difference. The less, the better.

Any feedbacks & interest would be appreciated.  
If this project is successful, it is sure to make a difference in the dental field.

Sean

@smrolfe @agporto @muratmaga @pieper

 ![Screen Shot 2021-04-30 at 1.13.22 AM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/c/bcec81e00efa7919419a7975b075a0af39c94cd7.jpeg)

---

<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: [April 30, 2021, 3:53am UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/39 "2021-04-30T03:53:18Z")

</div>

> [@seanchoi0519](#):
>
> If this project is successful, it is sure to make a difference in the dental field.

Can you tell a bit more about this application? How the colored overlay display helps the dentist?  
Do you see potential further improvements, additional features that could be useful?

The amount of funding that you mentioned to develop this might be sufficient for a software developer/engineering student looking for a summer project. If you cannot find a suitable student then you could contact one of the [Slicer commercial partners](https://slicer.readthedocs.io/en/latest/user_guide/about.html#commercial-partners) but probably they would ask for about one magnitude more funding to get started on a new project. There seem to be many dental applications of Slicer, so it could also make sense to coordinate with others in the community who are in this field and see if you can find some good common topics to work on and join forces to find funding and developers together.

---

<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 20, 2021, 1:45pm UTC](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259/42 "2021-06-20T13:45:03Z")

</div>

Upon research it looks like it may be beneficial to create a custom slicelet with the drag-and-drop function + ALPACA function. Could someone please confirm?

[Previous page](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259.md?page=1)

[Next page](https://discourse.slicer.org/t/two-stl-file-alignment-and-measurement/8259.md?page=3)
