2020 International Conference on Computational Science and Computational Intelligence (CSCI)
Multiple Ways for Medical Data Visualization
Using 3D Slicer
Ismail Mohammed Bahkali Sudhanshu Kumar Semwal
Department of Computer Science Department of Computer Science
University of Colorado Colorado Springs University of Colorado Colorado Springs
Colorado Springs, USA Colorado Springs, USA
[email protected] [email protected] Abstract— Computers can process large amounts of data.
Medical practitioners can deliver better services and provide II. ADVANTAGES OF USING 3D SLICER
more accurate diagnoses and treatment regimens to patients.
This document described how 3D Slicer allows Command Line 3D Slicer has the following advantages:
Interface (CLI), Python, Jupyter, and MATLAB in software to
process medial data. 3D Slicer has become useful software
• It is a free access software compatible with different
worldwide since 1997, especially in the medical field for pre- software such as Linux, Mac OS, and Windows.
operative visualization and analysis. Today, 3D Slicer is • The program is versatile as it uses DICOM files.
supported by The National Alliance for Medical Imaging
Computing (NA-MIC), Neuroimaging Analysis Center (NAC), • It can be integrated with different image devices, such as
Biomedical Informatics Research Network (BIRN), The MRI, CT scanners, and microscopes.
National Center for Image-Guided Therapy (NCIGT), The • 3D Slicer provides real-time images and analysis, which
Harvard Clinical and Translational Science Center (CTSC),
and the Slicer Community worldwide as a platform to develop improves surgical operations and efficiency.
new ideas. In this paper, we demonstrate our knowledge in using • Users are at liberty to customize the platform by adding
the 3D Slicer software. modules that suit them.
Keywords-component; 3D Slicer, MATLAB, Jupyter, Python, • Visualization allows professionals to share opinions that
CLI. lead to improved software.
• It can help generate better information, possibly reducing
I. INTRODUCTION diagnosis time for treatment.
3D Slicer is one of the quintessential software commonly • It reduces the cost of surgery by minimizing surgery
used in the medical field [16]. The system is open-source and planning and process.
used to visualize and analyze medical image data sets [2] [16]
[20]. It supports a wide range of information formats such as • It has broad functionality and scalability.
images, surfaces, segmentation, and annotations in either 2D,
3D, and 4D [4] [15]. The platform allows developers to III. 3D SLICER LIMITATION
implement and evaluate new features, which can then be
distributed to other clinical users. The main programming Despite the many advantages, 3D Slicer is characterized
languages used to code 3D Slicer are C++ and Python. by the following limitations:
However, it provides a secondary extension module, enabling
users to customize the platform’s functions and appearance. • It requires technical know-how to use the software or to
According to the article by Fedorov [4], the program is analyze data. Therefore, it limits the use of the software.
written in Python and C++. It has a full environment and • Restarting the program after adding extensions is
packages for the Python language [5]. 3D Slicer has a built-in mandatory; if the right sequences do not follow installing
Python console functions as a Jupyter notebook kernel for
easy prototyping and customization of products for customers, it or using it after installation, there could be errors.
hence analyzing different coding languages that one can • The software is also not approved for clinical use and is
utilize to code the program. This paper analyzes and examines meant for research, conditions that limit the usage in real
how to code 3D Slicer using CLI, Python, Jupyter, and situations [4].
MATLAB. The recommended process of coding 3D Slicer
includes GitHub download, CMAKE compilation, generation, • It is challenging to construct the environment, meaning that
and package because the procedure is simple and convenient there is no easy way to modify the program.
for the development of a software programming environment.
978-1-7281-7624-6/20/$31.00 ©2020 IEEE 793
DOI 10.1109/CSCI51800.2020.00149
IV. HOW TO USE A 3D SLICER?
3D Slicer operates in any Windows, Mac, or Linux
computer, and the installers are available in 64-bit. It is also
recommended that the hardware should have a memory of
more than 4GB, a minimum resolution of 1024 by 768, and
dedicated graphics [4]. New users get overwhelmed by the
number of options available after installing the software. It is
crucial to learn how the systems operate for different
applications. After launching the software, data should be
loaded, as illustrated in Figure1.
Figure 3. The representation of 3D Slicer built-in modules.
1. Annotations: Build and edit additional data linked
with a scene. The Markups module will shortly
replace the module. Currently supported
annotations are fiducial points, rulers, and
regions of interest (ROIs).
2. Data: It contains all information and allows
operation such as search, delete, or rename. The
Data module is the fundamental data-organizing
Figure 1. 3D Slicer window for loading data. point where presenting all loaded data for access
and direction is the Data module. It permits
After the process above, views can be customized by regulating the data in folders or patient/study
clicking the controller display push button. The options allow trees (automatically done for DICOM),
setting viewpoint direction and adding the slice to the 3D visualizing any displayable data, transforming
viewer. Figure 2 is a screenshot of the 3D Slicer window for whole branches, and many data type-specific
managing image views, which we have edited with comments features.
to show different image views.
3. DataStore: Allows users to download and upload
datasets.
4. DICOM Allows importing, loading, and exporting of
DICOM data. Allows sending and receiving data
using DICOM networking.
5. Markups: Create, edit, and manage markup
matrices in two and three dimensions. It can
replace fiducials annotations.
6. Models: The Models Module loads and balances
illustrate parameters of models such as Color,
Transparency, and Clipping. Save models via the
File menu, Save button. The Add 3D model or a
model directory button will permit the user to
Figure 2. A screenshot of the 3D Slicer window for managing image load any model that Slicer can read and all the
views. VTK models in a directory. Add Scalar Overlay
will load a scalar file and associate it with the
The third step involves data processing. The 3D Slicer currently active model. The user can modify the
software consists of already included modules (illustrated by appearance characteristics of the models in the
Figure 3), which include the following: Display pane. Select the model to operate on
794
from the model selector drop-down menu. Load 14. Welcome to Slicer: A panel features for loading
scalar overlays with a default color lookup table. data and customizing the view.
The user can reassign scalar overlays manually.
The user can turn on Clipping for a model in the V. PROGRAMMING 3D SLICER
Display pane and selecting the slice planes that The UI for 3D Slicer consists of three sections: input
will clip the model are in the Clipping pane. The parameter, results-widgets, and standard 2D and 3D views
Model Hierarchy pane enables the user to group [14]. The 3D Slicer software architecture is developed in
models collectively and sets the group's modules, which are coded using different programming
properties. languages. The system has three main modules: CLI, Scripted,
and Loadable Modules [11]. Accordingly, a developer writes
7. Scene Views: Create, edit, restore, delete scene the script modules using Python language that allows easy and
views. Scene views capture the state of the MRML extensive access to 3D Slicer’s internal systems. The
scene at a given point. The accepted method to developers further apply C++ language for the loadable
utilize them is to load all user data and then modules that control a custom graphical user interface’s
adjust the element's visibility and capture particular behavior. CLI communicates only through the
impressive scenic views. Unexpected action may predefined display, which limits its interaction. Each of the
happen if the user adds or deletes data from the other subsection is developed using specific algorithms to
scene while saving and restoring scene views. achieve particular functions. Thus, different programming
languages are used to create sections of 3D Slicer, which
8. Segment Editor: It allows editing segmentation defines their applications. 3D Slicer extension modules can be
coded using different languages such as MATLAB, Python,
objects by straight illustration and handling
Jupyter, and CLI. MATLAB’s functions can be accessed and
segmentation tools on the contained segments in employed within a 3D Slicer environment using
real-time, updating representations are MatlabBridge extension, enabling faster and simple
automatically other than the label map one. prototyping [9]. As a result of API in Python wrapper, 3D
Slicer can be customized using the Python language.
9. Segmentation: Any segmentation can hold Moreover, the Jupyter language can be implemented in 3D
multiple segments, which match to one structure Slicer by following a GitHub centric workflow [17]. The CLI
or ROI. Every segment can include multiple data approach can also be used to customize 3D Slicer through
representations for the same structure, and the input and output strategy, which is more accessible but limited
module supports automatic transformation to one batch processing at a time. The recommended steps for
between these illustrations and advanced customizing 3D Slicer software include the following steps:
appearance settings, and import/ export
features. • GitHub download.
• CMAKE compilation.
10. Transforms: Create and edit transformation • Generation and package phases.
matrices.
VI. HOW TO CODE 3D SLICER USING PYTHON?
11. View Controllers: It allows for transforming the
views options. Python is also used in many relevant packages, such as
SimpleITK, scikit-learn, and TensorFlow [3]. The 3D Slicer
12. Volume Rendering: It implements a 3D software is written on Visualization Toolkit (VTK), a pipeline
visualization of data. It provides advanced tools based library of graphical data. The program is mainly coded
for the toggling interactive volume rendering of in C++, but the API uses a Python wrapper [1]. The user
datasets. If supported, hardware-accelerated interface is developed in Qt, and it may be modified using
volume rendering is made available. It permits C++ or Python [1]. 3D Slicer has a Python-based platform
the selection of preset transfer functions to with an interactor within the graphical user interface capable
colorize and set the opacity of data in a task- of managing the software. Thus, developers can use built-in
appropriate approach and tools to customize the command-line interpreters to modify 3D Slicer software since
transfer functions that specify these parameters. they have access to the API linked libraries such as VTK, Qt,
and simpleITK, which are wrapped with the Python language
13. Volumes: It changes the size of different data, [13] [14]. Wrapping 3D Slicer software with the Python
adjusting Window, Level, Threshold, Color, and language makes it possible to develop extension modules for
other parameters that regulate the appearance of the program, enabling faster and simple prototyping. The
volume image data in the scene. steps are:
795
1. Open3DSlicer, press the search button next to 5. Add a module to extension.
Modules, click extension wizard.
6. Restart 3D Slicer and then open the created module.
2. Create an extension.
VII. HOW TO CODE 3D SLICER USING JUPYTER?
Jupyter was developed in 2011 as Python notebooks and is
an open software web-based application for programming.
The software supports numerous languages through the
integrated kernels. It can, therefore, be employed to code 3D
Slicer for customization purposes [17]. Yaniv examines
SimpleITK Jupyter notebooks, which can be programmed
using either Python or Language R [17]. The software consists
of a single document that describes the image-appraisal
workflow using text, equations, tables, and figures. The
program is separated into logical parts, known as code chunks.
The algorithm provides an opportunity for modifications via
the graphical user interface. The SimpleITK Notebook is
3. Select destination, which is the root directory.
available using git version control systems and GitHub.
Lowekamp [10] described the SimpleITK as an interface that
allows algorithms and data structures for the Insight Toolkit
(ITK) [7]. The implementation of Jupyter language can follow
a GitHub centric workflow, where new codes can be created
using the git workflow strategy, which is topic branch-based.
As such, a developer uploads code to a forked repository
before pulling a request to the primary dataset. The action
sets-off testing using CircleCI continuous service [17]. The
code is tested and integrated into the system. The Python
kernels embedded in the 3D Slicer make it possible to code
using Jupyter language, following the procedure outlined by
Lowekamp [10]. The steps are:
1. Open 3D Slicer software then click install slicer
4. Select Category. extensions.
796
2. Click on install extensions, pick developers tools, 6. Code using Python, Slicer views can be shown using
install SlicerJupyter, then restart. display command.
VIII. HOW TO CODE 3D SLICER USING MATLAB?
3. Launch JupyterKernal from search, press start
Jupyter server. MATLAB is a popular software used for the development
of algorithms for computational purposes. It is employed for
matrix manipulations, graphing data, creation and
implementation of algorithms, and user interface development
[1]. However, the program is limited to medical analysis
because of the difficulties of importing/exporting,
visualization, and processing images. Nevertheless, Lasso [9]
proposed a strategy that would enable the running of
MATLAB features in 3D Slicer having the architecture of the
proposed MatlabBridge mentioned in Figure 1 in [9].
The authors suggested an extension, MatlabBridge, which
can start the software, receive input data, run algorithms, and
process information using a TCP/IP based OpenIGTLink
protocol [9]. The graphical user interfaces are described in the
CLI module in XML format. The MatlabBridge should be
4. Create Notebook directory. downloaded and installed using the extension manager feature
in 3D Slicer. It has a MatlabModuleGenerator, a helper tool
for creating skeleton modules, which can be extended and
customized. MATLABCommander allows other 3D Slicer
modules to be run by MATLAB functions. Thus, the
MATLAB software can be used to program 3D Slicer
software via a MatlabBridge [9]. The steps are:
1. Open 3D Slicer, click install slicer extensions.
2. Click on install extensions, Pick developers tools,
Install MatlabBridge, then restart.
3. After restarting, Click the welcome to slicer menu,
Pick developer tools, Pick MATLAB, Press
MATLAB Module Generator.
4. Enter Module Name, Click Generate module, File
5. Open 3D Slicer in Jupyter notebook. will exist in directory, Press Restart application.
5. Click the welcome to slicer menu, Pick MATLAB,
Press FirstMatlabModule.
6. Download the data of interest (For example,
Download MR Head), click clinical sample data,
MATLAB, open your module.
7. Enter input volume, output volume, and apply.
8. Open your Module, click developer tools,
MATLAB, MATLAB Module Generator.
9. Copy MATLAB Script Directory and Past it on
your hard disk.
10. Exit 3D Slicer and Discard any modification.
797
IX. PROGRAMS NEEDED FOR SECONDARY MODIFICATION 2. Press import DICOM files, Navigate to the dataset
OF EXTENSION MODULES IN 3D SLICER file, Press import.
3D Slicer provides customization and extension
opportunities with an interactive console that gives all the
algorithms and data loaded. However, some programs, such
as CMake, SVN, Git, Visual Studio, and Qt, are needed to
provide a suitable environment to modify the extension
modules [11]. The CMake application is used to solve the
problem arising from multiple compilers used to program 3D
Slicer. It generates a Makefile or Project file, which describes
all platforms’ construction processes [11]. SVN software
stores data and marks changes made to code, allowing the
restoration of previous versions [11]. Git is open-source,
which is used to manage software versions. Visual Studio is
needed for compilation, debugging, and packaging of the 3. Click on the file, then press load.
developed source code for 3D Slicer [11]. Lastly, the Qt
program allows component programming and is mainly used
to modify the interface module [11]. CMake, SVN, Git, Visual
Studio, and Qt software are needed before changing 3D Slicer
extension modules.
X. HOW TO CODE 3D SLICER USING COMMAND LINE
INTERFACE?
One of the 3D Slicer program’s main goals is to provide
biomedical engineers, software developers, and researchers
with an opportunity for quick prototyping and development of
images for analysis. Therefore, the tool is open and ex-
tensive, with interfaces and design patterns to introduce new 4. The screen after loading the dataset.
functionalities [4]. The key user-level features for modifying
the software include DICOM and CLI [4]. The extension code
is divided into Python loadable and the C++ CLI module [14].
The former type is detailed later in the study. The C++ CLI
module is used for batch processing of input information.
Thus, it is limited to the basic input-output setup, where the
inputs are the command line parameters [14]. It is also
restricted to one-time processing. However, C++ CLI
supports easy prototyping by developers. The C++ CLI
module allows developers to modify or develop new
extension through an input-output phase, which is easier to
implement, but it enables only one batch processing at a time.
The steps are:
5. Use the Command Phase for different rendering and
1. Open 3D Slicer software, Press load DICOM data. manipulation.
798
XI. MODIFYING EXTENSION MODULES IN 3D SLICER The second step involves compiling and generating the
downloaded source code. The procedure can be undertaken
The leading coding languages used for 3D Slicer are C++ using either QT, VS, Git, CMake, SVN, or NSIS [7]. After
and Python. However, it provides a secondary extension that, the CMAKE software (Figure 5) should be used to
module, enabling users to customize the platform’s functions resolve issues arising from multiple compilers [18]. A
and appearance. 3D Slicer allows users to modify the software developer uses the CMake GUI to generate VS project files
to suit different applications. Optimizing the software to cater through the following paths:
to the medical equipment requirements require developers to
be highly accurate at higher speeds and maintain maximum • Where the source code is: sets the path to the
safety during the process. However, the modification process downloaded source code.
is complicated, and a suitable procedure has been proposed • Where to build the binaries is: sets the space for
[11]. The recommended steps for customizing 3D Slicer building and storing a project.
software include GitHub download, CMAKE compilation,
and generation and package phases. One acquires source code
from GitHub or SVN as the initial step outlined by [11].
However, the developer should configure Git before
downloading open software on GitHub [7]. The software
should then be installed. The machine information should be
set to be utilized by all Git repositories using the following
code:
$git config–globaluser.name”username”
$git config–[email protected]
Then, utilize the following code to create a version library:
1. Create an empty directory
$mkdir mymenu
$cd mymenu
$pwd /Users/ibahkali/mymenu
2. Initialize the warehouse git init
$git init “Initialized empty Git repository” in:
/Users/ibahkali/mymenu/.git/
Lastly, search the source code, select Clone or download,
copy the link, open GitBash, type git after $, put the URL, and
press download. The download process is summarized in
Figure 4.
Figure 5. CMake window for path configuration.
The third step is undertaken after the compilation using
Visual Studio to generate and debug the code, which might
exist or not as a packaged project. The fourth and last phase
involves packaging the software. The file might be in
packaged or unpackage formats. In the former case, then the
file can be produced directly. However, it cannot directly be
created if it is not packaged because it is located in the
SlicerDMRI.sln file [11]. Clicking the Edit, Application
Settings, Modules enables easy importation of the packaged
folder [11]. The modules can then be opened and modified
according to a user’s preference. Figure 6 summarizes the
tools and steps needed when undertaking extension module
modification in 3D Slicer.
Figure 4. The process of downloading a source code in GitHub
799
REFERENCES
[1] M. Bustamante, "Detection and Quantification of Small Changes in
MRI Volumes," 2014.
[2] D. Chalupa, and J. Mikulka, "A novel tool for supervised segmentation
using 3D slicer," Symmetry, 2018, pp. 627.
[3] B. E. Chapman, J. A. Roberts, and A. Sorenson, "Scientific Session
Posters and Demonstrations Creating an Open Source Infrastructure for
Image Phenotyping in Clinical Research," SIIM, 2017.
[4] A. Fedorov, R. Beichel, J. Kalpathy-Cramer, J. Finet, JC. Fillion-
Robin, S. Pujol, C. Bauer, D. Jennings, F. Fennessy, M. Sonka, and J.
Buatti. "3D Slicer as an image computing platform for the Quantitative
Imaging Network," Magnetic resonance imaging, 2012, pp.1323-1341.
[5] J. L. Forbes, "Developmentand Verification of Medical Image
Analysis Tools Within the 3D Slicer Environment," 2016.
[6] D. T. Gering, "A system for surgical planning and guidance using
image fusion and interventional MR," (Doctoral dissertation,
Massachusetts Institute of Technology), 1999.
[7] S. Jin, G. Yu, J. Song, J. Chang, J. Cui, "Development environment
construction of medical imaging software 3d slicer," Journal of
Complexity in Health Sciences, 2020, pp. 43-51.
[8] T. Kapur, S. Pieper, A. Fedorov, JC. Fillion-Robin, M. Halle, L.
O'Donnell, A. Lasso, T. Ungi, C. Pinter, J. Finet, S. Pujol, "Increasing
the impact of medical image computing using community-based open-
Figure 6. Tools and steps when undertaking extension module access hackathons," The NA-MIC and 3D Slicer experience, 2016, pp.
modification in 3D Slicer. 176-180.
[9] A. Lasso, K. Alexander, C. Jechel, K. Wang, J. Schreiner, G.
Fichtinger, "Running Matlab® functions in 3D Slicer using
XII. CONCLUSION MatlabBridge," Imaging Network Ontario, 2015, pp. 78.
3D Slicer is an important software, especially in the medical www.imno.ca/sites/default/files/2014Proceedings.pdf. Accessed 4
Nov 2020.
field, because it analyzes sophisticated data through
[10] B. C. Lowekamp, D. T. Chen, L. Ibáñez, D. Blezek, "The design of
visualization. The software reduces costs and promotes SimpleITK," Frontiers in neuroinformatics, 2013, pp. 45.
surgical operations safety, which has increased its popularity [11] L. Ma, C. Zhang, W. Wu, J. Chang, J. Cui, "Secondary development
in medical applications. 3D Slicer is coded mainly using C++ based on 3D Slicer extension modules," Journal of Complexity in
and Python programming languages. However, it provides a Health Sciences, 2020, pp. 73-80.
secondary extension module, enabling users to customize the [12] N. Bruns, "3D Slicer: Universal 3D Visualization Software," Der
Unfallchirurg, 2019, pp. 662-663.
platform’s functions and appearance. In this regard, the study
[13] F. Pye, N. B. Raja, B. Shirley, Á. T. Kocsis, N. Hohmann, D. JE.
was undertaken to investigate how a coding environment can Murdock, and E. Jarochowska, "ImageJ and 3D Slicer: open source
be created using different languages to modify the 3D Slicer 2/3D morphometric software," PeerJ Preprints, 2019.
program and its several paths. It was established that the [14] T. Michalík, "Software pro stereotaktickou navigaci v
software could be optimized to meet medical equipment epileptochirurgii," 2019.
requirements, which need high accuracy, speed, and safety. [15] S. Vijayan, S. S. Melo, S. Anamali-Allareddy, F. B. Teixeira, and V.
However, the modification process is complicated, and a Allareddy, "Segmenting Root Canal Systems Using an Open Source
Slicer Software," Oral Surgery, Oral Medicine, Oral Pathology and
suitable procedure was proposed. The recommended steps for Oral Radiology, 2019, pp. 48-49.
customizing 3D Slicer software include GitHub download, [16] Y. Muyi, "Medical image segmentation algorithm based on 3D slicer
CMAKE compilation, and generation and package phases. By and its application." Electronic World, 2016, pp. 14-15.
using a MatlabBridge extension, MATLAB’s functions can be [17] Z. Yaniv, B.C. Lowekamp, H.J. Johnson, and R. Beare, "SimpleITK
accessed and employed within a 3D Slicer environment, image-analysis notebooks: a collaborative environment for education
enabling faster and simple prototyping. The Python language and reproducible research," Journal of digital imaging, 2018, pp.290-
303.
can also customize 3D Slicer because its API is done in
[18] J. Yu, X. Li, Z. Wu, "Design and Implementation of Compiler Theory
Python wrapper. Moreover, the Jupyter language can be Demo Module," Research and Exploration in Laboratory, 2018, pp. 36.
implemented in 3D Slicer by following a GitHub centric [19] X. Zhang, K. Zhang, Q. Pan, J. Chang, "Three-dimensional
workflow, where new codes are created using the topic reconstruction of medical images based on 3D slicer," Journal of
branch-based git strategy. The CLI approach can also be used Complexity in Health Sciences, 2019, pp. 1-2.
to customize the 3D Slicer through input and output strategy, [20] X. Zhou, J. Wang, M. Guo, Z. Gao, "Cross-platform online
visualization system for open BIM based on WebGL," Multimedia
which is easier but limited to one batch processing at a time. Tools and Applications, 2019, pp. 28575-28590.
In this paper, we explained these several paths for using 3D
Slice so that the usage of 3D Slicer could be more
commonplace and grow further.
800