How to Modify the Default Threshold Values in Segment Editor for Custom Segmentation?

Operating system:win11
Slicer version:5.6.2

Hello everyone,

I’m working on developing a custom module in Slicer and started by modifying existing components. In the Segment Editor module, I would like to modify the Threshold adjustment functionality to set a specific default threshold range, such as for skull segmentation.

Specifically, I want to set the default threshold values (e.g., Hounsfield unit range for the skull) so that when performing segmentation, the values are pre-set and there’s no need to manually adjust them every time. This way, the default values can be used directly for segmentation tasks.

My questions are:

  1. Is this modification possible?
  2. Do I need to re-engineer the whole Slicer software, or can this be done by modifying the relevant Python scripts or configuration files?

I think you can do this all from Python (.slicerrc.py or in your own module’s initialization).

Each Segment Editor has its own effects, and each effect has their parameters. Look at here for example to see how a parameter can be changed:
https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#create-keyboard-shortcut-for-toggling-sphere-brush-for-paint-and-erase-effects
And you can see which parameters to set here: