MALPACA template selection

Hello!
I would like to use the MALPACA template selection tool, but I am running into an error. I went through the MALPACA tutorial with the sample data (mouse skulls) and it worked fine. Now I am trying the same thing with my data, all of which are cervical vertebrae from the same species, but I am having trouble at Step 2: Generate point clouds matched to reference.

Here are the steps I used:
• Placed my model data (.ply) in my Downloads folder (same one I used in the tutorial). The sample data used 61 models, I’m using 16 vertebrae from a pelican. These meshes were all cleaned/repaired in Meshmixer.
• Started new 3D Slicer scene and opened ALPACA module.
• Template selection: selected model directory and output directory. Did not enable reference selection box.
• Used spacing factor of 0.03
• Selected “Step 1”. This is the output:
The reference is Pelican_C10_cleaned
The number of points in the downsampled reference pointcloud is 653
• Selected Step 2. There is no new output text.
• The output folder has 5 matching point clouds: C10, C11, C12, C13, C14.
• The next step is not enabled.

I tried this with a spacing factor of 0.02 as well, and I tried it with a different template (C5), and it still did not let me continue on to the next steps. Is there something I am overlooking?

Thanks!
-Rachel

Here is my error log:

ReadDataInternal ((unknown)): File ReadDataInternal ((unknown)): File C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C10_cleaned.ply does not contain coordinate system information. Assuming LPS.
“Model” Reader has successfully read the file “C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C10_cleaned.ply” “[0.10s]”
:: Loading point clouds and downsampling…
:: Point-to-plane ICP registration is applied on original point…
ReadDataInternal ((unknown)): File C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C11_cleaned.ply does not contain coordinate system information. Assuming LPS.

@Rachel_Fleming This seems part of the log. There is really no error in here. (You can ignore the ply does not contain coordinate information message).

Can you share your datasets or provide the whole log?

Sure! Here is the full log (I had to copy and paste since I couldn’t upload a .txt file):

[DEBUG][Qt] 30.01.2023 10:48:19 (unknown:0) - Session start time …: 2023-01-30 10:48:19
[DEBUG][Qt] 30.01.2023 10:48:19 (unknown:0) - Slicer version …: 5.2.1 (revision 31317 / 77da381) win-amd64 - installed release
[DEBUG][Qt] 30.01.2023 10:48:19 (unknown:0) - Operating system …: Windows / Personal / (Build 22621, Code Page 65001) - 64-bit
[DEBUG][Qt] 30.01.2023 10:48:19 (unknown:0) - Memory …: 16068 MB physical, 52932 MB virtual
[DEBUG][Qt] 30.01.2023 10:48:19 (unknown:0) - CPU …: GenuineIntel , 20 cores, 20 logical processors
[DEBUG][Qt] 30.01.2023 10:48:19 (unknown:0) - VTK configuration …: OpenGL2 rendering, TBB threading
[DEBUG][Qt] 30.01.2023 10:48:19 (unknown:0) - Qt configuration …: version 5.15.2, with SSL, requested OpenGL 3.2 (compatibility profile)
[DEBUG][Qt] 30.01.2023 10:48:19 (unknown:0) - Internationalization …: disabled, language=
[DEBUG][Qt] 30.01.2023 10:48:19 (unknown:0) - Developer mode …: disabled
[DEBUG][Qt] 30.01.2023 10:48:19 (unknown:0) - Application path …: C:/Users/rache/AppData/Local/NA-MIC/Slicer 5.2.1/bin
[DEBUG][Qt] 30.01.2023 10:48:19 (unknown:0) - Additional module paths …: NA-MIC/Extensions-31317/SegmentEditorExtraEffects/lib/Slicer-5.2/qt-loadable-modules, NA-MIC/Extensions-31317/SegmentEditorExtraEffects/lib/Slicer-5.2/qt-scripted-modules, NA-MIC/Extensions-31317/SlicerMorph/lib/Slicer-5.2/qt-scripted-modules, NA-MIC/Extensions-31317/MarkupsToModel/lib/Slicer-5.2/qt-loadable-modules
[WARNING][Qt] 30.01.2023 10:48:22 (unknown:0) - libpng warning: iCCP: profile ‘ICC Profile’: ‘CMYK’: invalid ICC profile color space
[WARNING][Qt] 30.01.2023 10:48:23 (unknown:0) - libpng warning: iCCP: known incorrect sRGB profile
[DEBUG][Python] 30.01.2023 10:48:24 [Python] (C:\Users\rache\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Slicer-5.2\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:38) - Scripted subject hierarchy plugin registered: Annotations
[DEBUG][Python] 30.01.2023 10:48:25 [Python] (C:\Users\rache\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Slicer-5.2\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:38) - Scripted subject hierarchy plugin registered: SegmentEditor
[DEBUG][Python] 30.01.2023 10:48:25 [Python] (C:\Users\rache\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Slicer-5.2\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:38) - Scripted subject hierarchy plugin registered: SegmentStatistics
[DEBUG][Qt] 30.01.2023 10:48:25 (unknown:0) - Switch to module: “Welcome”
[DEBUG][Python] 30.01.2023 10:48:26 [Python] (C:\Users\rache\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Slicer-5.2\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:38) - Scripted subject hierarchy plugin registered: FormatMarkups
[DEBUG][Qt] 30.01.2023 10:51:02 (unknown:0) - Switch to module: “ALPACA”
[INFO][VTK] 30.01.2023 10:51:32 [vtkMRMLModelStorageNode (000001AC6DC6CB20)] (D:\D\S\S-0\Libs\MRML\Core\vtkMRMLModelStorageNode.cxx:414) - ReadDataInternal ((unknown)): File C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C10_cleaned.ply does not contain coordinate system information. Assuming LPS.
[DEBUG][Qt] 30.01.2023 10:51:32 (unknown:0) - “Model” Reader has successfully read the file “C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C10_cleaned.ply” “[0.15s]”
[INFO][VTK] 30.01.2023 10:51:41 [vtkMRMLModelStorageNode (000001AC6DC6C170)] (D:\D\S\S-0\Libs\MRML\Core\vtkMRMLModelStorageNode.cxx:414) - ReadDataInternal ((unknown)): File C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C10_cleaned.ply does not contain coordinate system information. Assuming LPS.
[DEBUG][Qt] 30.01.2023 10:51:41 (unknown:0) - “Model” Reader has successfully read the file “C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C10_cleaned.ply” “[0.14s]”
[INFO][Stream] 30.01.2023 10:51:41 (unknown:0) - :: Loading point clouds and downsampling
[INFO][Stream] 30.01.2023 10:51:41 (unknown:0) - :: Downsample with a voxel size 1.240.
[INFO][Stream] 30.01.2023 10:51:41 (unknown:0) - :: Estimate normal with search radius 2.481.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Compute FPFH feature with search radius 6.202.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Downsample with a voxel size 1.240.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Estimate normal with search radius 2.481.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Compute FPFH feature with search radius 6.202.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: RANSAC registration on downsampled point clouds.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - Since the downsampling voxel size is 1.240,
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - we use a liberal distance threshold 3.721.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Point-to-plane ICP registration is applied on original point
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - clouds to refine the alignment. This time we use a strict
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - distance threshold 1.861.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - 653
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - 34880
[INFO][VTK] 30.01.2023 10:51:42 [vtkMRMLModelStorageNode (000001AC6DC74530)] (D:\D\S\S-0\Libs\MRML\Core\vtkMRMLModelStorageNode.cxx:414) - ReadDataInternal ((unknown)): File C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C11_cleaned.ply does not contain coordinate system information. Assuming LPS.
[DEBUG][Qt] 30.01.2023 10:51:42 (unknown:0) - “Model” Reader has successfully read the file “C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C11_cleaned.ply” “[0.14s]”
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Loading point clouds and downsampling
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Downsample with a voxel size 1.240.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Estimate normal with search radius 2.481.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Compute FPFH feature with search radius 6.202.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Downsample with a voxel size 1.240.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Estimate normal with search radius 2.481.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: Compute FPFH feature with search radius 6.202.
[INFO][Stream] 30.01.2023 10:51:42 (unknown:0) - :: RANSAC registration on downsampled point clouds.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - Since the downsampling voxel size is 1.240,
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - we use a liberal distance threshold 3.721.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - :: Point-to-plane ICP registration is applied on original point
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - clouds to refine the alignment. This time we use a strict
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - distance threshold 1.861.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - 653
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - 33598
[INFO][VTK] 30.01.2023 10:51:43 [vtkMRMLModelStorageNode (000001AC6DC6E260)] (D:\D\S\S-0\Libs\MRML\Core\vtkMRMLModelStorageNode.cxx:414) - ReadDataInternal ((unknown)): File C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C12_cleaned.ply does not contain coordinate system information. Assuming LPS.
[DEBUG][Qt] 30.01.2023 10:51:43 (unknown:0) - “Model” Reader has successfully read the file “C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C12_cleaned.ply” “[0.14s]”
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - :: Loading point clouds and downsampling
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - :: Downsample with a voxel size 1.240.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - :: Estimate normal with search radius 2.481.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - :: Compute FPFH feature with search radius 6.202.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - :: Downsample with a voxel size 1.240.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - :: Estimate normal with search radius 2.481.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - :: Compute FPFH feature with search radius 6.202.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - :: RANSAC registration on downsampled point clouds.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - Since the downsampling voxel size is 1.240,
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - we use a liberal distance threshold 3.721.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - :: Point-to-plane ICP registration is applied on original point
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - clouds to refine the alignment. This time we use a strict
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - distance threshold 1.861.
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - 653
[INFO][Stream] 30.01.2023 10:51:43 (unknown:0) - 44791
[INFO][VTK] 30.01.2023 10:51:44 [vtkMRMLModelStorageNode (000001AC6DC76430)] (D:\D\S\S-0\Libs\MRML\Core\vtkMRMLModelStorageNode.cxx:414) - ReadDataInternal ((unknown)): File C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C13_cleaned.ply does not contain coordinate system information. Assuming LPS.
[DEBUG][Qt] 30.01.2023 10:51:44 (unknown:0) - “Model” Reader has successfully read the file “C:/Users/rache/Downloads/MALPACA_test_vertebrae/CV_test_Models\Pelican_C13_cleaned.ply” “[0.17s]”
[INFO][Stream] 30.01.2023 10:51:44 (unknown:0) - :: Loading point clouds and downsampling
[INFO][Stream] 30.01.2023 10:51:44 (unknown:0) - :: Downsample with a voxel size 1.240.
[INFO][Stream] 30.01.2023 10:51:44 (unknown:0) - :: Estimate normal with search radius 2.481.
[INFO][Stream] 30.01.2023 10:51:44 (unknown:0) - :: Compute FPFH feature with search radius 6.202.
[INFO][Stream] 30.01.2023 10:51:44 (unknown:0) - :: Downsample with a voxel size 1.240.
[INFO][Stream] 30.01.2023 10:51:44 (unknown:0) - :: Estimate normal with search radius 2.481.
[INFO][Stream] 30.01.2023 10:51:44 (unknown:0) - :: Compute FPFH feature with search radius 6.202.
[INFO][Stream] 30.01.2023 10:51:44 (unknown:0) - :: RANSAC registration on downsampled point clouds.
[INFO][Stream] 30.01.2023 10:51:44 (unknown:0) - Since the downsampling voxel size is 1.240,
[INFO][Stream] 30.01.2023 10:51:44 (unknown:0) - we use a liberal distance threshold 3.721.
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - Traceback (most recent call last):
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - File “C:/Users/rache/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/SlicerMorph/lib/Slicer-5.2/qt-scripted-modules/ALPACA.py”, line 756, in onMatchingPointsButton
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - template_density, matchedPoints, indices, files = logic.matchingPCD(self.ui.modelsMultiSelector.currentPath, self.sparseTemplate, self.referenceNode, self.pcdOutputFolder, self.ui.spacingFactorSlider.value,
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - File “C:/Users/rache/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/SlicerMorph/lib/Slicer-5.2/qt-scripted-modules/ALPACA.py”, line 1652, in matchingPCD
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - ICPTransform = self.estimateTransform(sourcePoints, targetPoints, sourceFeatures, targetFeatures, voxelSize, skipScalingOption, parameterDictionary)
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - File “C:/Users/rache/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/SlicerMorph/lib/Slicer-5.2/qt-scripted-modules/ALPACA.py”, line 1325, in estimateTransform
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - ransac = self.execute_global_registration(sourcePoints, targetPoints, sourceFeatures, targetFeatures, voxelSize,
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - File “C:/Users/rache/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/SlicerMorph/lib/Slicer-5.2/qt-scripted-modules/ALPACA.py”, line 1445, in execute_global_registration
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - evaluation = registration.evaluate_registration(target_down, source_down, distance_threshold, np.linalg.inv(result.transformation))
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - File “<array_function internals>”, line 180, in inv
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - File “C:\Users\rache\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Lib\site-packages\numpy\linalg\linalg.py”, line 552, in inv
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - File “C:\Users\rache\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Lib\site-packages\numpy\linalg\linalg.py”, line 89, in _raise_linalgerror_singular
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - raise LinAlgError(“Singular matrix”)
[CRITICAL][Stream] 30.01.2023 10:51:48 (unknown:0) - numpy.linalg.LinAlgError: Singular matrix

I can also share my dataset, let me know if you still need it and I can email them to you.

Yes, sharing the data would be great.

Pelican_C2_cleaned.ply
Pelican_C3_cleaned.ply
Pelican_C4_cleaned.ply
Pelican_C5_cleaned.ply
Pelican_C6_cleaned.ply
Pelican_C7_cleaned.ply
Pelican_C8_cleaned.ply
Pelican_C9_cleaned.ply
Pelican_C10_cleaned.ply
Pelican_C11_cleaned.ply
Pelican_C12_cleaned.ply
Pelican_C13_cleaned.ply
Pelican_C14_cleaned.ply
Pelican_C15_cleaned.ply
Pelican_C16_cleaned.ply
Pelican_C17_cleaned.ply

Alternatively, here’s a zipped folder:
CV_test_Models.zip

Says I need permission, can you share publicly?

I made the link general access, did that work?

1 Like

So, I donwloaded the data and replicate the error. We will take a look.
Meanwhile, can you tell me a bit about the project? All I have a is a vertebral column. Do you have more samples (lots more)?

ALPACA/MALPACA will probably not going to work well if your goal is to use one or two of the vertebra to landmark the rest, given how drastically their shape changes from proximal to distal. However, if you do have a lots of specimen with the same structures, you might be able to pool the data and select a proximal vertebra to landmakr similar looking ones, a middle one in the series for similar range, and finally distal one to do the remaining ones (basically three templates).

Is it sort of the analysis you are looking into doing it?

Hi Murat,
Ok! Yes I have cervical vertebrae models from a dozen species in the Pelicanimorphoae clade. I’m interested in knowing whether there is GPA clustering associated with feeding strategy (strikers, plunge divers, tactile probers, etc). In total I have around 200 models. I could choose a representative vertebra from each neck region. Though I do suspect there may be a lot of variability in shape between species.

Hi Rachel,

Thanks for trying our method and posting the issue! I also looked at your dataset. Like what Murat suggested, I think the issue is that some vertebrae from one specimen are a bit too different. The generating matching pointcloud function stopped in the middle (in my case, it stopped at C3), that’s why the next step is not enabled automatically. You can check the generated matching pointclouds in the specified output folder.

ALPACA can still generate a reasonable registration among them, but the difference is too much for matching downsampled pointclouds in the templates selection module. For example, here is a registered C2 (red) and C3 (blue) pointclouds in ALPACA. You can use ALPACA (“single alignment” tab) to test the registration when in doubt.

Anyway, we’ll add a catch for this error to remind users to check for the original models. Thanks!

To give a deeper insight, templates modules are there to help you choose what samples you can use as source to landmark the rest of the sample via ALPACA/MALPACA. For that, we do a pseudo-GPA in which we use the geometry of the samples to create a fixed number of points across samples. If the shapes of the reference specimen (selected randomly, or you can specify explicitly) and targets are too different, then that finding the corresponding points step fail. And we can’t do out pseudoGPA and kmeans clustering.

If you can split your samples by the region of the vertebrate (proximal cervical, middle cervicals, and distal cervicals), and pool the models that way, and rerun the templates separately for each region, you might be able to run the templates module.

Are you planning to use manual LMs or semiLM to digitize the shape of the vertebra?

Thanks for your quick responses! I am planning on using semiLMs.
Later today or tomorrow I will try template selection separately on those different regions, then use PseudoLMGenerator on the selected templates, then run MALPACA. If that sounds good, I’ll get back to you soon to let you know how it went.

One more clarification. You can’t use PseudoLM generator in context of multiple template landmarking. PseudoLM generator uses the geometry of the selected to create the LMs. So if you switch to another template, a different number of point will be generated hence multi-template pipeline won’t work.

You can still do all of these in ALPACA though. (Run templates tool to select the template separately for each anatomical region, just choose template as 1. Generate the point cloud for that template in PseudoLMs module and then run ALPACA on the rest of the samples.) .

Ah that makes sense, I’ll do the separate ALPACA runs on the different regions. Thanks!! I’ll follow up after trying that out.