SPHARM-PDM from triangular meshes

I would like to apply the SPHARM-PDM to triangular meshes for palaeontological morphometrics. I first saw this method applied in SPHARM-MAT of Styner (2006)
I’m not sure if this is a related project, but seems to do very similar things.

I think that my mesh format is an issue for the first step (Post Process Segmentation) as it isn’t voxel data.
Is the surface mesh in step 2 triangular? If so I could maybe use command line control to skip the first step and the rest might work?

SPHARM-PDM can take vtp files as an input, and I think I found a way to convert my stl data to this format. Would this produce the right type of data for this process?

Thank you for your help

SPHARM-MAT (by Li Shen) and our SPHARM-PDM is very similar and is based on the same underlying principles. The implementations are different and data does not easily mix in the middle of processing, though final processed data have some commonalities.

If you want to use SlicerSALT (and its SPHARM-PDM/Shape Analysis Module) in your setting, you can definitely do so. The pipeline cannot directly use your triangulation as it needs to be converted to a specific style of triangulation (which has an expected connectivity that is needed in the parametrization/optimization process). A SlicerSALT based analysis would thus first convert your triangulation back to high res voxel-data (the resolution can be adjusted if necessary) and then the desired style of triangulation is generated from that voxel data.

So, you can use SlicerSALT and its ShapeAnalysisModule (that uses SPHARM-PDM), but you cannot use your surfaces mid-processing, but rather have to start with your surfaces as input to the module (I think STL should be fine as it can be read by SlicerSALT).


@Fiona_Pye keep in mind that the methods that generate correspondence between structures automatically (whether SPHARM based or not) are typically developed and applied in context of high N of a single species. If you are working with highly morphologically disparate groups, you may initially want to take a critical view of the results.

Having said that, if establishing biological homology is not a strong constraint in your analysis, they may work well.

That’s correct. I would add that even with an analysis of very similarly shaped structures (such as is the case in neuroimaging studies), one should perform a quality assessment of the established correspondence too.

If you run into correspondence issues, SlicerSALT allows you to define fiducials on the surfaces to help with that.


Hi @styner and @muratmaga

Thank you for your fast and helpful responses, I really appreciate it.
So sorry for getting my references mixed up!

I can open STL files in SlicerSalt, however I have not found a way to convert to VTP within it. I managed to convert the STL to VTP in ParaView so hopefully this will be okay (it did start to run in the ShapeAnalysisModule)

My scans are very high resolution, each having between 2.5 million and 12 million polygons. It says in the instruction manual that the sphere and resulting meshes have 1002 points. Will the module simplify my models down to this level, or should I adjust the resolution first?

Unfortunately I don’t have a huge number of specimens but I am not searching for biological homology. I would like to compare the different shapes of the fossils and see if these distinctions can be used to identify them.

Thanks again for all of your help
Best wishes

You can modify the reconstruction level (default is icosahedron subdivision level 10, which translates to 1002 vertices). Though increasing the subdivision level to reconstruct millions of vertices is probably not advisable (regarding computation time and memory requirement).

Re homology: you need to establish correspondence to compare the shape of your fossils. The simplest way to establish this is via closest point correspondence. That is sufficient if simply want to compare differences on a pair-wise basis, but not for populations of data. Then you need something more sophisticated (such as provided by SPHARM-PDM). Do you have 1 specimen per fossil and look for differences between individual fossils, or rather small groups of fossils and look for differences between the groups?

Also: what type of fossils are you looking at? Are the surfaces simply connected or do they have holes/handles?


Hi Martin,

My access to powerful computers is very limited, so I need to keep it as low demand as possible. Hopefully level 10 will be sufficient!

I am studying conodonts, they are basically the teeth of the first vertebrate and have a cone shape (

). They are very simple in shape, so classical landmark analysis style morphometrics isn’t great for them. They don’t have any holes or anything, so yes they are simply connected.

I have one fossil of each tooth type (7 total) from one species and am hoping to find differences between these. The total comparison, along with the spherical harmonics is why I am really interested in SPHARM-PDM. If this works, it could be extended to include other species (where then homology will play a part) or looking at differences between small groups of fossils.

Thanks again

These are fairly simple shapes. Perhaps you can reduce your meshes to quite a bit and give slicer-salt a try. Surface toolbox in Slicer has tools (decimation, smoothing etc) that might be useful for you.

Hi Murat and Martin,

The surface toolbox is amazing for reducing my meshes, thank you very much!
However, the post process segmentation of SPHARM-PDM just won’t accept my meshes. I read in the forum somewhere that the mesh to label map only works with dense meshes, so this might be the issue with my STL files.

As an alternative I am importing the TIFF files and segmenting, to produce a label map volume as an nrrd file (with the ends definitely sealed off so I have a truly solid surface) and the Shape Analysis Module now runs until the end of step two, where it produces the para.vtk and surf.vtk and then it stops with errors. It seems to be this bug which has been previously noted https://github.com/Kitware/SlicerSALT/issues/138
I will try to get a computer with Linux to get around this.

Thanks again for all of your help,

Hi Fiona,
comments/ questions:

  1. which version of Slicer Salt are you running, which platform?

  2. are you running the SPHARM shape analysis module, or rather the individual steps (e.g the SegPostProcess module) separately?

  3. if you are having problems with surface to label conversion, you can run that separately and (use Mesh to Label Map module).

  4. what is the error that you are getting when running it on the labelmaps that you generated from the TIFF files? Did you load the surf.vtk file into Slicer and see whether the surface looks okay?

  5. with respect to your shape, best play around with the settings for the surface reconstruction (subdivision and SPHARM degree) to make sure you get a reasonable reconstruction.


Hi Martin,

  1. I am running SlicerSalt for Windows (on Windows 10) from the executable file. I also have the most recent version of full slicer with SPHARM-PDM installed.

  2. I have been running the ShapeAnalysis module as a whole to see how far it gets. I will try doing it piece by piece.

  3. I will have a look at the Mesh to Label map alone, but I wouldn’t be surprised if the STL files just aren’t suitable.

  4. There is no issue with the label maps from the Tiffs, the label map conversion goes nicely and l the surf.vtk looks good. The error came in at step 3 and was an “unknown exception” as described in the other topic.

  5. Yeah I can see that this takes a bit of trial and error, once I get it fully running I will try this out.

Thanks again

@Fiona_Pye, out of curiosity where does your meshes come from? If these are from microCT scans, you can skip the mesh generation step, and use the labelmaps.

Hi Fiona,

I am late to the game, but I see you got fantastic advice from @styner and @muratmaga.
I believe we built in the option in SPHARM to get vtk’s as an input. In order to generate a vtk out of a vtp you can use Paraviews “extract surface” filter.

This SPHARM option just uses a Slicer module that scan converts a surface into a label map, you could try to run it on one of your cases and see how it goes. https://www.slicer.org/wiki/Documentation/Nightly/Extensions/MeshToLabelMap

All the best,

Hi Bea and @muratmaga,

The STL meshes that I have were generated for a previous study on these fossils. The original scans were acquired at the SLS Synchrotron. The group who did the original study provided me with the TIF files and STL meshes they produced. I don’t think I have labelmaps to start with unfortunately, because that would make life a lot easier!

Can you convert STL into vtk this way? All these file types are new to me, and I don’t know why I went for vtp rather than vtk to start. I will have a look anyway. Also, though my meshes should be a solid surface, they are a bit messy so I think this is also an issue. I haven’t yet worked out a good way to fix this in my meshes (I tried the fill holes thing in MeshLab that someone mentioned), and decided to try generating them as clean as possible as voxel volume data rather than surface meshes. This got me the furthest along the process of anything yet!

Yeah I am not sure what is the issue with this, I will have a look into it.

Thank you for your help

Hi Fiona,

Have you tried using MeshToLabelMap?
Converting from STL to VTK is straightforward, but MeshToLabelMap should work with both.


Hi Bea,

So when I input my STL into Mesh to Label Map, it tells me that I have to provide valid spacing information (>0), however for the spacing the auto is -1,-1,-1. Is this error referring to this, or do I need a reference image to run this? If so, I don’t actually understand what kind of reference image is required.

Secondly, a colleague has a Linux computer, and SpharmPDM ran all the way through on newly segmented test samples, so this is good!

Thank you for your help and patience!

Hi Fiona,

Yes, I believe you will need a reference image. Do you have any of the original segmentations that you used? If it is the same machine it will keep all the metadata you need to run the module.


Hi Bea,

Do you mean the segmentations which were used to make the STL files? If so, unfortunately not, these were generated about 10 years ago by my supervisor.

A second question, my samples are all different sizes so do I need to standardise for this before I run SPHARM-PDM or does the method ignore/account for size differences and just consider shape?


Hi Fiona,

Then you will have to create a reference image. You can do that with ITK https://itk.org/ITKExamples/src/Core/Common/CreateAnImage/Documentation.html

What do you mean, different sizes? Can you provide an example?
In general SPHARM-PDM will have the same triangulation scaled as far as there is inherent correspondence.


Hi Bea,

Thank you, I will try this out.

So essentially some of specimens are twice the size of others because they all come from different individuals. Would I need to resize them so they are all the correct relative sizes to each other before SPHARM-PDM?

Thanks a lot