[Insight-users] Problem with MultiResMIRegistration [And the VNL behaviour under Cygwin]

Karthik Krishnan Karthik.Krishnan at kitware.com
Tue Dec 7 14:53:37 EST 2004


Hi Fong,

Your problem is related to the minor descripency in VNL behaviour in 
Cygwin. I've given a temporary fix below that should make your code 
work, before we commit those changes. Thanks for pointing out.

Just add the line
    ReinitializeSeed();
in the constructor MutualInformationImageToImageMetric < , > 
::MutualInformationImageToImageMetric()

Now your code should work fine with Cygwin. If you want to know why, 
read the explanation below:

Basically the family of pseudo-random generators, ie drand48(), 
lrand48(), or mrand48(), seem to behave differently under different 
operating systems. Strictly speaking, before any calls to these 
functions are made, we need to go through initialization entry points, 
srand48(), seed48() and lcong48() respectively to initialize the seed. 
Now, on most compilers relax this behaviour and supply a default seed. 
Cygwin's gcc does not. So all calls to vnl_sample_normal, 
vnl_sample_uniform etc failed in Cygwin since they are often called 
without seeding in ITK.

Your MultiresMIRegistration example uses the 
MutualInformationImageToImageMetric, which uses a 
ImageRandomConstIteratorWithIndex to randomly pick evaluation points. 
VNL is used to generate these random numbers.

A more exact solution would be to replace ReinitializeSeed() with 
ReinitializeSeed(vcl_time(0)). This does a quasi-random initialization. 
You will now need to include the file "vcl_ctime.h"

Thanks
Hope this helps
karthik


Fong Ming Hooi wrote:

> Hello,
>
>  
>
> I'm having some trouble with the MultiResMIRegistration program.  I'm 
> using the input of BrainWebT1toT2b.txt and have been getting this 
> corresponding output:  
>
>  
>
> Output:
>
> Parsing input ...
>
> Fixed image filename: 
> C:\ITKFiles\ITKAppBin2\MultiResMIRegistration\brainweb165a10f17.mha
>
> Moving image filename: 
> C:\ITKFiles\ITKAppBin2\MultiResMIRegistration\brainweb1e5a10f17Rot10Tx15.mha
>
> Permute order: [0, 1, 2]
>
> Flip axes: [0, 0, 0]
>
> Number of levels: 5
>
> Fixed image shrink factors: [4, 4, 1]
>
> Moving image shrink factors: [8, 8, 1]
>
> Number of iterations: [2500, 2500, 2500, 2500, 2500]
>
> Learning rates: [0.0001, 1e-05, 5e-06, 1e-06, 5e-07]
>
> Translation scale: 320
>
> Output filename: t1tot2.mhd
>
>  
>
> Preprocess the images ...
>
> Register the images ...
>
> --- Starting level 0
>
>  No. Iterations: 2500 Learning rate: 0.0001
>
> --- Starting level 1
>
>  No. Iterations: 2500 Learning rate: 1e-05
>
> --- Starting level 2
>
>  No. Iterations: 2500 Learning rate: 5e-06
>
> --- Starting level 3
>
>  No. Iterations: 2500 Learning rate: 1e-06
>
> --- Starting level 4
>
>  No. Iterations: 2500 Learning rate: 5e-07
>
> Final parameters: [0, 0, 0, 1, 0, 0, 0]
>
> Overall transform matrix:
>
> 1 0 0
>
> 0 1 0
>
> 0 0 1
>
>  
>
> Overall transform offset:
>
> [0, 0, 0]
>
> Generating output ...
>
>  
>
>  
>
> The output image is unchanged from the moving image.   Does anyone 
> have any advice as to what I can do to troubleshoot this?  I've built 
> the ITK 1.8 framework using cygwin along with FLTK 1.1.4 and Qt 2.3.1 
> as well.  Also, the Hello World example works fine along with the 
> Registration examples.   
>
>  
>
> Thanks,
>
> Fong Ming
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>  
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20041207/e95f09d6/attachment.html


More information about the Insight-users mailing list