Create Your Own Module!

CONTENTS

DEVELOPMENT MODES


Scripted Module (i.e. development in Python)

Description
A scripted module is one way of developing a module in 3D Slicer. It is written using Python, and provides access to most classes required to build a module, such as all of VTK, most of ITK and Qt. If complete access to all of these classes is required, the module should be written in C++ (see the section below). For more information on scripted module development click here!
Advantages
  1. Does not require extensive programming experience.
  2. Compatible with downloaded slicer, both nightly and stable releases, which means it does not require compiling Slicer from source code.
  3. The python console in 3D Slicer allows you to test parts of your code. Be aware that there are minor differences in coding structure between the console and your python script.
Development
  1. To incorporate logic that was written in another scripted module in your module, you must use a scripted module yourself.
  2. Scripted modules can access logic class written in any C++ (loadable) module available in 3D Slicer using slicer.modules.[ModuleName].logic().
  3. ITK is available in scripted modules through SimpleITK. SimpleITK is slightly different than ITK. Please refer to SimpleITK documentation for more information, provided here.
  4. The Qt functions that are available for a scripted module have been converted to Python (I.e. Python wrapped) from C++. Due to this, the naming convention and functionality are not entirely consistent. Note: PyQt is a commercial product that is entirely separate from the Python wrapped Qt. To access these functions use: qt.Q[FunctionName].
  5. All other normal python functionality can be accessed through a scripted module, including importing classes (eg. import numpy)
Sample code
This section provides sample code for developing a 3D Slicer loadable module with IGT capabilities. This skeleton file is scripted in Python with specific IGT capabilities that you can use for development. If these capabilities are not useful for your application they can simply be commented out or removed from the script. A sample xlm file is also included to enable connection to the Plus Server. Sample code for a scripted module can be found here!  


Loadable Module (i.e. development in C++)

Description
A loadable module is another way of developing a module in 3D Slicer. It is written using C++, and provides full access to VTK, ITK and Qt. Please refer to this page to learn how to create a loadable module here! .
Advantages
  1. Able to handle complex computations efficiently.
  2. Provides full control over the user interface.
  3. Enables logic classes to be reused by any other scripted or loadable module.
Development
  1. Requires building Slicer in other words compiling Slicer from source code through CMake. Learn how to build Slicer here!
  2. Packaging a loadable module requires it to be complied in a similar manner to Slicer. Packing allows the modules to be loaded into Slicer.
  3. Developing loadable modules require more advanced coding skills and a background in C++ programing.

 

CREATE A MODULE

Once the module type is decided, follow these step to create the folder and files for the module.










Figure 1: Steps for creating your own module.

 

ADD MODULE TO AN EXTENSION<

To include your module into the 3D Slicer extension manager (i.e. make your module open source), follow the instructions below.
  1. Create a GitHub repository for your module
  2. Select the extension that fits your module best and send a pull request to that extension's GitHub.
  3. If your module doesn't fit into any existing extensions or you want to create a new extension, send a pull request to the general Slicer GitHub page.
  4.