[Insight-users] Re: seg fault

Christos Panagiotou C.Panagiotou at cs.ucl.ac.uk
Mon, 12 Apr 2004 16:47:48 +0100


Luis Ibanez wrote:

>
> Hi Christos,
>
> Just to double check...
>
> What you want to do is to use the Multi-Resolution framework
> and change the transfrom when you change resolution levels.
> Is that correct ?


-----
 Dear Luis
 i am just trying to add an observer... to return the metric values
 so i can check how it converges so i can later on use this to
 optimize the learning rates and the steplength...
 nothing more or nothing less. What I ve done is i just added
 the CommandIteratationUpdate class as seen in the 
/examples/registration/MultiResImageRegistration1.cxx
 and i am using it by adding:

  CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New();
  m_Optimizer->AddObserver( itk::IterationEvent(), m_Observer );


>
> -- 
>
> Here is a guess of what may be happening:
>
> The Optimizers communicate with the CostFunction (in this case
> the ImageMetric) by passing an array of parameters. This array
> is declared to be of type:   itk::Array< double >
>
> This is a dynamic array whose size is defined at run time.
> When you run an optimizer with a particular cost function
> the optimizer prepares a number of internal variables to
> deal with the number of elements of this parameters array.
> If you change the cost function at run-time, care has to
> be taken to ensure that the optimizer resizes all the
> variables that rely on the size of the parameters array.
>
> In the case of registration, the number of parameters of the
> cost function is directly the array of Transform parameters.
>
> When you change the Transform at run time, you are probably
> changing the number of parameters that the optimizer is
> receiving. The segmentation faults that you observe may be
> the consequence of not giving the optimizer a chance to
> reinitialize the variables that deal with the size of the
> parameters array.
>
> The changes in the settings for learning rates if probably
> unrelated to your problem. It is unlikely that changing the
> learning rate may lead to a seg. fault.
>
> ....
>
> A couple of questions:
>
> 1) What Transforms are you using at every level of the pyramid ?


    it is an affine transform...

>
> 2) When you get the seg. fault. What are the transforms being
>    used in the previous and next level of the pyramid ?


    affine all the way

>
> 3) Where in the code are you replacing the Transform ?
>    (file, line number, and please: ITK Version !)

+---
    I dont alter the transform i just initialize it as you have 
suggested in previous emails
    and i assign it to the registration method using:

    registration->SetTransform(     transform     );

    i dont interfere with the transform after that... i let the 
optimizer do it (and it worked
    until i added the observer!)

   i initaly alter the transform type from rigid body to affine in 
MIMRegistrator.h
   and modified the MIMRegistrator.txx to work with the affine (for example
   i modified the loop that applies the translation scaling from rigid body:

  for ( int j = 4; j < 7; j++ )
    {
    scales[j] = m_TranslationScale;
    }

to affine (the last three parameters)

  for ( int j = 9; j < 12; j++ )
    {
    scales[j] = m_TranslationScale;
    }

and other small alterations

+---
    my ITK version is 1.6.0
+---
    everything takes place in the MultiResMIRegistration application in 
files:
    MIMRegistrator.txx, .h and I have also added a .h file where i 
define the commandIterationUpdate class which
    i then include and use in the MIMRegistrator.h and use it in 
MIMRegistrator.txx
   

>
> 4) How are you restarting the Optimizer once that you have
>    replaced the transform ?

    as i said i dont alter the transform during the optimization


finally Two more questions:
a.    I tried to replace the MI image to image metric with the 
normalized histogram
    (before i added the observer - when the first metric was giving me 
results (not the best but it was working) )
    when i used the normalized histogram MI metric i was still getting 
the overlap exception..
    i thought the normalized histogram MI metric is supposed to be 
INVARIANT from selections in learning rates
    etc. am i wrong?
b.   is there an optimizer in ITK that uses line search? is it the 
regular step optimizer? i haven't really read their implementations

   
  
sorry for the long reading
thanks very much for your fast reply
christos