Inserting a unique Module to Pipeline Creator

Hello. Is there a way to insert unique module into the Pipeline Creator extension? Specifically, I would like to add Volume Clip With Model as a custom step in a pipeline. Thanks.

A timely question – check out the Slicer Pipelines update announcement just posted.

Terrific! Thanks so much for your reply.

A good example is probably how we added the Surface Toolbox pipeline steps.

To be able to add a new step you need to

  • Write a function that executes your functionality
  • add the @slicerpipelines decorator

See also the Pipelines Documentation you could even do this in the Python Console.

Any pipeline that you create though will need to be able to call the code that you wrote so you will also need to make it persistent within the slicer environment. Otherwise you would not be able to execute your pipeline after a new start. It should probably be added to the module that it is mainly utilizing. If that is not accessible you could probably add it to a custom module created via the Extension Wizard, or just add it to you .slicerrc.py. You could add the function to the module that you created once it’s been stored.

1 Like

Hi!
sorry for hijacking this thread, I work in the medical field and have limited coding experience, is it possible to add the Model Maker module as a new pipeline step in the way you explained?

Hi Lorenzo, yes it should be, you would need to put the functionality you need from Model Maker into a python function. I don’t know enough about Model Maker to be a good resource here. In most cases it’s calling some function of the modules logic().

Although it looks like the Model Maker is a CLI module this might require a bit more work than a normal Slicer module (https://github.com/Slicer/Slicer/blob/main/Docs/developer_guide/python_faq.md)

Maybe if you provide more specifics some of what you need some other community member can help you with this

1 Like

hi Herald, thank you for your answer, I will read through the python FAQ and see if I can do something myself.
The goal would be to have a pipeline step that takes a labelmap and exports .stl files of that segment with the desired amount of smoothing applied (this value would be chosen in the creation of the pipeline or if possible at every use of the pipeline). I’m having trouble finding the ModelMaker modules functions in the software repository (so that I could at least use them in a python script) could you please indicate me where to find them?
thank you very much

We talked a bit internally and it seems that the Model Maker module as it’s a CLI module doesn’t quite follow the pattern of the currently implemented modules. We’re currently looking into whether we can set up an example using the the Model Maker module, this might take a bit though

As an option the current implementation for the Segmentations tool only exposes access to the first segmentation. It would be a lot easier to write an version that takes the index of a segmentation to write out. Would that be of help or is what you need only achievable within the modelmaker ?

Hi, I think it would be only possible from the model maker module but let me briefly explain what I need to do so you can confirm that there isn’t another way to do this.
I need two different segments from a head CT scan, one including all the solid parts and one including only the air around the face and in the upper airways (I do this with thresholding and a bit of postprocessing of the segments). Then I export them to a labelmap and use the model maker module to apply two different types of smoothing (sinc and laplacian) to the models and export a pair of stl for each segment (one for each smoothing option). All this can be automated with a pipeline up to the labelmap export. I’m not in the position to change the smoothing approach (i.e. using the segment smoothing option) because I need to follow specific guidelines in the stl creation.
thank you and your colleagues for your help.

I would recommend using segmentations for converting labelmap to closed surface. It uses Windows sinc smoothing, as Laplacian smoothing shrinks volumes.

Model Maker uses mini-scenes, which is a special method for importing a large set of models, which is not used anywhere else and therefore not well supported. Model Maker module is not used much anymore, since segmentations take care of generating closed surface representation automatically (and have many other advantages).

If you want to specifically study the issues with Laplacian smoothing then you can turn off smoothing in the segmentation (in representation conversion parameters) and then apply various VTK filters yourself (it takes 4-5 lines of Python script to run a VTK smoothing filter on a model node).

Hi, thank you for your answer.
Correct me if I’m wrong but are you saying that if I create a segment in the “Segment editor” module with the smoothing switched on (lets say with the value of 0.10) and then export it through the “Segmentations” module “Export to files” function in STL format I would obtain the same STL produced by the Model Maker module when choosing the Sinc smoothing option with the value of 0.1? ( In the Model Maker case I would export the segments without smoothing to a labelmap)

Smoothing factor is not interpreted the same way (in segmentation we use a logarithmic scale to make it easier for users to cover a wide range) but the same VTK classes are used.

1 Like