Create Your Own

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.

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.
  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

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.

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.
  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.