[Insight-users] trouble using the bulktransform
Erik Tuerke
tuerke at cbs.mpg.de
Thu Mar 4 05:19:48 EST 2010
Erik Türke wrote:
> Erik Türke wrote:
>> 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!
>> _____________________________________
>> 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 have one more question regarding the bulktransform.
>
> My bulk transform has the following parameters: 0.945735, 0.113925,
> -0.00285777, -0.079356, 1.00047, -0.103143, 0.0578154, 0.0547296,
> 0.993574, 92.1006, 93.1594, 40.8156
>
> Now i start the registration and print out the last transform
> parameters. But this transform only contains values below 1.
> Isnt the translation (92.1006, 93.1594, 40.8156) stored in the last
> transform parameters?? Or are they just lost?
>
> Or are the translation stored in the FixedParameters, which after the
> registration looks like [8, 8, 8, -119.25, 149.25, -121.25, 39.75,
> 49.75, 39.75, -3.42285e-08, -5.23956e-25, 1, 3.06152e-17, -1,
> 5.23956e-25, 1, 3.06152e-17, 3.42285e-08] ?
>
> Thanks a lot!
>
>
>
> _____________________________________
> 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!
Now i am realizing, that the bulktransform method works fine!
I think the problem is the resampling process.
The translation of the transform is stored in the fixedparameters of the
bsplineDeformable transform, is that right?
But when i manipulate fixed parameters, this has not any effect on the
resampling result.
The shift of the resampled image remains the same. However, if i
manipulate the fixed parameters of an affine transform, the resampling
result changes.
Is this normal??
Thanks
More information about the Insight-users
mailing list