Edit this page

NA-MIC Project Weeks

Back to Projects List

Use Slicer from Jupyter notebook

Key Investigators

Project Description

Jupyter notebook is an interactive shell for executing scripts and viewing execution results.


Notebook user interface (frontend) is separated from the code execution engine (kernel). The objective is to create a Slicer extension, which Jupyter notebooks can connect to and access all Slicer features.

Approach and Plan

  1. Implement extension that includes a simple kernel that can execute Python commands using Slicer’s built-in Python interpreter.
  2. Implement returning of console output to the notebook.
  3. Implement returning of viewer content to the notebook.
  4. Publish extension on extension manager.

Progress and Next Steps

  1. Created SlicerJupyter extension, which uses xeus as Jupyter kernel implementation
  2. Contributed changes to dependent projects. See our QuantStack/xeus pull requests, our xeus issue report discussing best strategy to update xeus for supporting event-loop integration, and also our branch improving CMake support for CryptoPP.
  3. Implemented command execution
  4. Implemented preliminary version of display() function to show viewer content in the notebook.
  5. Publish extension on extension manager.

Future plans:


Side-by-side view of a Notebook and 3D Slicer:

Screenshot of a notebook and Slicer

Notebook showing code and viewer content:

Screenshot of a notebook

Notebook showing code and viewer content:

Screenshot of a notebook in JupyterLab

Complete notebook rendered on GitHub: https://github.com/lassoan/SlicerNotebooks/blob/master/My%20first%20Slicer%20notebook.ipynb

Background and References