[Insight-users] Re: seg fault

Luis Ibanez luis.ibanez at kitware.com
Mon, 12 Apr 2004 10:14:19 -0400


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 ?

--

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 ?

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

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

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


Thanks


    Luis


--------------------------
Christos Panagiotou wrote:

> dear luis
> 
> to remind: i am trying to alter the MultiResMIRegistration application 
> to work with affine transformation
> as i ve told i have problems of achieving the desired results so i ve 
> added an observer to the optimizer using
> the CommandIterationUpdate class found in the examples/registration/ *.cxx
> 
> imediately when the iterations start, i receive a seg fault
> i used the ddd debugger as you ve proposed in a similar problem and got 
> the following output:
> 
> -------------------------
> Fixed image filename: mr1.mha
> Big Endian: 0
> Image Size: [256, 256, 136]
> Image Spacing: [1, 1, 1]Moving image filename: ot_100x120x138.mha
> Big Endian: 0
> Image Size: [100, 120, 138]
> Image Spacing: [1, 1, 1]Permute order: [1, 2, 0]Flip axes: [1, 0, 
> 0]Number of levels: 4
> Fixed image shrink factors: [4, 4, 1]Moving image shrink factors: [2, 2, 
> 1]Number of iterations: [500, 500, 500, 500]Learning rates: [1e-04, 
> 1e-05, 5e-06, 1e-06]Translation scale: 350
> PGM directory: pettopd
> 
> Preprocess the images ...
> Need to permute: [1, 2, 0]Need to flip: [1, 0, 0]Register the images ...
> --- Starting level 0
> No. Iterations: 500 Learning rate: 1e-04
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -1084448096 (LWP 3010)]
> 0x0029051a in itk::SubjectImplementation::InvokeEvent(itk::EventObject 
> const&, itk::Object*) () from /usr/local/lib/InsightToolkit/libITKCommon.so
> (gdb)
> ----------------------------
> 
> i ve seen in a similar post that i need two instances of the optimizer 
> if i want to modify the cost function during the optimization procedure
> 
> in the MultiResMIRegistration application i use the 
> gradientdescentoptimizer and the learning rates change through the 
> following code:
> 
>  typedef SimpleMemberCommand<Self> CommandType;
>  typename CommandType::Pointer command = CommandType::New();
>  command->SetCallbackFunction( this, &Self::StartNewLevel );
> 
> where the StartNewLevel method changes the learning rates
> 
> i am not sure if this has something to do about it, but i am stack with 
> the seg fault and i am not sure why i am getting it...
> 
> any help would be appreciated
> 
> thanks
> christos
>