[Insight-users] DeformableRegistration4.cxx error?

Dawood Masslawi masslawi at gmail.com
Tue Mar 22 10:47:18 EDT 2011


Glad to hear that :)
Tuning an optimization is completely application specific. The purpose of registration, 
the images and the used components should be all matched together to get the best
results. Most of the time this is a trial-and-error process, but in general you should 
consider the following. 
First thing to figure out is parameter setting of the B-Spline transformation, in particular
number of grid nodes (grid size), large number of grid nodes will result in a more smooth
deformation but with higher computational cost. In my experince starting with a grid size of
5-6 (2 grid size on image + 3 border grid size) seems to have good results, based on the
resulting deformation optimal grid size can be assigned.
Once you figure out the transformation parameters the optimization parameters can be
tuned, first thing to do is to scale the registration parameters so values of different range
have a normalized effect on the optimization (e.g. DeformableRegistration15.cxx) and then
start evaluating the registration with the default parameters and with low number of
iterations, cost function evaluations and corrections (e.g. #iterations 50, #function
evaluations 100 and #corrections 10), this way you can avoid computational overload.
Usually during the evaluation initial estimate of other optimization parameters is obtained,
five main parameters that should be tuned (common to most optimizers) are gradient 
tolerance, cost function convergence factor, min/max step lengths and relaxation factor.
Gradient tolerance determines a lower threshold which cuases the optimization to stop if its
value reached, recommended values for gradient tolerance are 1e-6 to 1e-10, higher values
might result in premature elimination of the optimization process. The optimizer stops if the
reduction of the cost function value is lower than the assigned convergence factor, lower
values have higher accuracy, usual range of convergence factor values are, 1e+1 (high
accuracy), 1e+7 (moderate accuracy) and 1e+12 (low accuracy). Min and max (initial) step
lengths determine the allowed range of step length changes, for noisy metrics usually min
step length is high so the optimizer would not fall into the local extrema, range of values for
min/max step lengths are between 0.001and 0.1. The relaxation factor controls the rate
which step lengths are reduced, lower values will shrink the step length which also might
result in a local exrema (range of values= 0.5-10.0). The first optimization parameter to tune
is the convergence factor then gradient tolerance and after that the step lenghts and
relaxation factor, notice that it is best to start with the default values which lower the
computation time and continue from there. You can also assign a lower and upper bound for
the optimization search space with the SetLower/UpperBound method. Other parameter
settings are ralated to the type of metric used and they also should be considered with
regards to accuracy and computation time. I think this is just about enough to get things
working, if other memebers have any additional information that I have missed it would be
great to share it with us. 
P.S., each of the aforementioned parameters and methods are specific to certain optimizers
and some may not be supported by a certain optimizer.
Best regards,
Dawood
--- On Mon, 3/21/11, Brecht Heyde <Brecht.Heyde at med.kuleuven.be> wrote:

From: Brecht Heyde <Brecht.Heyde at med.kuleuven.be>
Subject: RE: [Insight-users] DeformableRegistration4.cxx error?
To: "Dawood Masslawi" <masslawi at gmail.com>
Cc: "insight-users at itk.org" <insight-users at itk.org>
Date: Monday, March 21, 2011, 8:43 AM

Hi Dawood,

Thanks for the suggestion. I reran the example and it seems to work just fine: the borders of the rat lungs seems to be mapped unto each other after registration.

Do you have any suggestions in tuning optimizer parameters in the context of B-spline registration?

Best regards,
Brecht
________________________________________
From: insight-users-bounces at itk.org [insight-users-bounces at itk.org] On Behalf Of Dawood Masslawi [masslawi at gmail.com]
Sent: 19 March 2011 15:04
To: Brecht Heyde
Cc: insight-users at itk.org
Subject: Re: [Insight-users] DeformableRegistration4.cxx error?

Hi Brecht,

The "DeformableRegistration13.cxx" example uses the RegularStepGradientDescent

optimizer for 2D images. Using the same settings should work for your code.

Good luck,

Dawood


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<



Hi all,

I forgot to mention that I found a similar post on the ITK user list back in 2009: http://itk-insight-users.2283740.n2.nabble.com/Problem-with-DeformableRegistration4-cxx-example-td3218635.html

Has anything been resolved since then? I'll try rerunning the example with a RegularStepGradientDescent optimizer.
Has anyone found any acceptable settings for the optimizer? Something along the lines of:
optimizer->MinimizeOn();
optimizer->SetMaximumStepLength(2.00);
optimizer->SetMinimumStepLength(0.001);
optimizer->SetNumberOfIterations(200);

Where and how would you start tuning this optimizer for this fairly large amount of parameters (already in 2D)?

Regards,
Brecht
________________________________________
From: Brecht Heyde
Sent: 18 March 2011 20:20
To: insight-users at itk.org<http://www.itk.org/mailman/listinfo/insight-users>
Cc: Brecht Heyde
Subject: DeformableRegistration4.cxx error?

Dear all,

I just tried running Examples/Registration/DeformableRegistration4.cxx/.
Is it normal that the stop condition of the LBFGS optimizer gives me an error: "vnl_lbfgs: Error. Netlib routine lbfgs failed."?

Also, I compared the differences after registration and they are still fairly large (see attachments)

Please find the output of the program below:

--
>DeformableRegistration4 ..\..\data\RatLungSlice1.mha ..\..\data\RatLungSlice2.mha ..\..\data\RatLungSlice2deformed.mha ..\..\data\differenceoutput.mha ..\..\data\differencebefore.mha ..\..\data\deformfield.mha

Intial Parameters =
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0]

Starting Registration
*************************************************
  N=128   NUMBER OF CORRECTIONS=5       INITIAL VALUES F= 169.433   GNORM= 16.0675
*************************************************
   I   NFN    FUNC        GNORM       STEPLENGTH
   1    2       139.836       9.070       0.062
   2    3       127.553      10.676       1.500
   3    4       113.837       8.462       1.500
   4    5        98.974       5.939       1.500
   5    6        94.611       4.260       1.500
   6    7        93.683       1.780       1.500
   7    8        92.602       1.161       1.500
   8    9        91.093       1.608       1.500
   9   10        90.869       1.485       1.500
  10   12        90.796       1.187       0.228
  11   14        90.717       0.954       0.220
  12   16        90.694       0.822       0.129
  13   18        90.666       0.720       0.125
 IFLAG= -1  LINE SEARCH FAILED. SEE DOCUMENTATION OF ROUTINE MCSRCH ERROR RETURN OF LINE S
EARCH: INFO= 3 POSSIBLE CAUSES: FUNCTION OR GRADIENT ARE INCORRECT OR INCORRECT TOLERANCES
vnl_lbfgs: Error. Netlib routine lbfgs failed.
Optimizer stop condition = LBFGSOptimizer: Failure
Last Transform Parameters
[0.011861, 0.0530738, -0.114476, -0.0014865, 0.0148372, -0.0549163, -0.00438914, 0, 0.1025
66, 0.502715, -0.762941, 0.35145, 0.153952, -0.63219, -0.0498668, 0, 0.00738199, 0.0666841
, 0.570735, -0.0706879, -0.17164, -0.115005, -0.0396254, 0, 0.0192471, 0.09889, -0.943169,
 -0.647905, 0.172792, -0.181095, 0.0226301, 0, 0.050406, 0.190277, -0.870343, 0.320529, 0.
489361, -0.130754, 0.0165127, 0, -0.00494977, 0.0367683, -0.134814, -0.0234467, -0.487765,
 -0.12967, -0.00325786, 0, -0.00218239, -0.0164876, -0.00720033, 0.013605, -0.0421713, -0.
00401046, -0.000156239, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.000118737, -0.027066, -0.0382732, 0.0
483314, 0.121524, 0.0467903, 0.000733309, 0, -0.0314756, -0.494522, -0.152103, 0.605314, 0
.417874, 0.0194144, 0.00334922, 0, -0.00976682, 0.459453, 1.36226, 0.784408, -0.443754, -0
.712014, -0.000740298, 0, 0.051106, -0.530244, -3.37043, -2.10846, 0.0149461, 0.0297596, -
0.00694551, 0, 0.0164421, -0.761362, -2.79346, -2.53847, -0.683093, 0.206363, -0.00512468,
 0, 0.0233849, 0.154342, -0.42728, -1.65801, -1.25134, -0.0402723, 0.00227039, 0, 0.000605
736, 0.00629161, -0.0126661, -0.176088, -0.174036, -0.00030687, 0.00118331, 0, 0, 0, 0, 0,
 0, 0, 0, 0]
          Probe Tag    Starts    Stops             Time (s)
        Registration           1            1           28.9173
          Probe Tag    Starts    Stops           Memory (kB)
        Registration           1            1               396

--
CMakeLists.txt
PROJECT( RegistrationExamples )

CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )

# Find ITK
IF ( NOT EXISTS ${ITK_BINARY_DIR} )
  SET( ITK_BINARY_DIR "" CACHE PATH "Path to ITK binary folder" )
  MESSAGE( FATAL_ERROR "ITK binary directory ${ITK_BINARY_DIR} does not exist!" )
ELSE()
     #Manually include ITKConfig.cmake and UseITK.cmake.
     #This is also done if ITK is found automatically: IF(ITK_FOUND) includes FindITK.cmake from C:\CMake 2.8\share\cmake-2.8\Modules
     #In FindITK.cmake ITKConfig.cmake and UseITK.cmake are included
  MESSAGE ( STATUS "Including ITKConfig.cmake" )
  INCLUDE ( ${ITK_BINARY_DIR}/ITKConfig.cmake )
  MESSAGE ( STATUS "Including UseITK.cmake" )
  INCLUDE ( ${ITK_BINARY_DIR}/UseITK.cmake )
ENDIF()
MESSAGE( STATUS "ITK binary directory: ${ITK_BINARY_DIR}" )

ADD_EXECUTABLE(DeformableRegistration4 DeformableRegistration4.cxx )
TARGET_LINK_LIBRARIES(DeformableRegistration4 ITKIO ITKNumerics ITKStatistics ITKAlgorithms ITKBasicFilters ITKFEM)
--

Does anyone see any problems here?
Thanks!

Best regards,
Brecht Heyde





      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110322/ea38d94b/attachment-0001.htm>


More information about the Insight-users mailing list