Class AlgorithmConstPowellOptBase

java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.AlgorithmConstPowellOptBase
All Implemented Interfaces:
de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables, ActionListener, WindowListener, Runnable, EventListener
Direct Known Subclasses:
AlgorithmConstPowellOpt3D

public abstract class AlgorithmConstPowellOptBase extends AlgorithmBase implements de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
Powell's Method

Runs Powell's method. Powell's method is a way to find minimums without finding derivatives. Basically, it starts at some point P in N-dimensional space, proceeds in a direction, and minimizes along that line using a 1-dimensional minimization method. It continues like this until the point has moved by less than the tolerance. It starts with the initial point defined in the constructor and initial directions of (1 0 ... 0) (0 1 0 ... ) ..., the basis vectors. At the end, "point" is the best point found and functionAtBest is the value at "point".

This is an abstract class which contains many of the basic functions needed to run Powell's method. 2D and 3D versions extend this version.

This optimization technique is based on FLIRT. FLIRT stands for FMRIB's Linear Image Registration Tool. For more information on FLIRT, visit their homepage at http://www.fmrib.ox.ac.uk/fsl/flirt/. Their main paper is:

Jenkinson, M. and Smith, S. (2001a).
A global optimisation method for robust affine registration of brain images.
Medical Image Analysis, 5(2):143-156.

Version:
0.1 Oct 1, 2001
Author:
Neva Cherniavsky
  • Field Details

    • bracketBound

      protected int bracketBound
      The initial bracket size for first iteration of Powell.
    • costFunction

      protected AlgorithmOptimizeFunctionBase costFunction
      Cost function called to measure cost - 1D.
    • finalPoint

      protected double[] finalPoint
      Final point when optimization is complete.
    • fromOrigin

      protected TransMatrixd fromOrigin
      The transformation matrix from the origin of the input image.
    • functionAtBest

      protected double functionAtBest
      The cost of the function at the best minimum.
    • maxIterations

      protected int maxIterations
      The maximum number of iterations the optimization allows.
    • myProgressBar

      protected ViewJProgressBar myProgressBar
      Progress bar that may be set for long optimization runs.
    • nDims

      protected int nDims
      Degress of freedom.
    • parent

      protected AlgorithmBase parent
      Parent algorithm that called this optimization.
    • point

      protected double[] point
      Point that is currently being optimized.
    • progressBegin

      protected int progressBegin
      Where progress is when sent in.
    • progressMax

      protected int progressMax
      The max the progress can go to.
    • start

      protected double[] start
      Point that was initially passed into function.
    • success

      protected boolean success
      Indicates whether the Powell algorithm succeeded in finding a minimum.
    • tolerance

      protected double[] tolerance
      Array of tolerances for each dimension.
    • toOrigin

      protected TransMatrixd toOrigin
      The transformation matrix to the origin of the input image.
    • trLimits

      protected float[][] trLimits
      Array of translation and rotation limits for each dimension.
  • Constructor Details

    • AlgorithmConstPowellOptBase

      public AlgorithmConstPowellOptBase(AlgorithmBase parentAlgo, int degreeOfFreedom, AlgorithmOptimizeFunctionBase costFunc, double[] initial, double[] tols, int maxIter, int coords, int bracket)
      Constructs a new algorithm with the given centers of mass (needed for setting the transformations), the given cost function (which was constructed with the proper images), the initial point we're looking at, and some tolerance within that point to look for the minimum. The initial point contains rotations, translations, scales, and skews.
      Parameters:
      parentAlgo - DOCUMENT ME!
      degreeOfFreedom - Degree of freedom for transformation (must be 3, 4, 6, 7, 9, or 12).
      costFunc - Cost function to use.
      initial - Initial point to start from, length of 12.
      tols - Tolerance for each dimension (tols.length == degreeOfFreedom).
      maxIter - The maximum iterations.
      coords - 2 or 3 for 2D or 3D
      bracket - the bracket bound for the first iteration of powell
  • Method Details

    • convertToMatrix

      public abstract TransMatrixd convertToMatrix(double[] vector)
      Helper method that converts a vector with certain values set to a matrix. For values not set, uses those in start variable.
      Parameters:
      vector - Point with possible rotations, translations, etc. set.
      Returns:
      Matrix representation of that point.
    • getFinal

      public abstract double[] getFinal()
      Returns the final point with translations, rotations, scales, and skews representing the best Transformation.
      Returns:
      A vector representing the best transformation in terms of translations, rotations, scales, and skews.
    • getFinal

      public abstract double[] getFinal(double[] point)
      Returns the final point with translations, rotations, scales, and skews representing the best Transformation.
      Returns:
      A vector representing the best transformation in terms of translations, rotations, scales, and skews.
    • getMatrix

      public abstract TransMatrixd getMatrix()
      Returns the matrix representing the best transformation.
      Returns:
      A matrix representing the best transformation.
    • getMatrix

      public abstract TransMatrixd getMatrix(double sample)
      Returns the matrix representing the best transformation. The passed in parameter represents the resolution (same in all directions and for both input and reference images, since resampled isotropically). Since the optimization was done in pixel space, not millimeter space, the translation parameters need to be scaled by the sample value.
      Parameters:
      sample - Sample size.
      Returns:
      A matrix representing the best transformation.
    • measureCost

      public abstract void measureCost()
      Calls cost function with inputed point and saves result in functionAtBest.
    • setInitialPoint

      public abstract void setInitialPoint(double[] initial)
      Sets the initial point to the value passed in.
      Parameters:
      initial - Initial point.
    • setLimits

      public abstract void setLimits(float[][] limits)
      Sets the limits on rotation and translation.
      Parameters:
      limits - limits
    • didSucceed

      public boolean didSucceed()
      Returns whether or not a minimum was found.
      Returns:
      whether or not a minimum was found.
    • disposeLocal

      public void disposeLocal()
      Sets everything to null and prepares this class for destruction.
    • getCost

      public double getCost()
      Returns the cost of the best transformation.
      Returns:
      The cost of the best transformation.
    • getPoint

      public double[] getPoint()
      Returns the optimized point, with length == degrees of freedom.
      Returns:
      The optimized point.
    • setMaxIterations

      public void setMaxIterations(int max)
      Sets the maximum number of iterations.
      Parameters:
      max - The max number of iterations.
    • debugPoint

      protected void debugPoint(double[] point, String message)
      Method to display current point values.
      Parameters:
      point - DOCUMENT ME!
      message - DOCUMENT ME!
    • eval

      public double eval(double[] x)
      Specified by:
      eval in interface de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
    • getNumberOfVariables

      public int getNumberOfVariables()
      Specified by:
      getNumberOfVariables in interface de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables