[Insight-users] LevelsetMotionRegistrationImageFilter
Luis Ibanez
luis.ibanez at kitware.com
Tue Oct 20 16:44:55 EDT 2009
Hi Kishore,
Thanks for testing the code, and for pointing out the residual problem
with the image spacing in the LevelSetMotionFunction class.
Since this is a bug, we have to fix it.
I have now added methods
* SetUseImageSpacing()
* GetUseImageSpacing()
to the LevelSetMotionImageFunction class,
along with the corresponding boolean flag,
and make the computation of line 275 to be
conditioned by this new flag.
The relevant CVS commits are:
http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/Algorithms/itkLevelSetMotionRegistrationFilter.txx?root=Insight&r1=1.6&r2=1.7&sortby=date
http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/Algorithms/itkLevelSetMotionRegistrationFunction.txx?root=Insight&r1=1.6&r2=1.7&sortby=date
http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/Algorithms/itkLevelSetMotionRegistrationFunction.h?root=Insight&r1=1.4&r2=1.5&sortby=date
and the bug entry:
http://public.kitware.com/Bug/view.php?id=9709
has been updated.
A different behavior will be observed by those who:
have set the UseImageSpacing in the filter to OFF.
but... that is fine, since the behavior they were getting
before was bogus.
Thanks
Luis
------------------------------------------------------------------------------------
On Tue, Oct 20, 2009 at 1:41 PM, Kishore Mosaliganti
<kishoreraom at gmail.com> wrote:
> Hi Luis,
>
> I checked and it is working fine now. Thanks for correcting it quickly.
>
> But I want to bring up another point. The filter has an option
> UseImageSpacingOn() and UseImageSpacingOff(). This option has no
> effect on the filter performance. In both cases, it works with
> ImageSpacingOn. If you look at line 275 in
> itlLevelsetMotionRegistrationFunction.txx, the image spacing is being
> used to calculate derivatives.
>
> I do require the usage of image spacing and so its not a problem to
> me. However, it may affect someone else.
>
> Thanks,
> Kishore
>
> On Mon, Oct 19, 2009 at 1:09 PM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>> Hi Kishore,
>>
>> I think we have found a fix for the problem that your
>> reported:
>>
>> http://public.kitware.com/Bug/view.php?id=9709
>>
>> In summary:
>>
>> The tkFiniteDifferenceImageFilter now uses the Output
>> image, instead of the Input image, as the source for
>> the Spacing parameters.
>>
>> In this way, the process should work even for the uses
>> of this filter in which a NULL input has been passed
>> to the filter.
>>
>> The fix has been committed, and the new test is now
>> passing in my local build.
>>
>>
>> If you have a chance,
>> could you please update your ITK CVS checkout
>> and try again a build of your application ?
>>
>> and...
>>
>> Please let us know how it goes
>>
>>
>>
>> Thanks
>>
>>
>> Luis
>>
>>
>>
>> -----------------------------------------------------------
>> On Sat, Oct 17, 2009 at 5:43 PM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>>> Hi Kishore,
>>>
>>> Thanks for pointing this out,
>>> and for filing the bug report.
>>>
>>> Unfortunately this class don't even have a test.
>>> So, we have started by adding a test for it,
>>> (mostly based on the test of the Demons filter).
>>>
>>> You will find this new test under:
>>>
>>> Insight/Testing/Code/Algorithms/
>>> itkLevelSetMotionRegistrationFilterTest.cxx
>>>
>>>
>>> This test is running the filter with the method
>>>
>>> UseImageSpacingOn()
>>>
>>> and we don't observe a segmentation fault as a
>>> consequence.
>>>
>>> .....
>>>
>>> In your email you say that the member variable
>>>
>>> this->m_Input,
>>>
>>>>> is a vector of 3 image pointers.
>>>
>>>
>>> For what I can see in this filter, the Input variable
>>> is actually of the same type as the InputImage
>>> type used for instantiating the filter.
>>>
>>>
>>> Could you provide a minimal example illustrating
>>> the situation in which you see that the m_Input
>>> variable is an array of images ?
>>>
>>>
>>> Thanks
>>>
>>>
>>> Luis
>>>
>>>
>>> -----------------------------------------------------------
>>> On Tue, Oct 13, 2009 at 7:36 PM, Kishore Mosaliganti
>>> <kishoreraom at gmail.com> wrote:
>>>> To add to the below problem, I initialized the filter with a 0 vector
>>>> deformation field. Now, the filter executes with ImageSpacingOn().
>>>> However, the metric values with iterations are not influenced by the
>>>> ImageSpacingOn option.
>>>>
>>>> This makes me believe the underlying implementation is not using the
>>>> image spacings.
>>>>
>>>> Kishore
>>>>
>>>> On Tue, Oct 13, 2009 at 7:13 PM, Kishore Mosaliganti
>>>> <kishoreraom at gmail.com> wrote:
>>>>> Hi all,
>>>>>
>>>>> I was using the LevelsetMotionRegistrationImageFilter to register two
>>>>> 3D image datasets whose voxels have anisotropic spacing:
>>>>>
>>>>> RegistrationFilterType::Pointer filter = RegistrationFilterType::New();
>>>>> CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New();
>>>>> filter->AddObserver( itk::IterationEvent(), observer );
>>>>> filter->SetFixedImage( fixedImage );
>>>>> filter->SetMovingImage( movingImage );
>>>>> filter->SetNumberOfIterations( 50 );
>>>>> filter->SetGradientSmoothingStandardDeviations( 0.1 );
>>>>> filter->UseImageSpacingOn();
>>>>> filter->Update();
>>>>>
>>>>> The problem is I get a Segmentation fault when I turn on
>>>>> UseImageSpacingOn(). Otherwise, the filter executes normally.
>>>>>
>>>>> I used the debugger and went into the code.
>>>>> LevelsetMotionRegistrationImageFilter is a sub-class of
>>>>> PDEDeformableRegistrationImageFilter which is a subclass of
>>>>> FiniteDifferenceImageFilter. The code failed in the
>>>>> FiniteDifferenceImageFilter::GenerateData() method in the following
>>>>> lines:
>>>>>
>>>>> ....
>>>>>
>>>>> if (this->GetState() == UNINITIALIZED)
>>>>> {
>>>>> // Set the coefficients for the deriviatives
>>>>> double coeffs[TInputImage::ImageDimension];
>>>>> if (m_UseImageSpacing)
>>>>> {
>>>>> for (unsigned int i = 0; i < TInputImage::ImageDimension; i++)
>>>>> {
>>>>> coeffs[i] = 1.0 / this->GetInput()->GetSpacing()[i];
>>>>> }
>>>>> }
>>>>> else
>>>>> {
>>>>> for (unsigned int i = 0; i < TInputImage::ImageDimension; i++)
>>>>> {
>>>>> coeffs[i] = 1.0;
>>>>> }
>>>>> }
>>>>>
>>>>> .....
>>>>>
>>>>> When I went to see the state of the input pointer, this->m_Input, it
>>>>> is a vector of 3 image pointers. Basically, this->m_Input[1] refers to
>>>>> the fixed image and this->m_Input[2] refers to the moving image.
>>>>> this->m_Input[0] is NULL. this->m_Input[0] is supposed to contain the
>>>>> initial deformation field which is not a prerequisite for running the
>>>>> code.
>>>>>
>>>>> The code in itkPDEDeformableRegistrationImageFilter::SetFixedImage()
>>>>> and itkPDEDeformableRegistrationImageFilter::SetMovingImage() call
>>>>> this->ProcessObject::SetNthInput( 1, const_cast< FixedImageType * >(
>>>>> ptr ) ) and this->ProcessObject::SetNthInput( 2, const_cast<
>>>>> FixedImageType * >( ptr ) ) respectively.
>>>>>
>>>>> This filter derives from
>>>>> ImageToImageFilter<TDeformationField,TDeformationField> but the vector
>>>>> of inputs have been set as scalar-valued fixed and moving image
>>>>> pointers. Also, for the case when the initial deformation field is
>>>>> unknown, the FiniteDifferenceFilter is checking for the first input
>>>>> which doesn't exist.
>>>>>
>>>>> I have filed a bug report:
>>>>> http://public.kitware.com/Bug/view.php?id=9709
>>>>>
>>>>>
>>>>>
>>>>> Thanks,
>>>>> Kishore
>>>>>
>>>> _____________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.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
>>>>
>>>
>>
>
More information about the Insight-users
mailing list