Changing threshold in python does not update in any views

I want to use a shortcut to change the lower threshold of a foreground US volume to 1 (so that the black surrounding pixels disappear).

I used the code from here, and this code changes the threshold in the GUI, however, it doesn’t ‘propagate’ to any of the views - nothing changes there. I still need to manually nudge the slider/value a bit for the view to be updated.

Is there any command that needs to be executed for the view to be updated?

Make sure you have turned on thresholding for the display node. You can set threshold values with thresholding not enabled.

volume_node.GetDisplayNode().ApplyThresholdOn()

This will essentially change the Threshold mode combobox selection from “Off” to “Manual”. It also changes to “Manual” after manually dragging the threshold slider.

image

3 Likes