Can I prevent ModelMaker from changing what appears in the Slice views?

I am using ModelMaker in a custom Python module to generate models from a labelmap. I’ve used the code in EditorLib/MakeModelEffect.py as a template.

When the model is generated, the state of the views (i.e., the background image and labelmap) is changed so that only the generated model is visible. Can anyone tell me if this is an intended side effect? Is there a good way to retain the state of the views when the new model is added to the scene?

Note that this behavior occurs when I call ModelMaker from my module (the use case I am interested in), but it also occurs when I use ModelMaker from the Slicer module menu.

Thanks for your help!

When a CLI module returns a mini-scene (as far as I know Model Maker is the only module that does this) then all MRML node selectors are reset. See details in this issue:

The issue is still open, because it only impacts Model Maker, which is now not needed (model<->segmentation<->labelmap conversions can be done using segmentations) and the problem is really hard to solve.

I have the same issue with this model Maker module.
I tried the “labelmap conversions” as you said, but with this tool I can’t set the “smooth” or decimate" parameter. Is there a way to set thoose parameters with the labelmap conversions tool from "segment Editor " ?

You can change decimation and smoothing parameters in Segmentations module as described here.

image

1 Like

Thank a lot very usefull, do you have a python code example that change decimation and smoothing ?

See this example in the script repository.

1 Like