Create a workflow between Modules

Operating system: win10
Slicer version: 4.10.0
Expected behavior:
Actual behavior:

Hi,everyone. I want to create a flow like this: DICOM → Segment editor ->Segmentations->…
by using /creating a button in each module instead of using the module list in toolbar.

I noticed that there is a button in Segment editor module can do the work like i mentioned above.
image

Can someone give me some suggestions about how to achieve this ?

Thanks in advance.

See description of how to implement a “slicelet”, a custom workflow with simple and convenient user interface: https://www.slicer.org/wiki/Documentation/Nightly/Developers/Slicelets

You could also look at the CaseIterator extension if you are working through a long list of similar subjects.

https://www.slicer.org/wiki/Documentation/Nightly/Extensions/SlicerCaseIterator

Thanks for the reply.

A “slicelet” seems really good.

But i do not want to create another user interface and what i expect is that we do not change modules or extract functions from modules and we only set a fixed order for each module , for example, we load dicom iamges in DICOM module and we click a “Next” button (that we can create) on DICOM UI, it will go directly to Segment editor module.

The function of this “Next” button is similar to the “Segmentation” button in above pic.

Can this be achieved ?

Thanks guys . I have solved this problem by using the code below:

// Switch to registration module and set selections
qSlicerAbstractModuleWidget* moduleWidget = qSlicerSubjectHierarchyAbstractPlugin::switchToModule("SegmentEditor");
QApplication::processEvents();
1 Like

Thanks for this, it helped a lot!
In python the code is easier

def switchModule(self, moduleName):
    # Switch to another module
    pluginHandlerSingleton = slicer.qSlicerSubjectHierarchyPluginHandler.instance()
    pluginHandlerSingleton.pluginByName('Default').switchToModule(moduleName)

Built-in module user interfaces expose almost all underlying features, which is ideal for free experimentation. However, this flexibility and complexity is not well suited for enforcing a fixed workflow. Depending on your users, they may be able to tolerate this.

In general, you can get much better results by creating your own module GUI by using Qt designer application. You just drag-and-drop the components you need and connect them in the designer and maybe a few ten or hundred lines of Python code. See details instructions in this tutorial.

Example of a module GUI edited in Qt designer, made of Qt, CTK, and high-level Slicer widgets:
image

Most modules provide reusable high-level components but if there are some features in a module GUI that you cannot replicate easily in your own module then let us know. Segment Editor is designed to be embedded into custom module GUIs. DICOM browser is not displayed in a view layout, so in your module you can simply switch to the DICOM browser view layout to browse/load DICOM files.

1 Like