A User-Friendly, Multi-Lingual Library for Medical Image Registration
Total Page:16
File Type:pdf, Size:1020Kb
SimpleElastix: A user-friendly, multi-lingual library for medical image registration Kasper Marstal1, Floris Berendsen2, Marius Staring2 and Stefan Klein1 1Biomedical Imaging Group Rotterdam (BIGR), Department of Radiology & Medical Informatics, Erasmus Medical Center, PO Box 2040, Rotterdam, 3000 CA, the Netherlands, fkmarstal,[email protected] 2Division of Image Processing (LKEB), Department of Radiology, Leiden University Medical Center, PO Box 9600, 2300 RC Leiden, the Netherlands, ff.berendsen,[email protected] Abstract import SimpleITK as sitk resultImage = sitk.Elastix( sitk.ReadImage("fixedImage.nii"), In this paper we present SimpleElastix, an extension of sitk.ReadImage("movingImage.nii") SimpleITK designed to bring the Elastix medical image reg- ) istration library to a wider audience. Elastix is a modular Listing 1: Medical image registration in Python using collection of robust C++ image registration algorithms that SimpleElastix. is widely used in the literature. However, its command-line interface introduces overhead during prototyping, experi- mental setup, and tuning of registration algorithms. By in- tegrating Elastix with SimpleITK, Elastix can be used as a oping the registration algorithms themselves. However, less native library in Python, Java, R, Octave, Ruby, Lua, Tcl research has focused on accessibility, interoperability and and C# on Linux, Mac and Windows. This allows Elastix to extensibility of these algorithms. Scientific source code is intregrate naturally with many development environments typically not published [16], is lacking documentation or is so the user can focus more on the registration problem and difficult to use because it has not been written with other less on the underlying C++ implementation. As means researchers in mind. This is a problem since image regis- of demonstration, we show how to register MR images of tration is a prerequisite for a wide range of medical image brains and natural pictures of faces using minimal amount analysis tasks and a key algorithmic component for image- of code. SimpleElastix is open source, licensed under the based studies. Open source, user-friendly implementations permissive Apache License Version 2.0 and available at of scientific software make state-of-the-art methods accessi- https://github.com/kaspermarstal/SimpleElastix. ble to a wider audience, promote opportunities for scientific advancement, and support the fundamental scientific prin- ciple of reproducibility. To this end, we have developed the 1. Introduction SimpleElastix software package. In the past decade there has been an increasing interest in Elastix [19] is an open source, command-line program relating information from different medical images spurred for intensity-based registration of medical images that al- by a growing availability of scanners, modalities and com- lows the user to quickly configure, test, and compare dif- puting power. This typically involves image registration ferent registration methods. SimpleElastix is an extension for transforming images into a common coordinate sys- of SimpleITK [21] that allows the user to configure and tem so corresponding pixels represent homologous biolog- run Elastix entirely in Python, Java, R, Octave, Ruby, Lua, ical points. Clinical applications include segmentation of Tcl and C# on Linux, Mac and Windows. In addition, we anatomical structures, computer-aided diagnosis, monitor- have developed an extensive test suite, online documenta- ing of disease progression, surgical intervention and treat- tion, and a citable online software repository following rec- ment planning. ommended best practices for scientific software publication A significant amount of research has focused on devel- [24], all within an online environment that stimulates com- 1 Figure 1: Example of two registered images from the Hammersmith83 dataset using default registration procedure as shown in Listing 1. Checkerboard pattern of fixed and result images (left) and overlay of associated segmentations (right). munity involvement and contribution. SimpleElastix also tration libraries, discuss their influence on the design of includes SimpleTransformix, an accompanying program for SimpleElastix, and present the contributions that enable subsequent warping of images, point sets and segmentations SimpleITK to link Elastix with other programming lan- using transformation fields computed with SimpleElastix. guages. We then outline the continuous integration (CI) The software contributions are three-fold. testing framework, online documentation framework and online contribution process. Finally, we apply a built-in pre- • A low-level ITK-filter-based C++ interface for Elastix configured registration method to MR images of brains and and Transformix. 2D natural pictures of faces. The focus of the paper is on • A facade interface to these filters that enables Sim- reducing complexity of experimental setups for typical im- pleITK to build Elastix and Transformix bindings for age registration problems. All experiments in this paper are Python, Java, R, Ruby, Octave/Matlab, Lua, Tcl and available online. C# on Linux, Mac and Windows. 1.1. Previous Work • Preconfigured registration methods that serve as start- A number of open source libraries are available online ing points for tuning registration algorithms to domain- and the scientific community has been thriving around the specific applications. use of these tools. The National Library of Medicine’s In- Together, these contributions lower the entry barrier for per- sight Segmentation and Registration Toolkit (ITK) is a col- forming image registration. For example, Figure 1 shows a lection of methods for image filtering, segmentation and registration of two brains from a publicly available data set registration. It is widely regarded as the standard reference consisting of 30 adult atlases each with 83 segmented re- for many medical image processing algorithms. Elastix is gions [14] using the method in Listing 1. A Dice Similarity based on ITK’s v3 registration framework [18] and makes Coefficient (DSC) of 0:92 was obtained for the total brain extensive use of ITK’s data structures for images, points, volume and a mean DSC of 0:74 was obtained for the indi- spatial objects, and several basic image processing compo- vidually labeled regions for this particular example. In the nents such as filtering, morphological operations, and in- experiments section we present the full setup used to obtain terpolation schemes. Elastix adds an additional configura- these results. tion layer that allows registration algorithms to be config- The remainder of the paper is laid out as follows. First, ured via text-based files. This allows users without expert we introduce previous open source medical image regis- programming knowledge to compare different registration algorithms. However, command-line scripting and man- ual editing of text-files typically needed for using Elastix in larger studies makes experimentation time-consuming, dif- ficult to reproduce and hard to maintain. Recently, there has been considerable interest in devel- oping bindings for other languages in order to streamline the use of ITK and bring its algorithms to a wider audi- ence. The SimpleITK project [21] was developed specifi- cally with usability in mind to overcome the steep learning curve of previous ITK wrapping efforts like WrapITK for Python, Java and Tcl [2] and ManagedITK for the .NET lan- guage family [23]. SimpleITK exposes simplified, native interfaces to ITK algorithms in a variety of scripting lan- guages following the facade design pattern [9]. Each ITK Figure 2: Software architecture of SimpleElastix. Three algorithm is wrapped in facade bindings that hide imple- layers are built on top of Elastix, each wrapping the layer mentation details such as the use of templates and the ITK below. ITK filters control the elastix library, facade classes pipeline architecture. This allows a user to setup an ITK provide a simplified interface to ITK filters and SimpleITK pipeline in a programming environment of their choice and uses the facade classes to generate and compile code for without knowing anything about the underlying C++ imple- target languages. mentation. For example, a researcher may choose to proto- type image processing pipelines in high-level scripting lan- 2. Method guages like Python, R or Octave and enterprise developers may choose to develop distributed computing software in The proposed software package consists of three layers languages like Java or C#. In this work we aim to bring the on top of the Elastix library as depicted in Figure 2. The first same level of versatility, convenience, and user-friendliness layer is an ITK filter-based C++ API that enables Elastix to to the Elastix community. be used in a regular ITK pipeline. The filter is templated Libraries such as Nipype [10] and ElastixFromMatlab over pixel types and dimensions of both the fixed and mov- [8] provide command-line wrappers for Elastix. Nipype ing images. The second layer consist of two facade C++ is a Python library that facilitates comparison stud- classes, one for Elastix and one for Transformix, that de- ies by providing uniform access to many popular im- fine the external interface in target languages. This layer age processing frameworks including ANTs, SPM, FSL, also hides the internal Elastix and Transformix filters and FreeSurfer, Camino, MRtrix, MNE, AFNI, Slicer and holds methods for passing data between SimpleITK and Elastix. ElastixFromMatlab makes it easier to use Elastix Elastix.