# Threshold scalar volume to labelmap

**URL:** <https://discourse.slicer.org/t/threshold-scalar-volume-to-labelmap/4457>\
**Category:** Development\
**Tags:** volume, cli, filters\
**Created:** [October 18, 2018, 8:22pm UTC](https://discourse.slicer.org/t/threshold-scalar-volume-to-labelmap/4457 "2018-10-18T20:22:07Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![kayarre](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kayarre/32/3606_2.png) [@kayarre](https://discourse.slicer.org/u/kayarre)\
**Post date:** [October 18, 2018, 8:22pm UTC](https://discourse.slicer.org/t/threshold-scalar-volume-to-labelmap/4457/1 "2018-10-18T20:22:07Z")

</div>

I am trying to use the python interface to load a (float) scalar volume in the form of a signed distance field want to apply thresholdscalarvolume to generate a label map with everything below 0.0. It doesn’t seem to be working in terms of creating the label map and running the cli interface.

here is a brief attempt with the code:

```auto
level_set = value['level_set']

[success, volumeNode] = slicer.util.loadVolume(level_set, returnNode=True)
volumeNode.SetName("case4" + "level_set")

tempLabel = slicer.vtkMRMLLabelMapVolumeNode() 
slicer.mrmlScene.AddNode(tempLabel) 
tempLabel.SetName("case4" + "thingy") 
temp_stuff = slicer.vtkSlicerVolumesLogic().CreateLabelVolumeFromVolume(slicer.mrmlScene, tempLabel, volumeNode)

# Compute the thresholded output volume using the Threshold Scalar Volume CLI module
cliParams = {'InputVolume': volumeNode.GetID(), 'OutputVolume': tempLabel.GetID(), 'ThresholdValue' : 0.0, 'ThresholdType' : 'Below', 'OutsideValue' : 1.0}
cliNode = slicer.cli.runSync(slicer.modules.thresholdscalarvolume, None, cliParams, wait_for_completion=True)

```

---

_[View the full topic](https://discourse.slicer.org/t/threshold-scalar-volume-to-labelmap/4457)._
