Add SlicerModelsVoxelization extension#2368
Conversation
Create Voxelization.json to ExtensionsIndex
|
This seems cool, but how is it different from what's already available in the Segmentation infrastructure? @lassoan |
|
Hi @pieper, thank you very much for your comment, We understand the concern. The current name/description may indeed be a bit misleading, and we would be happy to improve them to make the purpose of the extension clearer. The extension is not meant to replicate Segment Editor functionalities. Its goal is to generate a voxel-based volumetric mesh made of regular hexahedral elements, with a user-defined pitch. The output is therefore not a labelmap and not a surface model, but a volumetric mesh with nodes and elements that can be used in FEM workflows, for example with SOFA-Slicer, or exported to other simulation tools. The main difference from the Segment Editor / labelmap infrastructure is that the mesh resolution is controlled by the selected pitch, independently of the original image or segmentation resolution. The extension also lets users define a threshold for the minimum fraction of volume that a voxel must contain to be included in the final mesh, giving control over the boundary approximation and the trade-off between geometric fidelity, mesh size, and robustness. Compared to Segment Mesher, that also generates volumetric meshes, the extension provides a different type of volumetric discretization: regular voxel/hexahedral elements instead of tetrahedral elements. The extension also includes standard Boolean operations and the possibility to export the output meshes in different file formats. We see this as a complementary workflow. Tetrahedral meshes are very useful, but tetrahedralization can require additional surface cleaning and preprocessing, especially for complex anatomical geometries. A regular voxel/hexahedral mesh can be useful when a more straightforward and robust volumetric discretization is desired, for example in preliminary, automated, or educational FEM workflows. We presented a preliminary version of this work at the 3D Slicer Project Week in January 2026 and received encouraging feedback from participants interested in this workflow. We would be happy to discuss this further, clarify any remaining questions, and improve the extension, its name, or its documentation based on your suggestions. |
|
Okay, I see, thanks for the clarification. There are some failing checks to look into. |
update category to "Utilities"
|
Thank you @pieper, We have looked into the failing checks and working now on fixing the issues. |
Update Voxelization extension revision
Revisions
Revisions
|
It was not clear for me from the documentation what this extension can be used for. You could simply write that it provides a hexahedral mesher and give some information on the meshing strategy and intended use. I would also recommend to consider using more of the already Slicer infrastructure and VTK, because it may dramatically reduce the amount of code that you need to maintain. If the output is simply a uniform hexahedral mesh then vtkThreshold filter (followed by an optional append filter to merge points) could be used instead of bringing in trimesh. Boolean operations are available for both models and segmentations (Combine Models module in Sandbox extension; and Logical operations effect in Segment Editor), and quantitative analysis is offered in Segment Statistics module. Resampling segmentations is available in Segment Editor (specify geometry) or in Crop Volume module. Saving in various formats are already available in File/Save and Export node. Additional import/export formats can be easily added by implementing file reader/writer plugins. |
Thanks for your comment. I am Kimia and I am one of the contributors of the project. Regarding your comments:
|
vtkPolyDataToImageStencil is used in Slicer core extensively and have not experienced any issues. It did not support image directions when we started to use it and it may still not support it, so we usually convert the model points to IJK coordinate system. Have a look at https://github.com/Slicer/Slicer/blob/28ef15df2165a150be97f52e426f22a7dfdbd20d/Libs/vtkSegmentationCore/vtkClosedSurfaceToBinaryLabelmapConversionRule.cxx for a complete example.
Boolean operations are trivial on labelmap images (which are equivalent to hexa mesh on a uniform grid), so there is no need for Combine Models module, but simply resample the segmentations to the same grid and use numpy or VTK filters to combine the labelmap volumes.
Segmentations module can convert surface mesh to labelmap at the desired resolution (you can adjust it in the segment representation conversion parameters). The labelmap is equivalent to a uniform hexahedral mesh, as the conversion is trivial (unless I miss something).
You can call PLY is supported already. OFF is just for surface meshes and not very widely used. Probably it is better not to use it. MSH export using meshio is fine, but you don't need to add any custom GUI, but instead you can add a custom reader/writer and then the new file format will show up in the standard Save data dialog. See complete example here: https://github.com/Slicer/Slicer/blob/28ef15df2165a150be97f52e426f22a7dfdbd20d/Applications/SlicerApp/Testing/Python/SlicerScriptedFileReaderWriterTest.py#L118-L166
Segment statistics gives you both the volume computed from the surface mesh and labelmap representation (i.e., the hexa mesh). It is not required to use existing Slicer features, I just wanted to let you know that these features exist so that you can reduce the amount of code you need to maintain and support, if you want to. |
New extension
Tier 1
Any extension that is listed in the Extensions Catalog must fulfill these requirements.
Slicer(unless it explicitly provides a bridge between Slicer and a tool or library), because it would make it more difficult to find extensions if the name of many started with the same word.3d-slicer-extensionGitHub topic so that it is listed here. To edit topics, click the settings icon in the right side of "About" section header and enter3d-slicer-extensionin "Topics" and click "Save changes". To learn more about topics, read https://help.github.com/en/articles/about-topicsSettingsand in repository settings uncheckWiki,Projects, andDiscussions(if they are currently not used).Aboutin the top-right corner of the repository main page and uncheckReleasesandPackages(if they are currently not used)Tier 3
Community-supported extensions.
Tier 5
Critically important extensions, supported by Slicer core developers. New Slicer Stable Release is released only if all Tier 5 extension packages are successfully created on all supported platforms.