Page MenuHomePhabricator

Affine registration not compatible with ImageAccessors
Closed, ResolvedPublic

Description

How to reproduce:
> Open two images, select them and activate the "Rigid Registration View"
> Hit the 'Register' button ( this takes the default settings from the advanced view )

On windows, there is an immediate crash. On linux64, the 'Attempt for recursive lock' exception from ImageAccessor is shown in a dialog. So it is an issue with usage of CastToItk and similar functions.

Related Objects

Event Timeline

The recursive attemt originates from a CastToItkImage call nested into an AccessByItk call. The AccessByItk call gets the WriteAccess to the whole image and so does the CastToItkImage. When nested, this causes the dead-lock.

The Cast is needed for the itk::CenteredTransformInitializer which computes the initial position.

(1) the parameter of the

QmitkAffineTransformView::GetTransform2(itk::Image<TPixelType, VImageDimension>* itkImage1)

was not used in the body of the method, the call to AccesByItk was solely there to estimate the types. By assigning the parameter to the image (ITK) variable fixedImage we avoid the dead-lock on one hand and make no duplicated procedures and template instantiation on the other.

(2) both FixedImageType and MovingImageType are the same, so also the

mitk::CastToItkImage(m_MovingImage, movingImage);

is not needed. Simply use mitk::ImageToItk< MovingImageType >() call instead. This again reduces the template instantiation amount.

Not only the AffineTransform is affected. Several of the remaining transforms have the same problematic call.

-> For 2D Transforms: We use the AccessFixedDimension macro since we know that only 2D can be processed. The remaining part is the same.

New remote branch pushed: bug-14626-Recursive-ImageAccessorCall-AffineRegistration

[fc28d4]: Merge branch 'bug-14626-Recursive-ImageAccessorCall-AffineRegistration

Merged commits:

2013-03-06 17:24:50 Jan Hering [63c7cd]
Replaced nested calls to ImageAccessor for 3D transforms

  • fixed image set to the passed parameter, moving image created by the
  • ImageToItk filter instead of CastToItk since the type of the output is
  • known

2013-03-06 17:21:25 Jan Hering [74ef8e]
Replacing nested ImageAccessor calls in 2D Transform

  • using the parameter passed into the function for setting the fixed
  • image, using ImageToItk filter insted Cast for moving
  • also switched from AccessByItk to AccessFixedDimension (2) since the

called method expects 2D