Surface toolbox - Extract largest component

Operating system: Windows 11
Slicer version: 5.2.1 r31317
Expected behavior: Extract largest component of skull
Actual behavior: The model is performing as expected but I would actually like to extract the SECOND and THIRD largest components. Is there a way to do this, or to extract multiple large components, say the top 10 or 50 or whatever number is desired?
The input data is a .ply file of an adult mouse skull. I was hoping to use the Surface Toolbox to extract what are essentially three large components - the neurocranium and the left and right hemi-mandibles. I want to work specifically with the (separated) left and right hemi-mandibles, which are the second and third largest components. I thought this tool would be fastest for a series with a large number of specimens. If I should use a different tool, or if there is a way to adjust the settings for the Surface toolbox, please let me know. Thank you!

@S_Motch_Perrine
What you ask is normally done during the segmentation process. If you still have the segmentation of these models, you can run the island effect and instead of the default “keep largest component” choose “split islands to segments”. If they are not touching each other, then you should get three separate segments, and export models from there. Also this thread might be useful to deal with touching voxels. How can I approximate the magic wand tool in Avizo/Amira? - #4 by muratmaga

If you do not have the segmentation, but only the models you have couple options.

  1. I don’t think surface toolbox has the split islands mode exposed in the UI, but it might possibly be available as a python script (someone more knowledgable needs to comment @pieper ?)

  2. You can import/convert the models as segmentation then use the segment editor effects (such as island and scissors) to separate them and re-export as model. This might cause some loss of detail, as ideally this operation should be done as I described above. To give a try, right click on your models object in the data viewer, and choose “export to model to segmentation node”.

  3. You might give “Dynamic Modeler” module a try, and experiment with separating the models with drawing closed curves around them.

Thank you, @muratmaga ! I do not have the segmentation, only the models, so I will try your suggestions and thanks for tagging Pieper.

The Surface Toolbox code uses a very flexible VTK filter but only the basic functionality is exposed in the GUI. If you are solving a one-off problem writing a short custom python script is probably best. If anyone feels motivated, it would be possible to expose more features of the filter in the Surface Toolbox GUI by adding more parameter widgets.

https://vtk.org/doc/nightly/html/classvtkPolyDataConnectivityFilter.html#details

1 Like

If the parts are not connected in your ply model, there is a filter in Meshlab called “Split in Connected Components” that you can apply by right-clicking on your model name. The first new layer (“CC0”) is the largest and the rest mostly are sorted by size but not necessarily. If your mesh contains many many parts like floaties, the program might crash.

1 Like

As indicated before, such functionality is available in VTK and thus accessible in slicer but also in other geometry processing libraries which may/may not build on VTK.

A little Python script using vedo could likely do the job.

https://vedo.embl.es/docs/vedo.html

split mesh in connected components:
https://vedo.embl.es/docs/vedo/mesh.html#Mesh.split

extract just the largest connected component:
https://vedo.embl.es/docs/vedo/mesh.html#Mesh.extract_largest_region

Best wishes,

1 Like

Thanks, everyone! This has all been very helpful! I appreciate the time you took and the useful information provided. This is a very good community for learning.