Difference between revisions of "ITK Registration Optimization"
From NAMIC Wiki
Line 7: | Line 7: | ||
= Publications = | = Publications = | ||
− | # [http://insight-journal.org/InsightJournalManager/view_reviews.php?pubid=172 Aylward, Stephen; Jomier, Julien; Barre, Sebastien; Davis, Brad; Ibanez, Luis, "Optimizing ITK’s Registration Methods for Multi-processor, Shared-Memory Systems." MICCAI Open Source and Open Data Workshop, 2007 | + | # [http://insight-journal.org/InsightJournalManager/view_reviews.php?pubid=172 Aylward, Stephen; Jomier, Julien; Barre, Sebastien; Davis, Brad; Ibanez, Luis, "Optimizing ITK’s Registration Methods for Multi-processor, Shared-Memory Systems." MICCAI Open Source and Open Data Workshop, 2007] |
= Goals = | = Goals = |
Revision as of 19:35, 2 August 2007
Home < ITK Registration OptimizationContents
Quick Links
- Dashboard for this project
- Dashboard for BatchMake
- Batchboard (nightly experiment results) for this project
Publications
Goals
There are two components to this research
- Identify registration algorithms that are suitable for non-rigid registration problems that are endemic to NA-MIC
- Develop implementations of those algorithms that take advantage of multi-core and multi-processor hardware.
Algorithmic Requirements and Use Cases
- Requirements
- relatively robust, with few parameters to tweak
- runs on grey scale images
- has already been published
- relatively fast (ideally speaking a few minutes for volume to volume).
- not patented
- can be implemented in ITK and parallelized.
- Use-cases
- Intersubject mapping
- Example data set (Kilian)
- fMRI to hi-res brain morphology mapping
- Example data set (Steve Pieper)
- DTI: components of the diffusion tensor
- Example data (Sylvain)
- Intersubject mapping
Hardware Platform Requirements and Use Cases
- Requirements
- Shared memory
- Single and multi-core machines
- Single and multi-processor machines
- AMD and Intel - Windows, Linux, and SunOS
- Use-cases
- Intel Core2Duo
- Intel quad-core Xeon processors, Visual Studio 8, Windows Vista (Kitware: redwall)
- 6 CPU Sun, Solaris 8 (SPL: vision)
- 12 CPU Sun, Solaris 8 (SPL: forest and ocean)
- 16 core Opteron (SPL: john, ringo, paul, george)
- 16 core, Sun Fire, AMDOpteron (UNC: Styner)
Data
Workplan
Establish testing and reporting infrastructure
- Identify timing tools
- Cross platform and multi-threaded
- Timing and profiling
- Status
- Instrumenting modular tests
- Extending itk's cross-platform high precision timer
- Adding thread affinity to ensure valid timings
- Adding method for increasing process priority
- ViewCVS
- Profiling complete registration solutions for use cases
- Using CacheGrind on single and multi-core linux systems
- Using LTProf on windows
- Instrumenting modular tests
- Develop performance dashboard for collecting results
- Each test will report time and accuracy to a central server
- The performance of a test, over time, for a given platform can be viewed on one page
- The performance of a set of tests, at one point in time, for all platforms can be viewed on one page
- Status
- BatchMake database communication code being isolated
- Performance dashboard web pages being designed
Develop tests
- Develop modular tests
- Status
- Developed itkCheckerboardImageSource so no IO required
- Developed all tests listed in the "Modular Tests" section below
- Developing second generation tests that compare optimized performance with standard performance in a single executable
- Status
- Develop C-style tests
- Tests should represent the non-ITK way of doing image analysis
- Use standard C/C++ arrays and pointers to access blocks of memory as images
- Tests should represent the non-ITK way of doing image analysis
- Develop complete registration solutions for use cases
- Status
- Centralized data and provide easy access
- Identified relevant registration algorithms
- rigid, affine, bspline, multi-level bspline, and Demons'
- normalized mutual information, mean squared difference, and cross correlation
- Developing traditional ITK-style implementations
- Status
Compute performance on target platforms
- Completing the development of the reporting dashboard, the standard C tests, and the full registration applications (see above).
- Developing optimized versions of select methods in parallel with deploying the testing suite (see below).
ITK Optimization
- Target bottlenecks
- Multi-thread metric calculation
- Initial target is MattesMutualInformationImageToImageMetric
- Optimize code
- Sacrifice some memory and algorithm initialization speed to gain algorithm operation speed increases
- Call multi-threaded functions when possible
- Multi-thread metric calculation
- Integrate metrics with transforms and interpolators for tailored performance
MattesMutualInformationImageToImageMetric
Optimizations Employed
- GetValue
- Added multi-threading to GetValue function
- Partitions the samples - thereby distributes the computation of the transforms and interpolations across threads
- Original runtime is O(C1+C2*M) given M samples from the fixed image and new runtime is O(C1+(C2*M)/(C3*N)) given N cores. The ratio of C2/C3 varies by the type of transform used. When a BSplineTransform is used, the ratio C2/C3 approaches 1.0.
- Added the pre-computation of the FixedImageMarginalPDF for the sample to reduce the need for the thread mutex lock
- Required the concept of an AdjustedFixedImageMarginalPDF that is updated when a fixed image voxel does not map into the moving image and thereby isn't valid for the current computations. By only updating when samples are missed, mutex lock to update a cross-thread data structure is needed less often.
- Each thread now has its own copy of the joinPDF. After threads complete, jointPDFs from each thread are summed. This eliminates mutex from the main loop over samples.
- SUMMARY: Speedup on a dual-core system is about 30% (reduction in computation time) when using linear transform and linear interpolation and about 45% when using bspline transform and bspline interpolation.
- Algorithm optimization (aside from adding multi-threading)
- None at this level. Will be done for transforms and interpolators.
- Added multi-threading to GetValue function
- GetDerivative
- Following the same convention as used with GetValue
Modular tests
All tests send two values to performance dashboards
- the time required
- an measure of the error (0 = no error; 1 = 100% error)
Tests being developed and their parameter spaces
- NearestNeighborInterpTest <numThreads> <dimSize> <factor> [<outputImage>]
- LinearInterpTest <numThreads> <dimSize> <factor> [<outputImage>]
- BSplineInterpTest <numThreads> <dimSize> <factor> <bSplineOrder> [<outputImage>]
- SincInterpTest <numThreads> <dimSize> <factor> [<outputImage>]
- Uses the Welch window function
- BSplineTransformLinearInterpTest <numThreads> <dimSize> <numNodesPerDim> <bSplineOrder> [<outputImage>]
- 3 nodes are also added outside of the image for interpolation
- MeanSquaresImageToImageMetricTest <numThreads> <dimSize> <iterations>
- CorrelationCoefficientHistogramMetricTest <numThreads> <dimSize> <iterations>
- NormalizedCorreltationImageToImageMetricTest <numThreads> <dimSize> <iterations>
- MattesMutualInformationImageToImageMetricTest <numThreads> <dimSize> <numSamples> <iterations>
- MattesMutualInformationMetric defaults to BSpline interpolator - this test overrides to use nearest neighbor interpolation
- MutualInformationImageToImageMetricTest <numThreads> <dimSize> <numSamples> <iterations>
- NormalizedMutualInformationHistrogramMetricTest <numThreads> <dimSize> <iterations>
SECOND GENERATION TEST
- Computes runtime for GetValue, GetDerivative, and GetValueAndDerivative for standard ITK implementation and for the optimized version being developed. Also computes difference (if any) between their answers and reports as an error measure
- OptMattesMutualInformationImageToImageMetricTest
Larger tests
These are top down tests that implement registration tasks as a user would. These tests are run on real medical image data. The goal is to use these larger, realistic tests to focus our optimization effort.
- AlignMomentsTest <fixed image> <moving image> [number of threads] [transformed moving image] [post-registration difference image] [pre-registration difference image]
- AlignRigidMSETest <fixed image> <moving image> [number of threads] [number of iterations] [transformed moving image] [post-registration difference image] [pre-registration difference image]
- AlignRigidMMITest <fixed image> <moving image> [number of threads] [number of iterations] [transformed moving image] [post-registration difference image] [pre-registration difference image]
Events
- April 6, 2007: TCon
- April 12, 2007: TCon
- April 18, 2007: TCon
- May 1, 2007: TCon
- June 27, 2007: NAMIC Programmers' Week
Related Pages
- Non Rigid Registration
- Slicer3:Performance_Analysis
- User:Barre/ITK Registration Optimization
- Testing and ITK Backward Forward Compatibility
Performance Measurement
- LTProf - simple profilter for Windows - Shareware
- Intel's VTune for Linux ($)
- TAU
- Threadmon: Thread usage/blockage
- TotalView ($)
- PerfSuite (POSIX Threads)
- GProf work-around for multi-threaded apps
- References on multi-threaded profiling and code optimization