Get Voxel count off of LabelMapNode?

How would I get the number of voxels off of a label map node?

Use Labelmap statistics module to get the number of non-zero voxels.

1 Like

How would I go about that?

  • Open Label statistics module
  • Select Grayscale volume
  • Select Label map volume
  • Click Apply

Count column contains the number of voxels.

How would I access this through python?

The module is written in Python, so any specific functionality could be easily extracted/duplicated in your own script. Here is the relevant section:

If you want to build anything on this, then I would strongly recommend to switch to Segmentations/Segment Editor/Segment statistics modules now. These modules are much more capable than the old Editor/Label statistics - those old modules will be kept around for a while but they will not be developed any further.

See complete example of using Segment statistics in Python below. You can run the test by enabling developer mode in Slicer application settings, opening Segment statistics module, and clicking on Reload and test button.

1 Like