Skip to content

Latest commit

 

History

History
107 lines (83 loc) · 5.87 KB

README.md

File metadata and controls

107 lines (83 loc) · 5.87 KB

Segment Mesher extension

This is a 3D Slicer extension for creating volumetric meshes from segmentation using Cleaver2 or TetGen.

Cleaver2 mesher is freely usable, without any restrictions. TetGen mesher is only free for private, research, and educational use (see license for details).

Alt text

Installation

  • Download and install a latest stable version of 3D Slicer (https://download.slicer.org).
  • Start 3D Slicer application, open the Extension Manager (menu: View / Extension manager)
  • Install SegmentMesher extension.

Tutorial

  • Start 3D Slicer
  • Load a volume: switch to "Sample Data" module and load MRHead image
  • Switch to "Segment Editor" module
  • Add a new segment (it will contain the entire head)
  • Fill segment by thresholding: click "Threshold" effect set 30 as lower threshold, click "Apply"
  • Smooth segment: click "Smoothing" effect, set kernel size to 6mm, click "Apply"
  • Add a new segment (it will contain a spherical lesion)
  • Paint a sphere in the brain (simulating a lesion): click "Paint" effect, enable "Sphere brush", set "Diameter" to 8%, and click in the yellow slice view
  • Switch to "Segment Mesher" module (in Segmentation category)
  • Select "Create new Model" for Output model (this will contain the generated volumetric mesh)
  • Click Apply button and wait a about a minute
  • Inspect results: open "Display" section, enable "Yellow slice clipping", move slider at the top of yellor slice view to move the clipping plane; enable "Keep only whole cells when clipping" to see shape of mesh elements
  • Create more accurate mesh: open "Advanced" section, set scale parameter to 0.5, click "Apply", and wait a couple of minutes

Visualize and save results

  • Open "Display" section to enable clipping with slices.
  • Go to "Segmentations" module to hide current segmentation.
  • Switch to "Models" module to adjust visualization parameters.
  • To save Output model select in menu: File / Save.

Alt text

Mesh generation parameters

Cleaver parameters are described at https://sciinstitute.github.io/cleaver.pages/manual.html. Increase --scale parameter value to generate a finer resolution mesh.

  Meshing mode (element size control):
  -m [ --mesh_mode ] arg          Background mesh mode (structured [default], regular)
                                  Structured means adaptive computation of element size.
                                  Regular means constant element size.

  For regular mode (constant element size):
  -a [ --alpha ] arg              initial alpha value
  -s [ --alpha_short ] arg        alpha short value (only for "regular" mesh_mode)
  -l [ --alpha_long ] arg         alpha long value (onlu for "regular" mesh_mode)

  For structured mode (adaptive element size):
  -g [ --grading ] arg            sizing field grading: maximum rate of change of element size
                                  (1 is uniform)
  -x [ --multiplier ] arg         sizing field multiplier: feature size scaling
                                  (higher values make a coarser mesh)
  -c [ --scale ] arg              sizing field scale factor: volume sampling rate
                                  (higher value makes finer mesh)

  For prescribed sizing field (user-defined element size):
  -z [ --sizing_field ] arg       optional input file containing sizing field

  Other:
  -B [ --blend_sigma ] arg        Sigma of Gaussian smoothing filter that is applied
                                  to the input labelmap to remove step artifacts (anti-aliasing).
                                  Higher values may shrink structures and remove small details.
  --simple                        Use simple interface approximation.
  -b [ --background_mesh ] arg    input background mesh
  -w [ --write_background_mesh ]  write background mesh
  -r [ --record ] arg             record operations on tets from input file.
  -t [ --strict ]                 warnings become errors
  -v [ --verbose ]                enable verbose output
  -V [ --version ]                display version information

TetGen parameters are described at http://wias-berlin.de/software/tetgen/1.5/doc/manual/manual005.html#sec%3Acmdline

Developers

Split mesh to submeshes

meshNode = getNode('Model')
mesh = meshNode.GetMesh()
cellData = mesh.GetCellData()
labelsRange = cellData.GetArray("labels").GetRange()
for labelValue in range(int(labelsRange[0]), int(labelsRange[1]+1)):
    threshold = vtk.vtkThreshold()
    threshold.SetInputData(mesh)
    threshold.SetInputArrayToProcess(0, 0, 0, vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS, "labels")
    threshold.ThresholdBetween(labelValue, labelValue)
    threshold.Update()
    if threshold.GetOutput().GetNumberOfPoints() > 0:
        modelNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLModelNode", "{0}_{1}".format(meshNode.GetName(), labelValue))
        modelNode.SetAndObserveMesh(threshold.GetOutput())
        modelNode.CreateDefaultDisplayNodes()

Acknowledgments

Cleaver is an Open Source software project that is principally funded through the SCI Institute's NIH/NIGMS CIBC Center. Please use the following acknowledgment and send references to any publications, presentations, or successful funding applications that make use of NIH/NIGMS CIBC software or data sets to SCI: "This project was supported by the National Institute of General Medical Sciences of the National Institutes of Health under grant number P41 GM103545-18."

TetGen citation: Si, Hang (2015). "TetGen, a Delaunay-based Tetrahedral Mesh Generator". ACM Transactions on Mathematical Software. 41 (2): 11:1-11:36. doi:10.1145/2629697