# ALPACA not working

**URL:** <https://discourse.slicer.org/t/alpaca-not-working/28488>\
**Category:** Support\
**Tags:** registration, slicermorph\
**Created:** [March 21, 2023, 3:53am UTC](https://discourse.slicer.org/t/alpaca-not-working/28488 "2023-03-21T03:53:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gening\_Dong](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gening_dong/32/14706_2.png) [@Gening\_Dong](https://discourse.slicer.org/u/Gening_Dong)\
**Post date:** [March 21, 2023, 3:53am UTC](https://discourse.slicer.org/t/alpaca-not-working/28488/1 "2023-03-21T03:53:49Z")

</div>

Hi all,

I’m using the ALPACA in SlicerMorph to register two cardiac models. However, when I clicked “Run ALPACA”, no results were shown. (see the screenshot below)

Here’s my steps:

1. load two .stl files as the target and the source model
2. use the “PseudoLMGenerator” to generate landmarks for the source model
3. run ALPACA

And here is the output:

 ![Screenshot 2023-03-20 235111](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/a/1abb4f69287fc030793b05abcfd2cb78f3ca3024.jpeg)

There’s an error jumped out:

> Traceback (most recent call last):  
> File “F:/Slicer 5.2.1/NA-MIC/Extensions-31317/SlicerMorph/lib/Slicer-5.2/qt-scripted-modules/ALPACA.py”, line 448, in onRunALPACAButton  
> self.transformMatrix = logic.estimateTransform(self.sourcePoints, self.targetPoints, self.sourceFeatures, self.targetFeatures, self.voxelSize, self.ui.skipScalingCheckBox.checked, self.parameterDictionary)  
> File “F:/Slicer 5.2.1/NA-MIC/Extensions-31317/SlicerMorph/lib/Slicer-5.2/qt-scripted-modules/ALPACA.py”, line 1325, in estimateTransform  
> ransac = self.execute\_global\_registration(sourcePoints, targetPoints, sourceFeatures, targetFeatures, voxelSize,  
> File “F:/Slicer 5.2.1/NA-MIC/Extensions-31317/SlicerMorph/lib/Slicer-5.2/qt-scripted-modules/ALPACA.py”, line 1445, in execute\_global\_registration  
> evaluation = registration.evaluate\_registration(target\_down, source\_down, distance\_threshold, np.linalg.inv(result.transformation))  
> File “\< **array\_function** internals\>”, line 180, in inv  
> File “F:\Slicer 5.2.1\lib\Python\Lib\site-packages\numpy\linalg\linalg.py”, line 552, in inv  
> ainv = \_umath\_linalg.inv(a, signature=signature, extobj=extobj)  
> File “F:\Slicer 5.2.1\lib\Python\Lib\site-packages\numpy\linalg\linalg.py”, line 89, in \_raise\_linalgerror\_singular  
> raise LinAlgError(“Singular matrix”)  
> numpy.linalg.LinAlgError: Singular matrix

Does anyone have any ideas why the ALPACA is not working? Thanks in advance!

Best,  
Gening

---

<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:** [March 21, 2023, 4:26am UTC](https://discourse.slicer.org/t/alpaca-not-working/28488/2 "2023-03-21T04:26:45Z")

</div>

> [@Gening\_Dong](#):
>
> Does anyone have any ideas why the ALPACA is not working?

The error indicates RANSAC step failed to do Singular Matrix. If you can share your models it will be easier for us to troubleshoot or tell you why it failed.

---

<div class="post-metadata">

**Author:** ![Gening\_Dong](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gening_dong/32/14706_2.png) [@Gening\_Dong](https://discourse.slicer.org/u/Gening_Dong)\
**Post date:** [March 21, 2023, 4:40am UTC](https://discourse.slicer.org/t/alpaca-not-working/28488/3 "2023-03-21T04:40:17Z")

</div>

Thanks for the reply! Please see below for the target and source models.

[https://drive.google.com/drive/folders/1v9oAierGHOx5GLYkLU0L3OvafjoTSpYv?usp=share\_link](https://drive.google.com/drive/folders/1v9oAierGHOx5GLYkLU0L3OvafjoTSpYv?usp=share_link)

 ![9E1A02C3411640208933B75A6458BB97.png](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/e/7e4f006e600be0e52228c99518845515fe779e3e.png)

---

<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:** [March 21, 2023, 5:13am UTC](https://discourse.slicer.org/t/alpaca-not-working/28488/4 "2023-03-21T05:13:01Z")

</div>

> [@Gening\_Dong](#):
>
> Thanks for the reply! Please see below for the target and source models.

if you skip the scaling and the projection (check mark them), ALPACA will run. However, result is not going to be usable. Models are quite different from each other and has unmatched parts (like a bifurcating structure that doesn’t exist in the other one).

ALPACA wasn’t never intended to work with such geometries.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/e/2ed8e14ee0dd1f575d01c68d2edaf61b17c6ee71.jpeg)

---

<div class="post-metadata">

**Author:** ![Gening\_Dong](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gening_dong/32/14706_2.png) [@Gening\_Dong](https://discourse.slicer.org/u/Gening_Dong)\
**Post date:** [March 21, 2023, 5:36am UTC](https://discourse.slicer.org/t/alpaca-not-working/28488/5 "2023-03-21T05:36:03Z")

</div>

Thanks for the clarification! I was hoping it can register between models with different geometries by increasing the landmark density. But now I guess it won’t work. Could you please suggest any other approaches/algorithms might be able to register such geometries? Thanks much!
