# How to align two models (stl) and then do landmarks on it? 

**URL:** <https://discourse.slicer.org/t/how-to-align-two-models-stl-and-then-do-landmarks-on-it/39589>\
**Category:** Support\
**Created:** [October 8, 2024, 8:27pm UTC](https://discourse.slicer.org/t/how-to-align-two-models-stl-and-then-do-landmarks-on-it/39589 "2024-10-08T20:27:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Puja\_Ghosh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/puja_ghosh/32/77922_2.png) [@Puja\_Ghosh](https://discourse.slicer.org/u/Puja_Ghosh)\
**Post date:** [October 8, 2024, 8:27pm UTC](https://discourse.slicer.org/t/how-to-align-two-models-stl-and-then-do-landmarks-on-it/39589/1 "2024-10-08T20:27:27Z")

</div>

I have two models(stl) of torso (pregnant) and I am trying to align them one after another (superimpose) and then I want to do landmarks on the specific points where there are electrodes placed (checking position of electrodes from both the files) ?

---

<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:** [October 8, 2024, 8:49pm UTC](https://discourse.slicer.org/t/how-to-align-two-models-stl-and-then-do-landmarks-on-it/39589/2 "2024-10-08T20:49:53Z")

</div>

You don’t really need to align the models if you just want to landmark them.

But if you do, you can use the `FastModelAlign` to rigidly register one model to the other, and then you can do the landmarks on the rigidly registered model.

> **[Tutorials/FastModelAlign at main · SlicerMorph/Tutorials](https://github.com/SlicerMorph/Tutorials/tree/main/FastModelAlign)**
>
> SlicerMorph module tutorials. Contribute to SlicerMorph/Tutorials development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Puja\_Ghosh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/puja_ghosh/32/77922_2.png) [@Puja\_Ghosh](https://discourse.slicer.org/u/Puja_Ghosh)\
**Post date:** [October 8, 2024, 9:03pm UTC](https://discourse.slicer.org/t/how-to-align-two-models-stl-and-then-do-landmarks-on-it/39589/3 "2024-10-08T21:03:33Z")

</div>

Thank you so much Professor Maga

---

<div class="post-metadata">

**Author:** ![Sofia\_Gonzalez](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sofia_gonzalez/32/78172_2.png) [@Sofia\_Gonzalez](https://discourse.slicer.org/u/Sofia_Gonzalez)\
**Post date:** [October 9, 2024, 8:29am UTC](https://discourse.slicer.org/t/how-to-align-two-models-stl-and-then-do-landmarks-on-it/39589/4 "2024-10-09T08:29:52Z")

</div>

Someone knows how to align two models but with a code in python?

---

<div class="post-metadata">

**Author:** ![pblascof](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pblascof/32/79139_2.png) [@pblascof](https://discourse.slicer.org/u/pblascof)\
**Post date:** [January 17, 2025, 9:57pm UTC](https://discourse.slicer.org/t/how-to-align-two-models-stl-and-then-do-landmarks-on-it/39589/5 "2025-01-17T21:57:46Z")

</div>

Hi @muratmaga, I am super interested in aligning a batch of stl files to a target. I cannot use batch ALPACA or MALPACA directly since I do not have any reference landmarks and the PseudoLMGenerator does not do the job nicely. Is there a way to implement the FastAlignModel module in a smooth way in Python so I do not have to align all of them one by one? I would like to skip this manual work since afterwards I intend to compute a loss to decide which is the optimal source mesh to do the alignment to. I will use that one for later generating an average shape model based on the registered ones, so I need to find the optimal registration based on the optimal source and those many comparisons would be feasible only if automating the process.

---

<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:** [January 17, 2025, 10:02pm UTC](https://discourse.slicer.org/t/how-to-align-two-models-stl-and-then-do-landmarks-on-it/39589/6 "2025-01-17T22:02:01Z")

</div>

We really don’t have bandwidth to implement the batch mode in FastModelAlign. The source code is available and perhaps you can do and contribute back using the ALPACA as an example.

> <https://github.com/SlicerMorph/SlicerMorph/blob/master/FastModelAlign/FastModelAlign.py>

> <https://github.com/SlicerMorph/SlicerMorph/blob/master/ALPACA/ALPACA.py>
