# Creating a 3D Slicer extension with minimal programming skills

**URL:** <https://discourse.slicer.org/t/creating-a-3d-slicer-extension-with-minimal-programming-skills/17208>\
**Category:** Support\
**Tags:** segmentation, extensions-manager, python\
**Created:** [April 20, 2021, 1:34pm UTC](https://discourse.slicer.org/t/creating-a-3d-slicer-extension-with-minimal-programming-skills/17208 "2021-04-20T13:34:21Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [April 22, 2021, 5:41pm UTC](https://discourse.slicer.org/t/creating-a-3d-slicer-extension-with-minimal-programming-skills/17208/20 "2021-04-22T17:41:18Z")

</div>

> [@Vincebisca](#):
>
> I want to create some kind of workflow interface as follows :
> 
> 1. File loading manually (drag and drop would be cool)

I don’t know how to do this, but I believe it is possible. Loading via the Add Data method has never seemed cumbersome enough to me to pursue it.

> [@Vincebisca](#):
>
> 1. Selecting a segmentation scenario according to the type of image and anatomical parts to be treated

Automatically? Then you need to come up with the decision algorithm and implement it. Manually? Then just pick your favorite UI method (buttons, radio buttons, etc.)

> [@Vincebisca](#):
>
> 1. Segmentation using a limited set of methods (I want to display only the needed methods for this particular scenario, not everything that is available)

I have used segment editor effects from my modules, but have not tried to put a limited set of interactive effects to be available to the user. However, it looks like [this discussion](https://discourse.slicer.org/t/how-to-remove-some-segment-editor-effects/16162) has exactly what you want.

> [@Vincebisca](#):
>
> 1. Exportation of the segments as STL files

This is straightforward. You can use `slicer.vtkSlicerSegmentationsModuleLogic.ExportSegmentsClosedSurfaceRepresentationToFiles()` to export to STL or OBJ files.

> [@Vincebisca](#):
>
> So my questions are :
> 
> 1. I would like to not overcrowd the interface, so I am thinking of doing something like several interfaces that are displayed in the order of the phases and linked with a “previous/next” button, is it feasible? Do I need to have several QtDesigner files with the specific interface on each or is it one file with different pages?

The simple method used in many Slicer modules is to have sections with collapsible buttons. This allows areas which are not in current use to be collapsed and take up less room, allowing more screen space for the active area. You can set up your code to automatically collapse and expand sections at the proper times. For example, if I have a section in a collapsible button which is `self.ui.CTRegistrationAreaCB` I can collapse it with `self.ui.CTRegistrationAreaCB.collapsed = True`. For another approach, I believe Qt also allows tabbed layouts, but I’ve never tried that or looked into it so I can’t really help with that. Another possible approach would be to have multiple modules that you switch between (see [this discussion](https://discourse.slicer.org/t/create-a-workflow-between-modules/8510)). Also, I would highly recommend taking a look at [Slicelets](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Slicelets).

> [@Vincebisca](#):
>
> 1. For the segmentation part especially, is there a way to fully reuse what is done in the segment editor but with just a limitation of the available effects? Or do I have to recreate the whole thing manually?
> 2. I’ve seen in QtDesigner that there is a SegmentEditorWidget that basically displays the whole thing at once but I have not been able yet to understand how the connexion is done. It seems a bit different from simple buttons. And can I edit this widget? Because I haven’t found a way to access the internal features of the Widget…

[This discussion](https://discourse.slicer.org/t/how-to-remove-some-segment-editor-effects/16162) looks like it answers your question directly.

If you want to see an example of a working module which uses specific segment editor effects (but not the same way as they appear in the Segment Editor module) you could take a look at [Heartbeat4D/PropagateSegToOtherPhases.py at main · mikebind/Heartbeat4D · GitHub](https://github.com/mikebind/Heartbeat4D/blob/main/PropagateSegToOtherPhases.py) The code there is old, written before Qt Designer became the default way of creating the UI, but it still works fine. It makes use of thresholding, grow from seeds, erode, close holes, masking, creating empty segments, and copying from one segmentation to another.

---

_[View the full topic](https://discourse.slicer.org/t/creating-a-3d-slicer-extension-with-minimal-programming-skills/17208)._
