[Insight-users] trouble using the bulktransform
Erik Türke
tuerke at cbs.mpg.de
Sun Feb 28 17:15:54 EST 2010
Luis Ibanez wrote:
> Hi Erik,
>
>
> Why are you using a static_cast in ?:
>
>
> m_BSplineTransform->SetBulkTransform(
> static_cast<VersorRigid3DTransformType*> (initialTransform));
>
>
> That static_cast should be necessary.
>
> ---
>
> I suspect that the problem is mostly related to
> the initialization of the BSpline Transform itself.
>
> Particularly related to the image Direction.
>
>
> You may want to use the following class:
>
> Insight/Code/Review/
> itkBSplineDeformableTransformInitializer.h
> itkBSplineDeformableTransformInitializer.txx
>
>
> That is described in this Insight Journal paper:
>
>
> "Helper class for initializing the grid parameters of a
> BSpline deformable transform by using an image as reference"
> http://www.insight-journal.org/browse/publication/216
> http://hdl.handle.net/1926/1338
>
>
> Note that is simply a complement to the use of the
> Bulk Transform, not a replacement for it.
>
>
>
> Regards,
>
>
>
> Luis
>
>
>
> -----------------------------------------------------------------------
> On Fri, Feb 26, 2010 at 10:42 AM, Erik Türke <tuerke at cbs.mpg.de> wrote:
>
>> Hi!
>>
>> I am trying to use the SetBulkTransform method of the
>> BSplineDeformableTransform.
>>
>> The two images which i want to register are totally shifted, so i want to
>> use a simple translation as the bulk transform.
>>
>> So what i am doing is:
>>
>> m_BSplineTransform->SetBulkTransform(static_cast<VersorRigid3DTransformType*>
>> (initialTransform));
>>
>> If i print out the parameters of the initialTransform with:
>>
>> std::cout << static_cast<VersorRigid3DTransformType*>
>> (initialTransform)->GetParameters() << std::endl;
>>
>> the output is: [0, 0, 0, 96.2941, 92.5804, 38.6559], what is totally right.
>>
>> Now i setup the BSplineTransform:
>>
>> typedef typename BSplineTransformType::RegionType
>> BSplineRegionType;
>> typedef typename BSplineTransformType::SpacingType
>> BSplineSpacingType;
>> typedef typename BSplineTransformType::OriginType
>> BSplineOriginType;
>> typedef typename BSplineTransformType::DirectionType
>> BSplineDirectionType;
>>
>> BSplineRegionType bsplineRegion;
>> typename BSplineRegionType::SizeType gridSizeOnImage;
>> typename BSplineRegionType::SizeType gridBorderSize;
>> typename BSplineRegionType::SizeType totalGridSize;
>>
>> gridSizeOnImage.Fill(UserOptions.BSplineGridSize);
>> gridBorderSize.Fill(3); //Border for spline order = 3 (1
>> lower, 2 upper)
>> totalGridSize = gridSizeOnImage + gridBorderSize;
>>
>> bsplineRegion.SetSize(totalGridSize);
>> BSplineSpacingType bsplineSpacing =
>> m_FixedImage->GetSpacing();
>>
>> BSplineOriginType bsplineOrigin = m_FixedImage->GetOrigin();
>>
>> typename FixedImageType::SizeType fixedImageSize =
>> m_FixedImage->GetBufferedRegion().GetSize();
>>
>> for (unsigned int r = 0; r < FixedImageDimension; r++) {
>> bsplineSpacing[r] *= static_cast<double>
>> (fixedImageSize[r] - 1) / static_cast<double> (gridSizeOnImage[r]
>> - 1);
>> }
>>
>> BSplineDirectionType bsplineDirection =
>> m_FixedImage->GetDirection();
>> BSplineSpacingType gridOriginOffset = bsplineDirection *
>> bsplineSpacing;
>>
>> bsplineOrigin = bsplineOrigin - gridOriginOffset;
>>
>> m_BSplineTransform->SetGridSpacing(bsplineSpacing);
>> m_BSplineTransform->SetGridOrigin(bsplineOrigin);
>> m_BSplineTransform->SetGridRegion(bsplineRegion);
>> m_BSplineTransform->SetGridDirection(bsplineDirection);
>>
>> typedef typename BSplineTransformType::ParametersType
>> BSplineParametersType;
>>
>> m_NumberOfParameters =
>> m_BSplineTransform->GetNumberOfParameters();
>>
>> BSplineParametersType bsplineParameters(m_NumberOfParameters);
>> bsplineParameters.Fill(0.0);
>>
>> m_BSplineTransform->SetParameters(bsplineParameters);
>>
>> m_RegistrationObject->SetInitialTransformParameters(m_BSplineTransform->GetParameters());
>> If i now start the registration with 1 iteration, the result is
>> totally shifted again.
>> I am sure, the initial transform is right, because i got those values by
>> using the itk initializer class and tested the values as the initial
>> parameters of a VersorRigid3DTransform with iterations= 0 as well.
>> With the VersorRigid3DTransform, the images are aligned.
>> Why is the bulktransform not working here?
>>
>> I becoming a little desperate now :-( . Can somebody give me a hint?
>>
>> Thanks!
>>
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
Hi!
I was recognizing the same, when i browsed the examplecode.
But unfortunately that is not the source of trouble.
It is quiet odd, but tomorrow i will examine my code for the 10 th time :-)
Thanks anyway!
More information about the Insight-users
mailing list