Programmatically (python) define the values for the min and max of the slider in the volume widget (not the min-max of the window/level)

Once you have a qMRMLWindowLevelWidget object, you can use the setMinMaxBounds method.

import SampleData
volume_node = SampleData.SampleDataLogic().downloadMRHead()
window_level_widget = slicer.qMRMLWindowLevelWidget()  # creates a new window/level widget object
window_level_widget.setMRMLVolumeNode(volume_node)
window_level_widget.setMinMaxBounds(0,100)
window_level_widget.show()

You can also see discussion linked below about why you might use Window/Level values that are outside of the scalar range and why the values of -600 to 600 are chosen in the image you show.

1 Like