Get Module Panel on Jupyter Notebook

I’m doing a small project using 3DSlicer and jupyter notebook and I needed some help with the GUI. I’m using some script I got and it ain’t work. I was wondering if there’s any way I get all the GUI on jupyter notebook so I can segment inside the notebook and not having to go to 3DSlicer to do the segmentation.

I have this code:

# Only available if jupyter desktop server is configured.
# "404 : Not Found" error is displayed if Jupyter desktop server is not configured,
# in that case, switch to the application window if Slicer is running locally.
app = slicernb.AppWindow(contents="full", windowScale=1)

slicer.util.selectModule("SegmentEditor")
segmentEditorWidget = slicer.modules.segmenteditor.widgetRepresentation().self().editor
segmentEditorNode = segmentEditorWidget.mrmlSegmentEditorNode()
segmentationNode=slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode")
segmentEditorWidget.setSegmentationNode(segmentationNode)
segmentEditorWidget.setMasterVolumeNode(volumeNode)


display(app)

I was assuming (contents=“full”) would solve it but it just opens a new slicer tab and won’t run on my notebook.

Do you use the slicer-notebook docker image or you just run Slicer directly on your computer?

I just use it on my computer

slicernb.AppWindow offers GUI access to the Slicer application when Slicer runs on a remote server or within a docker container. If you run Slicer locally then remote desktop access is not necessary but you can just split your screen between the notebook and Slicer. You can still include views into your notebook various ways - see all the other examples above AppWindow examples.

I would like to do the segmentation inside the notebook and not having to go to slicer, just to make it faster and all in one place,
I’ll check slicernb.AppWindow.
Thank you.

I’ve been searching all around and I can’t find any documentation on slicernb.AppWindow. Where can I find it?

JupyterNotebooksLib is a tiny set of convenience classes. We haven’t set up a readthedocs site for it,. You can type the classname and press Shift-Tab for documentation:

You can also browse the documented source code here: SlicerJupyter/JupyterNotebooks/JupyterNotebooksLib/widgets.py at master · Slicer/SlicerJupyter · GitHub

If anything is not clear or incomplete then feel free to ask here. If you figure out something or your questions are answered then it would be great if you could send pull requests with your suggested changes to the documentation.

1 Like

Thank you for the information, really helped me out. I just have one more question, how can I setup my jupyter desktop server? I’m doing this project with a professor, he never heard about this and we can’t seem to find a solution.

The simplest way to get slicernb.AppWindow command to work is to run Slicer in a docker container.