software developer’s quarterly issue 12 jan 2010 · • the ray that was cast to obtain the point...

16
SOFTWARE DEVELOPER’S QUARTERLY Editor’s Note ........................................................................... 1 Recent Releases ..................................................................... 1 A Synthetic LiDAR Scanner for VTK ..................................... 3 New Variational Level-Set Classes with Region Fitting Energy in ITK ......................................................................... 6 Alternative Memory Models for ITK..................................... 9 N3 Implementation for MRI Bias Field Correction ............ 11 Exporting Contours to DICOM-RTSTRUCT ......................... 13 Kitware News ...................................................................... 15 Kitware is pleased to present a special edition of the Source which features several of the strongest Insight Journal submissions from 2009. The Insight Journal was designed to provide a realistic support system for disseminating sci- entific research in the medical image processing domain. Recognizing the need for a mechanism whereby the medical image analysis community can collectively share their ideas, code, data and results, Dr. Luis Ibàñez has worked with the ISC and championed the open-science cause to make the Insight Journal a reality. By providing a platform for open-access scientific publica- tion, Kitware continues to foster its commitment to the open-science community. To continue celebrating this cause we will annually publish this special Insight Journal Edition of the Source. Anyone may submit their work to the Insight Journal by registering, for free, at insight-journal.org; perhaps your work will be featured here next year! The Kitware Source is just one of a suite of products and services that Kitware offers to assist developers in getting the most out of its open-source products. Each project’s website contains links to free resources including mailing lists, documentation, FAQs and Wikis. In addition, Kitware supports its open-source projects with technical books, user’s guides, consulting services, support contracts and training courses. For more information on Kitware’s suite of products and services, please visit our website at www.kitware.com. Issue 12Jan 2010 MIDAS 2.4 RELEASED AS OPEN SOURCE Kitware is proud to announce the release of MIDAS 2.4, a major release implementing more than 20 new features. We are also happy to announce that the MIDAS source-code is now freely available under an unrestricted (BSD) license. Improved image gallery with color selection For the past year MIDAS, Kitware’s digital archiving and distributed processing system, has been generating a lot of interest from the research community and we believe that opening its source code will lead to a better archiving and processing system. We encourage users to download the latest release and join the mailing list. Among the new features of the 2.4 release: Redesigned image gallery Improved LDAP support Support for plug-ins Improved server-side upload Custom upload workflows Better BatchMake integration with custom reporting Kitware’s public instance of MIDAS is available at http:// insight-journal.org/midas, and is currenlty host to hundreds of freely available scientific and medical datasets. MIDAS can be downloaded from kitware.com/midas. CDASH 1.6 CDash, the open-source, web-based software testing server has had another major release. CDash aggregates, analyzes

Upload: others

Post on 27-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

S O F T W A R E D E V E L O P E R ’ S Q U A R T E R L Y

Editor’s Note ........................................................................... 1

Recent Releases ..................................................................... 1

A Synthetic LiDAR Scanner for VTK ..................................... 3

New Variational Level-Set Classes with Region Fitting

Energy in ITK ......................................................................... 6

Alternative Memory Models for ITK..................................... 9

N3 Implementation for MRI Bias Field Correction ............ 11

Exporting Contours to DICOM-RTSTRUCT ......................... 13

Kitware News ...................................................................... 15

Kitware is pleased to present a special edition of the Source which features several of the strongest Insight Journal submissions from 2009. The Insight Journal was designed to provide a realistic support system for disseminating sci-entific research in the medical image processing domain. Recognizing the need for a mechanism whereby the medical image analysis community can collectively share their ideas, code, data and results, Dr. Luis Ibàñez has worked with the ISC and championed the open-science cause to make the Insight Journal a reality.

By providing a platform for open-access scientific publica-tion, Kitware continues to foster its commitment to the open-science community. To continue celebrating this cause we will annually publish this special Insight Journal Edition of the Source. Anyone may submit their work to the Insight Journal by registering, for free, at insight-journal.org; perhaps your work will be featured here next year!

The Kitware Source is just one of a suite of products and services that Kitware offers to assist developers in getting the most out of its open-source products. Each project’s website contains links to free resources including mailing lists, documentation, FAQs and Wikis. In addition, Kitware supports its open-source projects with technical books, user’s guides, consulting services, support contracts and training courses. For more information on Kitware’s suite of products and services, please visit our website at www.kitware.com.

Issue 12• Jan 2010

MIDAS 2.4 RELEASED AS OPEN SOURCEKitware is proud to announce the release of MIDAS 2.4, a major release implementing more than 20 new features. We are also happy to announce that the MIDAS source-code is now freely available under an unrestricted (BSD) license.

Improved image gallery with color selection

For the past year MIDAS, Kitware’s digital archiving and distributed processing system, has been generating a lot of interest from the research community and we believe that opening its source code will lead to a better archiving and processing system. We encourage users to download the latest release and join the mailing list.

Among the new features of the 2.4 release:• Redesigned image gallery• Improved LDAP support• Support for plug-ins• Improved server-side upload• Custom upload workflows• Better BatchMake integration with custom reporting

Kitware’s public instance of MIDAS is available at http://insight-journal.org/midas, and is currenlty host to hundreds of freely available scientific and medical datasets.

MIDAS can be downloaded from kitware.com/midas.

CDASH 1.6CDash, the open-source, web-based software testing server has had another major release. CDash aggregates, analyzes

A Synthetic lidar scanner for vtk

Page 2: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

2

and displays the results of software testing processes sub-mitted from clients around the world, conveying the state of a software system to continually improve its quality. This release adds more than 20 new features including:• Support for persistent login• Better database compression• New graphs and reports• Improved coverage visualization• Better CTest communication• Expected submission time based on historic average• Faster load of the main dashboard page• Improved navigation links• Remote build management (beta)

To get started with CDash, host your project for free at my.cdash.org. For more info on CDash 1.6 visit cdash.org.

ITK 3.18ITK 3.18 will be released in early 2010. The main changes in this release include improvements in the following areas:• Support for mathematical routines in itkMath• Management of integer rounding and casting• 64-bit platform support, particularly Windows and Mac• Consistency in streaming large image files• Infrastructure for running many tests in parallel (ctest -jN)

in addition to:• Added options for installing ITK in a flat directory. This will

facilitate the use of ITK from external projects.• Fixes for the Mattes Mutual Information Metric enabling

this metric to work on binary images.

For up-to-date information on ITK 3.18, please visit the ITK mailing lists or search the ITK Wiki for “Release 3.18”.

PARAVIEw 3.6.2Kitware, Sandia National Laboratories and Los Alamos National Lab are proud to announce the release of ParaView 3.6.2. The binaries and sources are available for download from paraview.org. ParaView 3.6.2 contains the following new features and improvements.

The Python interface has been revamped, an exciting new extension to the Paraview Python interface is Python trace. The goal of trace is to generate human readable, not overly verbose, Python scripts that mimic a user’s actions in the GUI. See the “Python Trace” article on page 6 of the October 2009 Kitware Source for more details.

A collection of statistics algorithms is now available. Using these statistics algortihms, you can compute descriptive statistics (mean, variance, min, max, skewness, kurtosis), compute contingency tables, perform k-means analysis, examine correlations between arrays, and perform princi-pal component analysis on arrays. More information about these filters is available on the ParaView Wiki by searching “Statistical Analysis”.

This release also Includes the VisTrails Provenance Explorer plugin in Windows and Linux packages. VisTrails is an open-source, scientific workflow and provenance management system developed at the University of Utah that provides support for data exploration and visualization. The VisTrails Plug-in brings provenance tracking and the benefits of prov-enance to ParaView users. It automatically and transparently tracks the steps a user follows to create a visualization.

In contrast to the traditional undo/redo stack, which is cleared whenever new actions are performed, the plugin captures the complete exploration trail as a user explores different parameters and visualization techniques. A tree-based view of the history of actions allows a user to return to a previous version in an intuitive way, undo bad changes, compare different visualizations, and be reminded of the actions that led to a particular result.

There is no limit on the number of operations that can be undone, no matter how far back in the history of the visual-ization they are, and the history is persistent across sessions.

The VisTrails plugin can save all of the information needed to restore any state of the visualization in .vt files, which can be reloaded across ParaView sessions and shared among collaborators. This also allows multiple visualizations to be shared with a single file. For more information on the VisTrails Provenenance Explorer Plugin see page 8 of the July 2009 Kitware Source.

LANL’s cosmo plug-in is now distributed with ParaView. This plug-in allows ParaView to read and process *.cosmo format files, in which particles are described by mass, velocity and identification tags. These particles typically represent stellar masses. The halo finder filter is a friend-of-a-friend particle clustering algorithm. It creates groups containing particles that satisfy a tolerance/threshold linking distance criterion. The cosmology data format, halo finding algorithm, and related (experimental) filter implementations are made possible by the LANL cosmology researchers, the LANL visu-alization team, and international collaborators.

Mac application bundle and comand line tools are now built as universal binaries (PPC and Intel i386). This simplifies man-aging ParaView on Mac as now there is only a single binary to download for any architecture.

As always, we rely on your feedback to improve ParaView. We are experimenting with a new user-feedback mecha-nism. Please use http://paraview.uservoice.com/ or click on the “Tell us what you think” link of paraview.org to leave your feedback and vote for new features.

ParaView 3.6.2 demonstrating the VisTrails Provenance Explorer plugin for scientific workflow and provenance management.

Page 3: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

3

A SyNTHETIC LIDAR SCANNER FOR VTKIn recent years, Light Detection and Ranging (LiDAR) scanners have become more prevalent in the scientific community. They capture a “2.5-D” image of a scene by sending out thousands of laser pulses and using time-of-flight calcula-tions to determine the distance to the first reflecting surface in the scene. However, they are still quite expensive, limiting the availability of the data which they produce. Even if a LiDAR scanner is available to a researcher, it can be quite time consuming to physically set up a collection of objects and scan them.

Here, we present a set of classes which allow researchers to compose a digital scene of 3D models and ”scan” the scene by finding the ray and scene intersections using techniques from ray tracing. This allows researchers to quickly and easily produce their own LiDAR data. The synthetic LiDAR scan data can also be used to produce datasets for which a ground truth is known. This is useful to ensure algorithms are behav-ing properly before moving to non-synthetic LiDAR scans. If more realistic data is required, noise can be added to the points to attempt to simulate a real LiDAR scan.

SCANNER MODELWe have based the synthetic scanner on the Leica HDS3000 LiDAR scanner. This scanner acquires points on a uniform angular grid. The first point acquired is in the lower left of the grid. The scanner proceeds bottom to top, left to right. The order of acquisition is usually not important, but the code could be easily changed to mimic a different scanner if desired.

INPUT PARAMETERSIt is necessary to set several parameters before performing a synthetic scan. These parameters are:• A scene to scan (triangulated 3D mesh)• Scanner position (3D coordinate)• Min/Max ϕ angle (how far ”up and down” the scanner

should scan)• Min/Max θ angle (how far ”left and right” the scanner

should scan)• Scanner “forward” (the ϕ = 0, θ = 0 direction)• Number of θ points.• Number of ϕ points.

OUTPUTSTwo outputs are possible depending on the user’s require-ments. The first is a PTX file. A PTX file implicitly maintains the structure of the scan. The scan points in the file are listed in the same order as they were acquired. This point list, together with the size of the scan grid, is sufficient to repre-sent the grid of points acquired by the synthetic scanner.

The second type of output is simply an unorganized point cloud stored in a VTP file. This representation is useful for algorithms which do not assume any structure is known about the input.

NEw CLASSESWe introduce three new classes to implement a synthetic LiDAR scanner. The first two, vtkRay and vtkLidarPoint are supporting classes of vtkLidarScanner, which is the class that does the majority of the work.

vtkRayThis is a container class to hold a point (ray origin) and a vector (ray direction). It also contains functions to:• Get a point along the ray a specified distance from the

origin of the ray (double* GetPointAlong(double))• Determine if a point is in the half-space that the ray is

pointing “toward“ (bool IsInfront(double*))• Transform the ray (void ApplyTransform (vtkTransform* Trans))

vtkLidarPointThis class stores all of the information about the acquisition of a single LiDAR point. It stores:• The ray that was cast to obtain the point (vtkRay* Ray)• The coordinate of the closest intersection of the ray with

the scene (double Coordinate[3])• The normal of the scene triangle that was intersected to

produce the point (double Normal[3])• A boolean to determine if the ray in fact hit the scene at

all (bool Hit)

vtkLidarScanner This class does all the work of acquiring the synthetic scan.

Coordinate SystemThe default scanner is located at (0,0,0) with the following orientation:• Z axis = (0,0,1) = up• Y axis = (0,1,0) = forward• X axis = (1,0,0) = right (a consequence of maintaining a

right handed coordinate system)

Positioning (“aiming”) a vtkLidarScannerA rigid transformation can be applied to the scanner via the SetTransform function which positions and orients the scanner relative to the scene.

Casting RaysRays cast by the scanner are relative to the scanner’s frame after the transformation is applied to the default frame.

Figure 1: 3D view of the scan.

To demonstrate the angles which must be specified, a (ϕ = 5; θ = 4) scan of a flat surface was acquired, as shown in Figure 1. Throughout these examples the red sphere indi-cates the scanner location, cylinders represent the scan rays, and blue points represent scan points (intersections of the rays with the object/scene).

Page 4: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

4

Order of AcquisitionThe points were acquired in the order shown in Figure 2.

Figure 2: Scan points labeled in acquisition order.

Theta angleThe angle in the Forward-Right plane (a rotation around Up), measured from Forward. Its range is -π to π. – is left,

is right.

Figure 3 shows a top view of the scan of a flat surface. The min and max θ angles are labeled.

Figure 3: Diagram of Theta angle settings.

Phi angleThe elevation angle, in the Forward-Up plane (a rotation around Right), measured from Forward. Its range is – (down) to (up). This is obtained by rotating around the “right” axis (AFTER the new right axis is obtained by setting Theta).

Figure 4 shows a side (left) view of the scan of a flat surface. The min and max ϕ angles are labeled

Figure 4: Diagram of Phi angle settings.

NormalsEach LiDAR point stores the normal of the surface that it intersected. A scan of a sphere is shown in Figure 5 to dem-onstrate this. The normal vector coming from the scanner (red sphere) is the “up” direction of the scanner.

OUTPUTSvtkPolyDataA typical output from a VTK filter is a vtkPolyData. The vtkLidarScanner filter stores and returns the valid LiDAR returns in a vtkPolyData. If the CreateMesh flag is set to true, a Delaunay triangulation is performed to create a tri-angle mesh from the LiDAR points. vtkDelaunay2D is used to triangulate the 3D points utilizing the grid structure of the scan. Figure 6 shows the setup of a scan, the result with CreateMesh = false, and the result with CreateMesh = true.

Figure 5: Scene intersections and their normals

PTX fileAll of the LiDAR ray returns, valid and invalid, are written to an ASCII PTX file. The PTX format implicitly maintains the order of point acquisition by recording the points in the same order in which they were acquired. A “miss” point is recorded as a row of zeros. Upon reading the PTX file (not covered by this set of classes), the best test to see if a row of the file is valid is checking if the intensity of the return is 0. This prevents corner cases, such as a valid return from (0;0;0), from creating a problem or confusion.

Scanner coordinate frameUsing void vtkLidarScanner::WriteScanner(const std::string &Filename) const, a VTP file of the scanner can be written. A coordinate frame indicates the location and orientation of the scanner. The green axis is “up”, the yellow axis is “forward” and the red axis is “right”. Figure 7 shows the synthetic scan of a sphere along with the scanner that was used to perform the scan.

DATA STRUCTURE SPEED UPInstead of intersecting each ray with every triangle in the scene, this problem immediately lends itself to using a spatial data structure to achieve an enormous speedup. We originally tried an octree (vtkOBBTree), but we found that a modified BSP tree (vtkModifiedBSPTree) gives a 45x speedup, even over the octree! The current implementation includes this speed up and is therefore very fast.

Page 5: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

5

Figure 6: Effect of CreateMesh flag.

Figure 7: Synthetic scan of a sphere with the scanner displayed

NOISE MODELBy default, a synthetic scan is “perfect” in the sense that the scan points actually lie on a surface of the 3D model as in Figure 8. In a real world scan, however, this is clearly not the case. To make the synthetic scans more realistic, we have modeled the noise in a LiDAR scan using two independent noise sources: line-of-sight and orthogonal.

Line-of-Sight (LOS) NoiseLine-of-Sight noise reads as an error in the distance mea-surement performed by the scanner. It is a vector parallel to the scanner ray whose length is chosen randomly from a

Gaussian distribution. This distribution is zero mean and has a user specified variance (double LOSVariance). An example of a synthetic scan with LOS noise added is shown in Figure 9. The important note is that the orange (noisy) rays are exactly aligned with the gray (noiseless) rays.

Figure 8: A noiseless synthetic scan

Figure 9: A synthetic scan with line-of-sight noise added

Orthogonal NoiseOrthogonal noise models the angular error of the scanner. It is implemented by generating a vector orthogonal to the scanner ray whose length is chosen from a Gaussian distri-bution. This distribution is also zero mean and has a user specified variance (double OrthogonalVariance). An example of a synthetic scan with orthogonal noise added is shown in Figure 10. Note that the green (noisy) rays are not aligned with the gray (noiseless) rays, but they are the same length.

Combined NoiseA simple vector sum is used to combine the orthogonal noise vector with the LOS noise vector.

Figure 10: A synthetic scan with orthogonal noise added

Page 6: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

6

EXAMPLE SCENEAs an example, a car model with 20k triangles was scanned with a 100x100 grid. On a P4 3GHz machine with 2GB of ram, the scan took 0.6 seconds. Figure 11 shows the model and the resulting synthetic scan.

Figure 11: A car model and the resulting synthetic scan.

EXAMPLE CODEAn example (TestScanner.cpp) is provided with the code zip file, but the basics are demonstrated here below with hard coded values:

//read a scenevtkXMLPolyDataReader* reader = vtkXMLPolyDataReader::New();reader->SetFileName(InputFilename.c_str());reader->Update();

//construct a vtkLidarScannervtkLidarScanner* Scanner = vtkLidarScanner::New();

//Set all of the scanner parameters

Scanner->SetPhiSpan(vtkMath::Pi()/4.0);Scanner->SetThetaSpan(vtkMath::Pi()/4.0);

Scanner->SetNumberOfThetaPoints(5);Scanner->SetNumberOfPhiPoints(6);

Scanner->SetStoreRays(true);

//”Aim” the scanner. This is a very simple //translation, but any transformation will workvtkTransform* transform = vtkTransform::New(); transform->PostMultiply();//this is so we can specify the operations in the//order they should be performed (i.e. this is a //rotation followed by a translation)

//(any of these 4 lines can be ommited if they //are not required)transform->RotateX(0.0);transform->RotateY(0.0);transform->RotateZ(1.0);transform->Translate(Tx, Ty, Tz);

Scanner->SetTransform(transform);//indicate to use uniform spherical spacing

Scanner->MakeSphericalGrid();

Scanner->SetCreateMesh(true);

Scanner->SetInput(reader->GetOutput());Scanner->Update();

//create a writer and write the output VTP filevtkSmartPointer<vtkXMLPolyDataWriter> writer = vtkSmartPointer<vtkXMLPolyDataWriter>::New();writer->SetFileName(“test_scan.vtp”);writer->SetInput(Scanner->GetOutput());writer->Write();

David Doria is a PhD student in Electrical Engineering at Rensselaer Polytechnic Institute. He received his BS in EE in 2007 and his MS in EE in 2008, both from RPI. David is currently working on 3D object detection in LiDAR data. He is passionate about reducing the barrier of entry into 3D

data processing. Find out more about David on his website rpi.edu/~doriad or email him at [email protected].

NEw VARIATIONAL LEVEL-SET CLASSES wITH REGION FITTING ENERGy IN ITK

The level-set methodology involves numerically evolving a contour or surface according to a rate change partial differ-ential equation (PDE). The contour or surface is embedded as the zero level-set of a higher dimensional implicit func-tion, also called the level-set function (x,t). Other techniques in the literature with the same objec-tive include snakes and parametric surfaces. The main advantage of using level-set techniques over other methods is that they can handle complex shapes and topological changes, such as merging and splitting, with ease. Different constraints on the contour smoothness, speed, size and shape are easily specified.

Level-sets are very popular in the image analysis community for use in image segmentation, smoothing and tracking problems. There are two main classes of the level-set meth-odology - explicit and implicit methods. The explicit methods have a generic PDE to determine the temporal rate of change in the level-set function. It is expressed as a sum of speed functions that contain propagation, smoothing, and advection terms. Each of these terms is constructed from the image intensity function and involves the usage of image gradients. Segmentation is accomplished by detecting edges in the object of interest. Hence, these techniques are also referred as edge-based level-sets.

Implicit level-sets are driven by PDE that is derived by using a variational formulation. Here, an energy functional is first constructed and then minimized. An example of such a variant is that proposed by Chan and Vese [1]. In this variant, objects are segmented in images where edge information may be poor or entirely absent. The core idea is that the region statistics of the foreground region is much different from the background region. The region mean intensity is a popularly used statistic for segmentation as shown in Figure 1. These techniques are also referred to as region-based or active contours without edges. The current level-set frame-work in ITK is completely explicit with no support for the

Page 7: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

7

implicit techniques; for more information, see our submis-sions to the Insight Journal [4], [5] and [6].

(a) Dense filter iterations at 0, 10, 20 and 30

(b) Sparse filter iterations at 0, 10, 20 and 30.

Figure 1: Implicit segmentation of cells using mean intensity as a region statistic to separate foreground and background (a) Top

row showing dense filter iterations and (b) bottom row showing the sparse filter iterations. Note the difference in the structures

local to initialization in the sparse case.

Normally, the solution of the level-set update equation can be done on the entire image domain. The dense filter iteratively updates every single pixel in the image regard-less of its position with respect to the zero level-set. As a result, the convergence is much quicker and structures far from the zero level-set spawn contours for segmentation. The sparse implementation of the level-set solver maintains a band of pixels around the zero level-set which are itera-tively updated. The PDE is solved exactly on those pixels that are on the zero level-set or are immediate neighbors of the zero level-set. A user-defined bandwidth of pixels is used in maintaining the level structure and for calculating the derivatives. Pixels in the image beyond this band around the zero level-set are not considered. As a result, the evolution gradually proceeds from the initialization and converges on local structures. Structures far off from the zero level-set may remain unaffected.

MULTI OBJECT SEGMENTATIONS wITH LEVEL-SETS AND KD-TREE OPTIMIZATIONSIn biomedical image analysis, we are often interested in segmenting more than a single object from a given image. This especially happens when the objects to be segmented are adjacent to each other and the delineation of one object automatically affects the neighboring object. In such situations, it makes sense to concurrently process their seg-mentation in order to optimally segment the objects. As a simple example, there is a significant interest in segmenting nuclei or cells in microscopy images as shown in Figures 5 and 6. Each image is acquired at high resolution and could contain thousands of cells. These cells often cluster in regions and appear to overlap. The challenge is to split these cells into individual components. An iterative (or linear) cell extraction procedure using level-sets can cause inconsistent splits since each level-set function does not compete with the neighboring cells. There could be an overlap of the level-set functions. In such cases, it is necessary to use multiphase methods for segmentation.

There are several research papers devoted to multiphase methods that optimize the number of level-set functions used for a generic case of N phases or objects [2]. We are largely motivated by microscopy applications where cells

are segmented and tracked with constraints placed on the area, volume and shape of each individual cell. Each cell has a unique fluorescence intensity level, therefore it is best to have a unique level-set function per cell. This is the approach adopted in the popular work by Dufour, et al. [3].

itk::MultiphaseFiniteDifferenceImageFilter< TInputImage, TOutputImage >

itk::DenseMultiphaseLevelSetImageFilter< TinputImage, TFeatureImage, TFunction, TOutputPixel >

itk::DenseSegmentationFiniteDifferenceImageFilter< TinputImage, Image< TOutputPixel, ::itk::GetImageDimension< TinputImage >::ImageDimension >>

Figure 2: Inheritance model of the dense solver

itk::MultiphaseFiniteDifferenceImageFilter< TInputImage, TOutputImage >

itk::SparseMultiphaseLevelSetImageFilter< TinputImage, TFeatureImage, TFunctionType, TOutputPixel >

itk::MultiphaseSparseFieldLevelSetImageFilter< TinputImage,Image< TOutputPixel, ::itk::GetImageDimension< TinputImage >::ImageDimension >>

Figure 3: Inheritance model of the sparse solver

itk::RegionBasedLevelSetFunction< TInputImage, TFeatureImage, TSharedData >

itk::ScalarChanAndVeseLevelSetFunction< TinputImage, TFeatureImage, TSharedData >

itk::ScalarRegionBasedLevelSetFunctionBase< TinputImage, TFeatureImage, TSharedData >>

Figure 4: Inheritance model of the region-based level-set function

Figure 5: Space optimizations. (a) ROI defined around individual cells. (b) kd-tree structure constructed from ROI centroid.

Page 8: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

8

MEMORy OPTIMIZATION USING KD-TREESComputationally, it is memory intensive to have N level-set functions defined on the image domain. For a large image with many small objects (such as cells in microscopy images), it becomes a memory-intensive problem. Hence, we make the implementation robust by defining region-of-interest (ROI), using spatial data structures such as the kd-trees and cached lookup tables.

Each level-set function is first defined in a region-of-interest (ROI) within the image domain. This is illustrated in Figure 5(a). The ROI should encompass the object to be segmented and its extent is specified by the attributes’ origin and size. The spacing is the same as the feature or raw intensity image. This saves us considerable computational memory space. The centroid of each ROI region is then placed in a kd-tree structure. In the update for each level-set function, the overlaps of ROI regions are calculated by querying the kd-tree for the k-nearest neighbors as illustrated in Figure 5(b). This saves considerable computational time. Note that there is a cost associated with building the kd-tree that can be avoided for a small number of phases. We only instantiate the kd-tree mechanism of search upon user-request, or when there are more than 20 phases involved.

USAGE EXAMPLEWe consider an example for using multiphase level-set filters. After initialization, it is imperative that the user specify the number of level-set functions and set the feature image and initialization for each level-set function. We illustrate our example for N = 3.

MultiLevelSetType::Pointer levelSetFilter = MultiLevelSetType::New(); levelSetFilter->SetFunctionCount( 3 ); levelSetFilter->SetFeatureImage( featureImage ); levelSetFilter->SetLevelSet( 0, contourImage1 ); levelSetFilter->SetLevelSet( 1, contourImage2 ); levelSetFilter->SetLevelSet( 2, contourImage3 );

Appropriate global settings of the level-set include the number of iterations, maximum permissible change in RMS values and whether to use image spacing.

levelSetFilter->SetNumberOfIterations(nb_iteration); levelSetFilter->SetMaximumRMSError( rms ); levelSetFilter->SetUseImageSpacing( 1 ); Using a for-loop over all the level-set functions, we call the i-th difference function and set the corresponding attributes of that level-set function.

for ( unsigned int i = 0; i < 3; i++ ) { levelSetFilter->GetDifferenceFunction(i)-> SetDomainFunction( &Heaviside ); levelSetFilter->GetDifferenceFunction(i)-> SetCurvatureWeight( mu ); levelSetFilter->GetDifferenceFunction(i)-> SetAreaWeight( nu ); levelSetFilter->GetDifferenceFunction(i)-> SetLambda1( l1 ); levelSetFilter->GetDifferenceFunction(i)-> SetLambda2( l2 ); levelSetFilter->GetDifferenceFunction(i)-> SetOverlapPenaltyWeight( gamma ); levelSetFilter->GetDifferenceFunction(i)-> SetLaplacianSmoothingWeight( eta ); levelSetFilter->GetDifferenceFunction(i)-> SetVolumeMatchingWeight( tau );

levelSetFilter->GetDifferenceFunction(i)-> SetVolume( volume );

}

TRACKING MULTIPLE OBJECTS USING LEVEL-SETSMany biological experiments that involve microscopic imaging require segmentation and temporal tracking of cells as part of the analysis protocol. For example, develop-ment biologists are interested in reconstructing cell lineages during embryonic development. Migratory behavior and rearrangement of cells is a fascinating topic of research. Cancer researchers track cells in colonies to determine growth kinetics and the effects of different chemical agents. The cell forms the fundamental biological entity of interest and its tracking is essential in these applications.

Dufour, et al. [3] proposed a solution to the tracking problem by using coupled active surfaces. In this method, each cell is represented by a unique level-set function. Energy functions involving the level-set contours are defined to partition the image into constant intensity background and constant intensity foreground components. The foreground compo-nents are regularized, in terms of their area and length, for smoothness. Several other properties such as continuity in volume and shape across time-points are maintained. Their solution as proposed is robust and elegant for small datasets since each cell only requires a unique level-set function of the same size as the image domain. In our implementation of the method in [6], we make use of performance optimiza-tion using ROI bounding boxes that now make the tracking filter scale up to larger datasets containing many cells.

Figure 6: 3D confocal images of a developing zebrafish embryo. (a-c) Raw images at 1, 5 and 10 time-points. (d-f) Tracking results at

1, 5 and 10 time-points.

CONCLUSION AND FUTURE wORKIn this work, we developed region-based methods for varia-tional contour evolution using the level-set strategy. We extended the methods to simultaneously segment and track multiple objects in the images and thereby use a kd-tree spatial portioning to be efficient. Our goal was to use these methods in cell segmentation and tracking analysis. We obtained very good results in our work. The main limitation of multi-object segmentations using the current level-set for-mulation is their interactions are not well defined. We often observe absorption of one level-set function by a neighbor-ing one. We plan on further investigating these methods to make these methods robust.

Page 9: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

9

ALTERNATIVE MEMORy MODELS FOR ITK

An ITK image employs an implicit contiguous memory representation. Implicit means the representation cannot be configured or changed. Contiguous means the pixel elements are stored as a 1D array, where each element is adjacent in memory to the previous element. Unfortunately, in certain situations a contiguous memory representation is not desirable.

This article describes three alternative memory models for ITK images: slice contiguous, sparse, and single-bit. A slice con-tiguous image is a three-dimensional image whereby each slice is stored in a contiguous 1D array, but the slices are not necessarily adjacent in memory. Slice contiguous images are well suited for interoperability with applications represent-ing images using DICOM. A sparse image is an n-dimensional image in which each pixel is stored in a hash table data structure. This memory model is well suited for images with very large dimensions, but few pixels that are actually rel-evant. A single-bit binary image is an n-dimensional image that internally stores a boolean as a single-bit, rather than the typical eight-bits. Single-bit images allow very compact representations for on-off binary masks.

ITK images are tightly coupled with their underlying memory representation. Performing a quick "grep" over the code base reveals numerous classes which directly access the image pixel array via itk::Image::GetBufferPointer().Some of these include:• Image iterators• Image adapters• Image file readers/writers• VTK image export filter• Octree•Watershed segmenter• BSpline deformable transform• Optimized Mattes mutual information metric

The existence of these classes, as well as ITK’s strict backward compatibility policy, makes it difficult—but fortunately not impossible — to introduce images with alternative memory models. This article describes three new image memory models which use a similar mechanism to the existing itk::VectorImage. The new image types do not require changes to existing code, and they function with iterators and the majority of existing filters. However they will not function with classes that directly access the pixel array. For example, it is not possible to directly read or write the pro-posed images to/from disk, export the images to VTK, or use the images with the optimized registration framework.

(a) Contiguous Memory Model

(b) Slice Contiguous Memory Model

Figure 1: Contiguous and slice contiguous memory models.

REFERENCES[1] T. Chan and L. Vese. An active contour model

without edges. In Scale-Space Theories in Computer Vision, pages 141–151, 1999.

[2] L. Vese and T. Chan. A multiphase level-set framework for image segmentation using the Mumford and Shah model. International Journal of Computer Vision, 50:271–293, 2002.

[3] A. Dufour, V. Shinin, S. Tajbakhsh, N. Guillen-Aghion, J. C. Olivo-Marin, and C. Zimmer. Segmenting and tracking fluorescent cells in dynamic 3-d microscopy with coupled active surfaces. IEEE Transactions on Image Processing, 14(9):1396–1410, 2005.

[4] K. Mosaliganti, B. Smith, A. Gelas, A. Gouaillard, and S. Megason. Level-set segmentation: Active contours without edges. The Insight Journal, 2008.

[5] K. Mosaliganti, B. Smith, A. Gelas, A. Gouaillard, and S. Megason. Segmentation using coupled active surfaces. The Insight Journal, 2008.

[6] K. Mosaliganti, B. Smith, A. Gelas, A. Gouaillard, and S. Megason. Cell Tracking using Coupled Active Surfaces for Nuclei and Membranes. The Insight Journal, 2008.

ACKNOwLEDGEMENTSThis work was funded by a grant from the NHGRI (P50HG004071-02) to found the Center for in-toto genomic analysis of vertebrate development. Benjamin Smith at Simon Fraser University, Vancouver, Canada first developed a working prototype of the code using ITK. It was significantly improved with bug corrections and enhanced with newer C++ constructs and optimized for its speed by the team comprising of Kishore Mosaliganti, Arnaud Gelas, Alexandre Gouaillard and Sean Megason at Harvard Medical School. We are currently working on the development of GoFigure2 – an open source application for biomedical image analysis, visualization and archival using ITK, VTK and Qt.

Kishore Mosaliganti is a Research Fellow in the Megason Lab at Harvard Medical School where he He is currently developing algo-rithms for the extraction of zebrafish ear lineages using confocal microscopy images to be included in GoFigure2.

Arnaud Gelas is a Research Associate in the Megason Lab at Harvard Medical School where he is in charge of the development of GoFigure2. Currently, he manages the soft-ware development process of GoFigure2.

Alexandre Gouaillard is the President of CoSMo software which proposes software development services in medical image pro-cessing and modeling. Formerly he was a Research Associate at the Megason Lab at Harvard Medical School where he was in charge of the design and development of

GoFigure2. He is now a PI at the Singaporean Immunology Network (SIgN) in a Systems Immunology research group using Complex Systems Modeling.

Sean Megason is an Assistant Professor in the Department of Systems Biology at Harvard Medical School where he overlooks the development of GoFigure2. He is working in systems biology research on the develop-mental circuits of zebrafish.

Page 10: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

10

SLICE CONTIGUOUS IMAGESA slice contiguous image is implicitly three-dimensional. Each slice is stored in a contiguous 1D array, but the slices are not necessarily adjacent in memory. This representation is shown in Figure 1. The image can be realized by creating a new image class with custom pixel and neighborhood accessor functions. The pixel and neighborhood accessor functions provide a layer of indirection for iterators to access the image pixel data. Given the incoming offset for a contigu-ous memory model, the new accessors compute the index of the slice containing the pixel and the offset within that slice. The new image class is templated over the pixel type; it is not templated over the number of dimensions as it is always three.

One important different between itk::Image and itk::SliceContiguousImage is that for the later GetBufferPointer() always returns NULL (i.e., the pixel buffer makes no sense). Ideally this method would not even exist for slice contiguous images, but unfortunately too many other classes assume its existence.

A slice contiguous image is created in a very similar fashion to a “normal” image:

//TypedefstypedeffloatPixel;typedef itk::SliceContiguousImage <Pixel> ImageType;

// Create imageImageType::Pointer image = ImageType::New ();ImageType::IndexType start;start.Fill( 0 );ImageType::SizeType size;size[0] = 256; size[1] = 256; size[2] = 4;ImageType::RegionType region( start , size );image->SetRegions( region );image->Allocate( );

An additional step requires the pixel container to be config-ured with a list of slice pointers:

// Set slice pointersImageType::PixelContainer::SliceArrayType slices;slices.push_back( slice2->GetBufferPointer () );slices.push_back( slice4->GetBufferPointer () );slices.push_back( slice3->GetBufferPointer () );slices.push_back( slice1->GetBufferPointer () );ImageType::PixelContainerPointer container =ImageType::PixelContainer::New ();container->SetImportPointersForSlices ( slices, size[0]* size[1], false );image->SetPixelContainer ( container );

The slice contiguous image is now able to be used like any other image:

// Use the image with a filtertypedef itk::ShiftScaleImageFilter <ImageType , ImageType > FilterType;FilterType::Pointer filter = FilterType::New ();filter->SetInput( image );filter->SetShift( 10 );filter->Update( );

SPARSE IMAGESA sparse image is an n-dimensional image in which each pixel is stored in a hash table data structure. Each time a pixel is set, a new offset-value pair is added to the hash table. Such a memory model means that little or no memory is allocated when the image is created, but the memory footprint grows as more and more pixels are set. This memory model is well-suited for images with very large dimensions, but few pixels

which are actually relevant. It should be noted that (pres-ently) filters using sparse images must be single-threaded.

A sparse image can be created in the typical fashion:

//Typedefsconst unsigned int Dim = 2;typedef unsigned short Pixel;typedef itk::SparseImage<Pixel , Dim> ImageType;

//Create imageImageType::Pointer image = ImageType::New();ImageType::IndexType start;start.Fill( 0 );ImageType::SizeType size;size.Fill( 1000000 );//try this with a normal image!ImageType::RegionType region( start , size );image->SetRegions( region );image->Allocate( );

A sparse image requires a “background” value to be speci-fied for undefined pixels:

image->FillBuffer( 100 );

Pixels can be retrieved or set directly (using Get/SetPixel) or via an iterator:

ImageType::IndexType indexA = {100 , 100};Pixel pixelA = image->GetPixel( indexA );ImageType::IndexType indexB = {10000 , 10000};image->SetPixel( indexB , 5 );Pixel pixelB = image->GetPixel( indexB );

SINGLE-BIT BINARy IMAGESIt is very common in image processing to create mask images which indicate “on” or “off” regions. Currently, the smallest pixel element available in ITK for representing such images is unsigned char which is stored in a single byte (8-bits). Even though a boolean can only represent 0 or 1, it too is stored in a single byte—check this yourself using std::cout << sizeof(bool) << std::endl.

Single-bit binary images internally represent each pixel as a single-bit. As such, the memory footprint for on-off masks can be lowered by (nearly) a factor of eight. Similar to slice contiguous images, single-bit binary images provide custom pixel accessor functions which convert the incoming offset to the relevant bit mask for the underlying data storage. Unlike slice contiguous images, single-bit binary images fit slightly better within the existing ITK framework so GetBufferPointer() makes sense in this context.

A single-bit binary image can be created as follows:

//Typedefsconst unsigned int Dim = 2;typedef bool PixelType;typedef itk:: SingleBitBinaryImage <Dim > ImageType;

//Create imageImageType::Pointer image = ImageType::New ();ImageType::IndexType start;start.Fill( 0 );ImageType::SizeType size;size.Fill( 65 );ImageType::RegionType region( start , size );image->SetRegions( region );image->Allocate( );image->FillBuffer( true );

The bits are stored in blocks of 32, so the above code will actually allocate a buffer with size 96×96. As with all the presented image memory models, the binary image can be used with any iterator and/or filter which does not directly access the pixel buffer via GetBufferPointer().

Page 11: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

11

PERFORMANCEAlthough the memory models presented above may be advantageous for reducing memory usage in certain sce-narios, they have a performance penalty. Accessing pixels stored in a contiguous array can be highly efficient, whereas the three new images require additional computation whenever a pixel is accessed. A simple performance test was undertaken to compare the new memory models. The test measured four properties: (1) time to allocate the buffer, (2) time to fill the buffer, (3) time to set all pixels using an itera-tor, and (4) time to get all pixels using an iterator. Each test was run on a 256×256×256 image, executed on my notebook (Intel Core 2 Duo, T7250 @ 2GHz, 3GB RAM, Windows Vista SP1 32-bit) a total of 5 times with mean times (in seconds) reported in the following table.

All of the images have similar values for buffer allocation and getting pixels using an iterator. The sparse image was the fastest for filling the buffer because no memory is actu-ally set at this moment, only a single “background” value. However, it was also the slowest (by quite a margin) for setting pixels using an iterator, because each pixel being set must be added to the hash table. The single-bit binary image was also fast for filling the buffer because the pixels are set in groups of 32-bits, rather than individual elements.

Performance timings (in seconds) for a 256×256×256 image.

CONCLUSIONThis article discussed three images with alternative memory models: slice contiguous, sparse, and single-bit binary images. The proposed images should work with most of the existing ITK filters—assuming they access the pixel data using itera-tors rather than GetBufferPointer().

ACKNOwLEDGMENTSThanks to Karthik Krishnan (Kitware) and Glen Lehmann (Calgary Scientific) for helpful discussions.

Dan Mueller writes software to analyze and view images. At the moment he’s doing this for digital pathology images at Philips Healthcare in Best, Netherlands. When he’s not working with images, Dan enjoys making them with his camera. This year he’s taken over 6000 photos in 14 different countries.

N3 ITK IMPLEMENTATION FOR MRI BIAS FIELD CORRECTION

We forego theoretical discussions of MRI bias field correction and defer to relevant references [2, 7, 1]. Instead, we discuss our implementation and how it relates to both Sled’s paper [3] and the original N3 public offering. For notational pur-poses in this article, we denote the MNI N3 implementation as ‘N3MNI’ and the ITK implementation we offer as ‘N4ITK’.

IMPLEMENTATIONThe N4ITK implementation is given as a single class itk::N3MRIBiasFieldCorrectionImageFilter. It is derived from

the itk::ImageToImageFilter class (as is the related class itk::MRIBiasFieldCorrectionFilter) since its operation takes the MR image (with an associated mask) corrupted by a bias field as input, and outputs the corrected image. For the user that wants to reconstruct the bias field once the algorithm terminates, we demonstrate how that can be accomplished with the additional class itk::BSplineControlPointImageFilter which is included with this submission. Note that it is only needed if the bias field is to be reconstructed after the N3 algorithm terminates.

ALGORITHMIC OVERVIEwThe steps for the N3 algorithm are illustrated in Figure 4 of [3]. Initially, the intensities of the input image are trans-formed into the log space and an initial log bias field of all zeros is instantiated. In N3MNI, an option is given whereby the user can provide an initial bias field estimate but, to keep the options to a minimum, we decided to omit that option. However, given the open-source nature of the code, the ITK user can modify the code according to preference. After initialization, we iterate by alternating between esti-mating the unbiased log image and estimating the log of the bias field.

PARAMETERSOne of the attractive aspects of the N3 algorithm is the minimal number of parameters available to tune and the relatively good performance achieved with the default parameters which we tried to maintain, where we could, for both N3MNI and [3]. The available parameters are:• m_MaskLabel (default = 1): The algorithm requires a

mask be supplied by the user with the corresponding mask label. According to Sled, mask generation is not crucial and good results can be achieved with a simple scheme like Otsu thresholding.

• m_NumberOfHistogramBins (default = 200): One of the steps of N3 requires intensity profile construction from the intensities of the uncorrected input image and a triangular parzen windowing scheme. The default value is the same as in N3MNI.

• m_WeinerFilterNoise (default = 0.01): Field esti-mation is performed by deconvolution using a Wiener filter which has an additive noise term to prevent division by zero (see Equation (12) of [3]). This is identical to the noise variable in N3MNI and equal to Z2 in [3].

• m_BiasFieldFullWidthAtHalfMaximum (default = 0.15): A key contribution to N3 is the usage of a simple Gaussian to model the bias field. This variable character-izes that Gaussian and is the same as the FWHM variable in both N3MNI and [3].

• m_MaximumNumberOfIterations (default = 50): Optimization occurs iteratively until the number of itera-tions exceeds the maximum specified by this variable.

• m_ConvergenceThreshold (default = 0.001): In [3], the authors propose the coefficient of variation between the ratio of subsequent field estimates as the convergence criterion. However, in both N3MNI and N4ITK, the standard deviation of the ratio between subsequent field estimates is used.

• m_SplineOrder (default = 3): A smooth field estimate is produced after each iterative correction using B-splines. In both N3MNI and [3], cubic splines are used. Although any feasible order of spline is available, the default in N4ITK is also cubic.

Page 12: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

12

• m_NumberOfControlPoints Since the

field is usually low frequency, by default we set the number of control points to the minimum m_SplineOrder+1.

• m_NumberOfFittingLevels (default = 4): The B-spline fitting algorithm [6] is different from what is used in N3MNI and proposed in [3]. The version we use was already available in ITK as one of our earlier contributions [5] and is not susceptible to ill-conditioned fitting matri-ces. One of the parameters for that fitting is the number of hierarchical levels to fit where each successive level doubles the B-spline mesh resolution.

Figure 1: (a) Uncorrected image. (b) Mask image. (c) Bias field corrected image. (d) Uncorrected image with the calculated bias

field superimposed.

BIAS FIELD GENERATIONOftentimes, the user would like to see the calculated bias field. One of the more obvious reasons for this would be when the bias field is calculated on a downsampled image (suggested in [3] and given as an option in N3MNI and included in the testing code). One would then like to recon-struct the bias field to estimate the corrected image in full resolution. Since the B-spline bias field is a continuous object defined by the control point values and spline order, we can reconstruct the bias field of the full resolution image without loss of accuracy. We demonstrate how this is to be done in the test code itkN3MRIBiasFieldCorrectionImageFilterTest.cxx. Note that the control points describe a B-spline scalar field in log space so the itk::ExpImageFilter has to be used after reconstruction.

TEST CODEThe test code included with this submission, itkN3MRIBias-FieldCorrectionImageFilterTest.cxx, is designed to allow the user to immediately apply the N4ITK classes to their own images. Usage is given as follows:

itkN3MRIBiasFieldCorrectionImageFilterTest imageDimension inputImage outputImage [shrinkFactor] [maskImage] [numberOfIterations] [numberOfFittingLevels] [outputBiasField]

This class takes the input image, subsamples it according to the optional shrinkFactor option, and creates the bias field corrected output image. Other optional parameters are the maskImage (if not available, one is created using the itk::OtsuThresholdImageFilter), the number of iterations (default = 50), the number of fitting levels (default = 4), and a file name for writing out the resulting bias field.

SAMPLE RESULTSWe demonstrate usage with two MR images—a 2D brain slice and a volume from a hyperpolarized helium-3 image. We use ITK-SNAP to visualize the results.

2D BRAIN SLICEFigure 1(a) is the uncorrected image used in our 2D brain test. Close inspection demonstrates a darkening in the white matter toward the upper right of the image. This darkening is corrected in Figure 1(c).

itkN3MRIBiasFieldCorrectionImageFilterTest 2 t81slice.nii.gz t81corrected.nii.gz 2 t81mask.nii.gz 50 4 t81biasfield.nii.gz

3D HyPERPOLARIZED HELIUM-3 LUNG MRIFigure 2(a) is the uncorrected image used in our 3D helium-3 MR image volume. Close inspection demonstrates a darken-ing in the white matter toward the upper portion of the given axial slice. This darkening is corrected in Figure 2(c).

Figure 2: (a) Uncorrected image. (b) Mask image. (c) Bias field cor-rected image. (d) Uncorrected image with the calculated bias field

superimposed.

itkN3MRIBiasFieldCorrectionImageFilterTest 3 he3volume.nii.gz he3corrected.nii.gz 2 he3mask.nii.gz 50 4 he3biasfield.nii.gz

REFERENCES[1] R. G. Boyes, J. L. Gunter, C. Frost, A. L. Janke, T. Yeatman, D.

L.G. Hill, M. A. Bernstein, P. M. Thompson, M. W. Weiner, N. Schuff, G. E. Alexander, R. J. Killiany, C. DeCarli, C. R. Jack, N. C. Fox, and A. D. N. I. Study. Intensity non-uniformity cor-rection using n3 on 3-t scanners with multichannel phased array coils. Neuroimage, 39(4):1752–1762, Feb 2008.

[2] Zujun Hou. A review on mr image intensity inhomogene-ity correction. Internation Journal of Biomedical Imaging, 2006:1–11, 2006.

[3] J. G. Sled, A. P. Zijdenbos, and A. C. Evans. A nonparametric

Page 13: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

13

EXPORTING CONTOURS TO DICOM-RTSTRUCT

The “radiotherapy structure set” (RTSTRUCT) object of the DICOM standard is used for the transfer of patient structures and related data, between the devices found within and outside the radiotherapy department. It contains mainly the information for regions of interest (ROIs) and points of inter-est (e.g., dose reference points). In many cases, rather than manually drawing these ROIs on the CT images, one can indeed benefit from the wealth of automated segmentation algorithms available in ITK. But at present, it is not possible to export the ROIs obtained from ITK to RTSTRUCT format. In order to bridge this gap, we have developed a framework for exporting contour data to RTSTRUCT [1].

RTSTRUCTThe mandatory modules contained by the RTSTRUCT are presented in Table 1. These modules are grouped based on the type of information entity that they represent. Here is a brief description of each of these modules:

1. “Patient Module” specifies the attributes that describe and identify the patient who is the subject of a diagnostic study. This module contains attributes of the patient that are needed for diagnostic interpretation of the image and are common for all studies performed on the patient.

2. “General Study Module” specifies the attributes that describe and identify the study performed upon the patient.

3. “RT Series Module” has been created to satisfy the require-ments of the standard DICOM query/retrieve model.

4. “General Equipment Module” specifies the attributes that

identify and describe the piece of equipment that pro-duced a series of composite instances.

5. “Structure Set Module” defines a set of areas of sig-nificance. Each area can be associated with a frame of reference and zero or more images. Information which can be transferred with each ROI includes geometrical and display parameters, and generation technique.

6. “ROI Contour Module” is used to define the ROI as a set of contours. Each ROI contains a sequence of one or more contours, where a contour is either a single point (for a point ROI) or more than one point (representing an open or closed polygon).

7. “RT ROI Observations Module” specifies the identification and interpretation of an ROI specified in the Structure Set and ROI Contour modules, and

8. “SOP (Service-Object Pair) Common Module” defines the attributes which are required for proper functioning and identification of the associated SOP Instances. They do not specify semantics about the real-world object represented by the IOD.

[2] contains a comprehensive documentation of the DICOM standard covering all the modules. Refer to [1] for a brief summary of the RTSTRUCT.

Information Entity Mandatory Modules

Patient (1) Patient

Study (2) General Study

Series (3) RT Series

Equipment (4) General Equipment

Structure Set (6) Structure Set (6) ROI Contour (7) RT ROI Observations (8) SOP Common

Table 1: Mandatory Modules of RTSTRUCT.

IMPLEMENTATIONFigure 1 illustrates the pipeline that we use for exporting the automated segmentation results to RTSTRUCT format. It mainly contains three steps: Automated Segmentation, Mask to Contour Conversion and RTSTRUCT-Exporter.

Segmentation Tool (ITK or similar one)

RTSTRUCT Explorer

RTSTRUCT File

Mask to Contour Converter

Additional Information

DICOM CT-Image

Figure 1: Block diagram illustrating the pipeline for exporting the automated segmentation results to RTSTRUCT.

• Automated Segmentation: The input DICOM CT images are converted into a convenient image format (if required) and an automated segmentation is performed using ITK or similar tools. The output ROIs from this tool should be a mask. There can be multiple masks corresponding to differ-ent structures of interest and the current program indeed allows for the export of multiple masks. It is also possible to export the ROIs obtained on images that are cropped along z-axis; in such cases, the information of starting-slice-number and the number of slices used should be later passed to the RTSTRUCT-exporter module. The output of this module is passed to the “mask to contour converter”.

method for automatic correction of intensity nonunifor-mity in MRI data. IEEE Transactions on Medical Imaging, 17(1):87–97, Feb 1998.

[4] M. Styner, C. Brechbuhler, G. Szckely, and G. Gerig. Parametric Estimate of Intensity Inhomogeneities Applied to MRI. IEEE Transactions on Medical Imaging, 19(3):153–165, March 2000.

[5] N. J. Tustison and J. C. Gee. N-d Ck B-spline scattered data approximation. The Insight Journal, 2005.

[6] N. J. Tustison and J. C. Gee. Generalized n-d Ck B-spline scattered data approximation with confidence values. In Proc. Third International Workshop Medical Imaging and Augmented Reality, pages 76–83, 2006.

[7] U. Vovk, F. Pernus, and B. Likar. A review of methods for cor-rection of intensity inhomogeneity in mri. IEEE Transactions on Medical Imaging, 26(3):405–421, March 2007.

[8] A listing of several relevant algorithms compiled by Finn A. Nielsen at the Technical University of Denmark is provided at http://neuro.imm.dtu.dk/staff/fnielsen/bib/ and clicking on the folder "Nielsen2001BibSegmentation/".

[9] http://www.bic.mni.mcgill.ca/software/N3/[10] A complete discussion of ‘N4’ is provided at hdl.handle.

net/10380/3053.

Nick Tustison borders his moments of soft-ware-writing serenity at the Penn Image Computing and Science Lab (PICSL) with attempts at integrating Heidegger’s notion of “Dasein” with the open source software paradigm---oh, and battling ninjas, too.

Page 14: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

14

• Mask to Contour Conversion: We first extract axial slices of the mask using ExtractImageFilter of ITK. We then use the ContourExtractor2DImageFilter [3] from ITK, for obtain-ing contours on each of these slices. We finally create an output text file containing the information of total number of contours, coordinates of each contour-point along with the corresponding slice number, number of contour points for each contour and type of geometry of each contour (open or closed).

• RTSTRUCT-Exporter: Exporting the contours to RTSTRUCT format requires the implementation of RTSTRUCT-Writer. We implemented this in a class called “RTSTRUCTIO”. For creating instances of RTSTRUCTIO objects using an object factory, “RTSTRUCTIOFactory” class is also implemented. Refer to [1] for a detailed description of class-design and key implementation issues.

The inputs to the RTSTRUCT-Exporter are:• An axial slice of the DICOM CT image of the patient (for

extracting the information that is common to both CT image and RTSTRUCT, as described in [1]).

• Output(s) of the “Mask to Contour Converter” (multiple contours can be exported, as described in [1]).

• Few additional inputs like starting slice number with respect to the original image, total number of slices to be considered, ROI interpreted types and the colors to be assigned to each ROI.

All of these parameters are passed to the RTSTRUCT-Exporter through a text file.

EXAMPLEThe DICOM CT image used in this paper is acquired during routine clinical practice at Divisions of Radiotherapy, Fribourg Hospital (HFR) in Switzerland. The image is acquired on GE Medical System (Model: LightSpeedRT16). The size of each slice is 512 × 512 pixels with a spacing of 1.27 mm × 1.27 mm; the inter-slice distance is 2.5 mm. There are 116 slices in total.

Since we are interested only in the first 83 slices of the patient’s image, the original DICOM image is cropped in the Z-direction to contain only these slices, and a new image file (with .mhd extension) is created. The image is then thresh-olded in selected regions for removing the bed and other immobilization devices. Figure 2 shows the thresholded image. We created separate masks for the external-contour and bones through simple windowing of the image, as shown in Figure 2. These masks are shown in Figures 3 and 4. The contours of these masks are obtained using the “Mask to Contour Convertor”. The contour data, along with a slice of the DICOM CT image and other information, is passed to the RTSTRUCT-Exporter using a parameter-file. Figure 5 shows the resultant RTSTRUCT file superposed over the origi-nal DICOM CT image.

CONCLUSIONS & FUTURE wORKAn ITK implementation of the RTSTRUCT-Exporter is pre-sented. The details of the pipeline used and description of each module in the pipeline is presented. The implementa-tion is validated on a 3D CT image, by exporting the ROIs of the external-contour and bones to RTSTRUCT format.

We would also like to mention the recent work of Dowling et al. [4] that presents a method to do the reverse, i.e., import-ing the contours from the RTSTRUCT. It would be interesting to integrate these two implementations. RTSTRUCT-Exporter

is currently tested only on the DICOM CT images acquired from a GE Medical System (Model: LightSpeedRT16). A thorough testing on more images, acquired from various manufacturers and models, will make it more robust.

Figure 2: Sagittal, Coronal and Axial views of the 3-D CT image of the Patient. This is a cropped image containing only the first 83

slices of the original image.

Figure 3: Sagittal, Coronal and Axial views of the mask for external-contour of the 3-D CT image.

Figure 4: Sagittal, Coronal and Axial views of the mask for bones of the 3-D CT image.

Figure 5: A screen-shot showing the contours of the external-con-tour and bones in the RTSTRUCT file, superposed over the original

DICOM CT image.

ACKNOwLEDGMENTSThis work is supported in part by the Swiss National Science Foundation under Grant 3252B0-107873, 205321-124797, and by the Center for Biomedical Imaging (CIBM) of the Geneva--Lausanne Universities and the EPFL, as well as the foundations Leenaards and Louis-Jeantet. We thank Dr. A. S. Allal, Dr. Pierre-Alain Tercier and Dr. Pachoud Marc for providing us the data and helping us in testing. We thank Mathieu Malaterre for his valuable suggestions.

REFERENCES[1] S. Gorthi, M. Bach Cuadra, and J.-P. Thiran, “Exporting con-

tours to DICOM-RT Structure Set,” Insight Journal, 2009. [Online] hdl.handle.net/1926/1521

[2] “DICOM home page.” [Online] http://medical.nema.org/ [3] Z. Pincus, “ContourExtractor2DImageFilter: A subpixel-pre-

cision image isocontour extraction filter,” Insight Journal, 2006. [Online] hdl.handle.net/1926/165

[4] J. Dowling, M. Malaterre, P. B. Greer, and O. Salvado,

Page 15: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

15

“Importing contours to DICOM-RT Structure Sets,” Insight Journal, 2009. [Online] hdl.handle.net/10380/3132

Subrahmanyam Gorthi is currently pursuing his PhD at Swiss Federal Institute of Technology (EPFL), Lausanne, Switzerland. His research interests include medical image registration, segmentation and variational methods in image analysis.

Dr. Meritxell Bach Cuadra is currently with the Signal Processing Core of the Biomedical Imaging Center (CIBM), responsible for signal processing research at the Lausanne University Hospital (CHUV). Her main research interests are related to magnetic resonance (MR) and diffusion MR imaging,

atlases, registration, segmentation, and classification.

Dr. Jean-Philippe Thiran is currently an Assistant Professor at Swiss Federal Institute of Technology (EPFL), Lausanne, Switzerland. His research interests include image segmen-tation, prior knowledge integration in image analysis, partial differential equations and variational methods in image analysis, multi-

modal signal processing, medical image analysis, including multimodal image registration, segmentation, computer-assisted surgery, and diffusion MRI.

KITwARE NEwS

DEVELOPER'S TRAINING wEEKKitware’s Developer’s Training Week will be held May 3 - 6, in Albany, NY. The course will cover VTK, ParaView, ITK, and CMake. The course is a hands-on experience suitable for both new users of these open source projects as well as more advanced developers. Basic knowledge of C++ programming is recommended. The course is appropriate for both new users wishing to quickly gain proficiency and experienced developers requiring advanced customization skills.

Additional course information is available on our website or by emailing [email protected]. In addition to the upcom-ing course offered at Kitware's site, we also offer customized courses at either our site or yours. If you specific training needs that are not met by the standard course or the Spring dates do not work for your organization, a customized course may be right for you. Please contact a Kitware representa-tive to discuss training options for your organization.

KITwARE SPONSORS "THIS IS GIT" TALK AT UNCKitware sponsored a "This is GIT" talk for the University of North Carolina, Chapel Hill's undergraduate and graduate computer programming clubs. Kitware provided pizza and drinks to about 25 students, faculty, and staff at a talk by Jason Sewall, a UNC CS Ph.D. candidate. The talk lasted nearly 2 hours, with questions resulting in live demonstra-tions and extended discussions.

ITK DASHBOARD FEST A HUGE SUCCESSDashboard Fest 1.0 was a huge success thanks to your con-tributions. Our goal was to hit 200 experimental builds, and by the end of the day on Friday November 6, 2009, 1,033 experimental builds had been submitted to the Dashboard

from 106 different computers. The following users submit-ted the largest number of builds:• Gaëtan Lehmann (INRA)• Kevin Hobbs (Ohio University)• Oleksander Dzyubak (Mayo Clinic)• Arnaud Gelas (Harvard) • Alexandre Gouaillard (Harvard) • Kishore Mosaliganti (Harvard) • Hans Johnson (Iowa) • Kent Williams (Iowa)• Bradley Lowekamp (NLM/Lockheed Martin)• Sean McBride (Rogue Research) • Mathieu Coursolle (Rogue Research)• Christian Haselgrove (NITRC)• Steve Pieper (Brigham and Women's Hospital)• Iván Macía (Vicomtech) • Tom Vercauteren (Mauna Kea Technologies)

NORTH CAROLINA GROwS AGAINKitware’s North Carolina office has expanded into another 600 sq. ft. of office space in their current location. The office will now occupy over 4500 sq. ft. of modern office space in downtown Carrboro. The increase in space provides adding seating for eight new employees. Kitware's North Carolina office has grown from two employees to twelve in just over two years. And new leaders within the group, such as Julien Jomier and Brad Davis, ensure that the southern office will continue to rapidly expand.

RSNA 2009Kitware supported three events at the Radiological Society of North America's (RSNA) annual meeting in Chicago. The first was an educational exhibit at the first “Toward Quantitative Imaging: Reading Room of the Future”. Our showcase consisted of a large poster describing a Kitware's open-source Lesion Sizing Toolkit, a partnership with the Optical Society of America (OSA), and a computer which ran live examples. Our display was available in our exhibit area and on the OSA website as an interactive Science Publishing presentation (http://www.opticsinfobase.org/isp.cfm).

Stephen Aylward and Rick Avila taught a course on “Open-Source Tools for Medical Research and Applications”. Course attendance was high and evidenced the growing interest in open source solutions for medical imaging applications.

Rick also gave a scientific presentation on “Quantitative Estimation of Individual Lung Cancer Risk”. The presentation provided evidence that risk of developing lung cancer can be monitored well in advance of the onset of a malignancy. We now have preliminary study data showing good risk strati-fication performance, quantitative imaging and functional trends that have never before been reported.

In the Reading Room of the Future, Rick Avila, Senior Director of Healthcare Solutions, speaks about Kiware’s open-source toolkit for

quantitative lesion sizing. (Photo by Ray Whitehouse)

Page 16: SOFTWARE DEVELOPER’S QUARTERLY Issue 12 Jan 2010 · • The ray that was cast to obtain the point (vtkRay* Ray) • The coordinate of the closest intersection of the ray with the

16

Kitware’s Software Developer’s Quarterly is published by Kitware, Inc., Clifton Park, New York.

Contributors: Lisa Avila, Rick Avila, Utkarsh Ayachit, Stephen Aylward, Katie Cronen, Meritxell Bach Cuadra, David Doria, Arnaud Gelas, Subrahmanyam Gorthi, Alexandre Gouaillard, Luis Ibáñez, Julien Jomier, Steve Jordan, Sean Megason, Dan Mueller, Kishore Mosaliganti, Dave Partyka, Jean-Philippe Thiran, and Nick Tustison.

Design: Melissa Kingman, www.elevationda.com

Editor: Niki Russell

Copyright 2010 by Kitware, Inc. or original authors.

The material in this newsletter may be reproduced and dis-tributed in whole, without permission, provided the above copyright is kept intact. All other use requires the express permission of Kitware, Inc. Kitware, ParaView, and VolView are registered trademarks of Kitware, Inc. All other trade-marks are property of their respective owners.

To contribute to Kitware’s open source dialogue in future editions, or for more information on contributing to specific projects, please contact the editor at [email protected].

In addition to providing readers with updates on Kitware product development and news pertinent to the open source community, the Kitware Source delivers basic infor-mation on recent releases, upcoming changes and detailed technical articles related to Kitware’s open-source projects. These include:• TheVisualizationToolkit(www.vtk.org)• TheInsightSegmentationandRegistrationToolkit

(www.itk.org)• ParaView(www.paraview.org)• TheImageGuidedSurgeryToolkit(www.igstk.org)• CMake(www.cmake.org)• CDash(www.cdash.org)• MIDAS(www.kitware.com/midas)• BatchMake(www.batchmake.org)• VTKEdge(www.vtkedge.org)

Kitware would like to encourage our active developer community to contribute to the Source. Contributions may include a technical article describing an enhancement you’ve made to a Kitware open-source project or successes/lessons learned via developing a product built upon one or more of Kitware’s open-source projects. Authors of any accepted article will receive a free, five volume set of Kitware books.

LATE FALL/wINTER CONFERENCESIf you’re interested in meeting with a Kitware representative at one of these events, email us at [email protected].

SPIE Medical ImagingFebruary 13 - 18, at the Town and Country Resort and Convention Center in San Diego, CA. SPIE is the premier conference for medical scientists, physicists, and practitio-ners in the field of imaging. Stephen Aylward, Kitware's Director of Medical Imaging, is highly involved in this year's SPIE Conference. Stephen is serving as a Program Committee Member for the Computer-Aided Diagnosis Conference, Session Chair for the Breast Imaging Session, Workshop Co-Chair for the Computer-Aided Diagnosis Workshop and is an invited expert for the "Dessert with the Experts" student networking event. http://spie.org/medical-imaging.xml

Symposium on Interactive 3D Graphics and GamesFebruary 18 - 21, at the Hyatt Regency in Bethesda, MD. I3D is the leading-edge conference for real-time 3D com-puter graphics and human interaction, and 2010 marks the 24th year since the first conference gathering. Dr. Stephen Aylward, Kitware’s Director of Medical Imaging, will be in attendance. http://www.i3dsymposium.org

NEw HIRESJacob BeckerJacob joined Kitware's Computer Vision Group in October 2009 as an R&D Engineer. Jacob received his B.S. in Computer Science and Archaeology from the University of Wisconsin - La Crosse (UW-L) in 2001 and his M.S. in Computer Science from RPI in 2009. While at RPI he researched aligning a 2D image to a 3D model and filling in holes in LiDAR data using evidence provided by a single aligned 2D image.

Aasish ChaudharyAashish joined Kitware's Scientific Computing Group in October 2009 as an R&D Engineer. Aashish received his B.S. (Honors) in Mechanical Engineering from Devhi Ahilya University (India) in 2000 and his M.S. in Industrial Engineering with minor in Computer Science from Iowa State University.

His thesis work involved researching, designing and develop-ing frameworks to integrate simulation with visualization in virtual reality environments. Aashish is also a contributor to the Minerva Open Source Project.

Theresa VincentTheresa joined Kitware in September 2009 as an Accounting Specialist. Prior to joining Kitware, Theresa worked as an Accounting Associate for a non-profit company in Clifton Park. Theresa received her Associate's Degree in Accounting from Schenectady County Community College in 2002.

INTERNSHIP OPPORTUNITIESKitware Internships provide current college students with the opportunity to gain hands-on experience working with leaders in their fields on cutting edge problems. Our busi-ness model is based on open source software—an exciting, rewarding work environment.

Kitware interns assist in the development of foundational research and leading-edge technology across five business areas: supercomputing visualization, computer vision, medical imaging, data publishing and quality software process. We offer our interns a challenging work environment and the opportunity to attend advanced software training. To apply send your resume to [email protected].

EMPLOyMENT OPPORTUNITIESKitware has an immediate need for talented Software Developers, especially those with experience in Computer Vision, Scientific Computing and Biomedical Imaging. Qualified applicants will have the opportunity to work with leaders in computer vision, medical imaging, visualization, 3D data publishing and technical software development.

We offer comprehensive benefits including: flex hours; six weeks paid time off; a computer hardware budget; 401(k); health and life insurance; short- and long-term disability, visa processing; a generous compensation plan; profit sharing; and free drinks and snacks. Interested applicants should forward a cover letter and resume to [email protected].