Slicer/Slicer — pull request #118 by lassoan (2014-03-17 17:58:41+00:00)
Title: ENH: Several fixes and improvements in transform handling

Major fixes:
* Added mechanism to prevent immediate invocation of TransformModified events (similarly to Modified events) to allow atomic changes of transforms and prevent multiple event invocations (fixes #3610, #3611).
* Fixed vtkITKBSplineTransform inverse computation (the bulk component was ignored in the inverse computation due to a shadow variable)
* Fixed DeepCopy of vtkITKBSplineTransform.cxx (InternalDeepCopy method had to be implemented)
* Use vtkTransform's ability to compute inverse transforms instead of keeping separate transforms for forward and inverse transforms (still kept the two member variables in the transform node base class to allow storing of forward and inverse transform if they are both computed, e.g., some Demons registration provides both the forward and inverse transforms as outputs).
* Fixed ReadWriteAsTransformToParent logic in the storage node class (as inverse warp transforms usually cannot be written, the flag should point to the forward transform class). For convenience, the flag is updated automatically when a To/FromParentTransform is set in the transform node.
* Fixed transform node copy: now a true deep copy is performed (earlier only the pointer of the transforms were copied, therefore changing a transform in a node changed the copied node, too)
* Removed vtkMRMLNonlinearTransformNode, as non-linear transforms are not special cases anymore: the base transform class can manage them the same way as linear transforms.
* Changed Get/SetMatrixTransformToParent and Get/SetMatrixTransformFromParent method to make it clear that it makes a copy of the input and output, so changing a matrix is only possible by using the Set... method (and not Get...()->DeepCopy(...)). Kept the old functions to prevent build errors, but they are deprecated and a warning is logged if they are used (as the behavior of the Get... function is changed from a shallow copy to a deep copy). This API change required changing of a lot of file in the Slicer core and extensions.

Minor fixes:
* Made vtkMRMLTransformNode non-abstract: this is the class that can handle arbitrarily complex composite transforms (e.g., grid transform hardened on a bspline transform).
* Fixed invalid NonLinearTransformScene.mrml scene: wrong storage node ref ID caused warnings in the tests
* Changed the Bspline-f-m.tfm test data to include larger bulk component to make errors more detectable
* Added tests for composite transforms (e.g., hardened combination of grid and bspline transform)
* Split the transform node's huge read/write methods to separate smaller methods (one for each transform type)
* Added the option of loading a .mha file as a grid transform

Extensions updated according to the API change: OpenIGTLinkIF, SlicerIGT, SlicerRT, and TransformVisualizer. See details at:
https://github.com/openigtlink/OpenIGTLinkIF/pull/25
https://github.com/SlicerIGT/FiducialRegistrationWizard/pull/14
https://github.com/SlicerIGT/BreachWarning/pull/1
https://github.com/SlicerIGT/PivotCalibration/pull/13
https://github.com/SlicerIGT/TransformFusion/pull/2
https://www.assembla.com/spaces/slicerrt/tickets/563

Tests performed:

• All automatic tests passed (except those that are known to fail in the nightly builds)

• Load MRBrainTumor1 & MRBrainTumor2 sample
• Create model of MRBrainTumor2, threshold=50
• Linear registration with BRAINS (fixed: MRBrainTumor1 & moving: MRBrainTumor2)
• VERIFY: the resampled output image should look the same as the dynamically transformed moving volume, checked on several slices
• Save the transform as tfm from file, load the transform from file, apply the transform to the moving image
• VERIFY: the resampled output image should look the same as the dynamically transformed moving volume
• Apply transform to the model
• VERIFY: model is deformed in the 3D view, aligned with the volume slices
• Harden transform to the model
• VERIFY: model in the 3D view doesn’t change, model slice intersections are aligned with the volume
• Harden the transform on the volume
• VERIFY: the image doesn’t change too much

• BSpline registration with BRAINS (fixed: MRBrainTumor1 & moving: MRBrainTumor2)
• VERIFY: the resampled output image should look the same as the dynamically transformed moving volume
• Save the transform as tfm from file, load the transform from file, apply the transform to the moving image
• VERIFY: the resampled output image should look the same as the dynamically transformed moving volume
• Apply transform to the model
• VERIFY: model is deformed in the 3D view, aligned with the volume slices
• Harden transform to the model
• VERIFY: model in the 3D view doesn’t change, model slice intersections are aligned with the volume
• Insert linear transform between bspline and volume, move sliders
• VERIFY: volume deforms as it travels through the BSpline region
• Harden the transform on the volume
• VERIFY: the image doesn’t change too much

• Create a two markup list (each having 15 points), all but 3 in the same position
• Landwarp registration with Plastimatch with the markup lists, save the displacement field to file
• Load the displacement field
• VERIFY: the resampled output image should look the same as the dynamically transformed moving volume
• Apply the displacement field to the moving fiducials
• VERIFY: all the fiducials are now in the same position
• Harden the transform on the fiducials
• VERIFY: the fiducials don’t move
• Apply transform to the model
• VERIFY: model is deformed in the 3D view, aligned with the volume slices
• Harden transform to the model
• VERIFY: model in the 3D view doesn’t change, model slice intersections are aligned with the volume
• Harden the transform on the volume
• VERIFY: the image doesn’t change too much

• Load MRI head, create new linear transform, apply to the volume, move the sliders
• VERIFY: the volume moves in the slice viewer, the numbers change in the matrix
• Click Invert, Identity
• VERIFY: volume jumps to other side, to the center
• Connect to an OpenIGTLink server, apply a transform to a volume
• VERIFY: transform matrix values updated in transforms module, volume moves