Class AlgorithmELSUNCOpt3D

java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.AlgorithmELSUNCOpt3D
All Implemented Interfaces:
ActionListener, WindowListener, Runnable, EventListener

public class AlgorithmELSUNCOpt3D extends AlgorithmBase
Runs ELSUNC, LEVENBERG_MARQUARDT, or NL2SOL for a 3D image.

Based on ELSUNC allowed by the author with acknowledgement:

Gauss-Newton Based Algorithms For Constrained Nonlinear Least Squares Problems by Per Lindstrom and Per-Ake Wedin, Institute of Information Processing, University of Umea, S-901 87 Umea, Sweden This can be downleaded from http://www.cs.umu.se/~perl/reports/alg.ps.gz

Version:
0.1 March 23, 2012
Author:
William Gandler
  • Field Details

    • ELSUNC

      private final int ELSUNC
      See Also:
    • LEVENBERG_MARQUARDT

      private final int LEVENBERG_MARQUARDT
      See Also:
    • NL2SOL

      private final int NL2SOL
      See Also:
    • searchAlgorithm

      private int searchAlgorithm
    • nDims

      private int nDims
      Degress of freedom.
    • costFunction

      private AlgorithmOptimizeFunctionBase costFunction
      Cost function called to measure cost - 1D.
    • OARTolerance

      private double[] OARTolerance
      Array of tolerances for each dimension.
    • maxIterations

      private int maxIterations
      The maximum number of iterations the optimization allows.
    • parent

      private AlgorithmBase parent
      Parent algorithm that called this optimization.
    • toOrigin

      private TransMatrixd toOrigin
      The transformation matrix to the origin of the input image.
    • fromOrigin

      private TransMatrixd fromOrigin
      The transformation matrix from the origin of the input image.
    • points

      private Vectornd[] points
      Array used to hold the initial points, final points and costs
    • functionAtBest

      private double functionAtBest
      The cost of the function at the best minimum.
    • minFunctionAtBest

      private double minFunctionAtBest
    • eModel

    • nModel

    • lmModel

    • status

      private int status
    • start

      private double[] start
      Point that was initially passed into function.
    • epsilon

      private double epsilon
    • huge

      private double huge
  • Constructor Details

    • AlgorithmELSUNCOpt3D

      public AlgorithmELSUNCOpt3D(AlgorithmBase parent, WildMagic.LibFoundation.Mathematics.Vector3f com, int degreeOfFreedom, AlgorithmOptimizeFunctionBase costFunc, double[] tols, int maxIter, int searchAlgorithm)
      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, some tolerance within that point to look for the minimum, and the maximum number of iterations.
      Parameters:
      parent - Algorithm that called this optimization.
      com - Center of Mass of the input image.
      degreeOfFreedom - Degree of freedom for transformation (must be 3, 4, 6, 7, 9, or 12).
      costFunc - Cost function to use.
      tols - Tolerance for each dimension (tols.length == degreeOfFreedom).
      maxIter - Maximum number of iterations.
      searchAlgorithm - ELSUNC, LEVENBERG_MARQUARDT, or NL2SOL;
  • Method Details

    • disposeLocal

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

      public Vectornd[] getPoints()
      Return an array of transformation vector. The meanings of those transformation vector are as following: the initial transformation vector: before algorithm is performed the final transformation vector: after algorithm was performed.
      Returns:
    • setPoints

      public void setPoints(Vectornd[] points)
      Sets the transformation vectors.
      Parameters:
      points - the transformation vectors.
    • runAlgorithm

      public void runAlgorithm()
      Description copied from class: AlgorithmBase
      Actually runs the algorithm. Implemented by inheriting algorithms.
      Specified by:
      runAlgorithm in class AlgorithmBase
    • runELSUNC

      public void runELSUNC()
      Runs ELSUNC along one dimension at a time as long as the costFunction improves during one cycle of runs along every dimension.
    • runNL2sol

      private void runNL2sol()
    • dfault

      private void dfault(int[] iv, double[] v)
    • runLM

      private void runLM()
      Runs Levneberg-Marqaurdt along one dimension at a time as long as the costFunction improves during one cycle of runs along every dimension.
    • constructPoint

      public double[] constructPoint(double[] defaultPoint, double[] point)
      Construct a full 12-dimension transformation vector from the partial transformation vector. For missing values in point, the values in defaultPoint will be used. Different degree of freedom has different meanings: 3: only 3 translations 4: 3 translation and global scaling 6: 3 rotations and translations 7: 3 rotations and translations, and global scaling 9: 3 rotations, translations and scalings 12: 3 rotations, translations, scalings and skewings.
      Parameters:
      defaultPoint - a default full 12-dimension transformation vector.
      point - a partial or full transformation vector.
      Returns:
      a full transformation vector.
    • getFinal

      public double[] getFinal(double[] point)
      Accessor that returns the final point with translations, rotations, scales, and skews representing the best tranformation.
      Returns:
      vector representing the best transformation in terms of translations, rotations, scales, and skews.
    • convertToMatrix

      public TransMatrixd convertToMatrix(TransMatrixd toOrigin, TransMatrixd fromOrigin, double[] vector)
      Convert a 12-dimension transformation vector to a 4x4 transformation matrix.
      Parameters:
      vector - a 12-dimension transformation vector including 3 rotations, translations, scalings and skews.
      Returns:
      a 4x4 transformation matrix
    • extractPoint

      public double[] extractPoint(double[] startPoint)
      Extract the partial or full transformation vector from the start transformation vector, which will be optimized.
      Parameters:
      startPoint - the start full 12-dimension transformation vector.
      Returns:
      the partial or full transformation vector which will be optimized.
    • getMatrix

      public TransMatrixd getMatrix(int index, float sample)
      See Also:
    • getMatrix

      public final TransMatrixd getMatrix(int index)
      Obtain the transformation vector and convert to the matrix representation.
      Parameters:
      index - the index of transformation vector.
      Returns:
      the transformation matrix
    • convertToMatrix

      public TransMatrixd convertToMatrix(double[] vector)
      Convert a transformation vector to a transformation matrix.
      Parameters:
      vector - a transformation vector.
      Returns:
      a transformation matrix
    • measureCost

      public final double measureCost(double[] point)
    • getCost

      public final double getCost(int index)
      Returns the cost for the transformation vector.
      Parameters:
      index - the index of transformation vector.
      Returns:
      the cost for the transformation vector.
    • getPoint

      public double[] getPoint(int index)
      Return the full transformation vector.
      Parameters:
      index - the index of the transformation vector.
      Returns:
      the full transformation vector.
    • getPoint

      public double[] getPoint(int index, float sample)
      Obtain the transformation vector and adjust its translation by sample parameters.
      Parameters:
      index - the index of transformation vector.
      sample - the translation scaling parameter.
      Returns:
      the translation scaled transformation vector.
    • getMatrix

      public TransMatrixd getMatrix(double[] point, float sample)
      See Also:
    • adjustTranslation

      public void adjustTranslation(TransMatrixd mat, float sample)
      See Also:
      • invalid reference
        AlgorithmPowellOptBase#adjustTranslation(TransMatrix, float)
    • getMatrixHalf

      public TransMatrixd getMatrixHalf(int index)
      Obtain the transformation vector, scale it by 0.5, then convert it to transformation matrix.
      Parameters:
      index - the index of transformation vector.
      Returns:
      the scaled transformation matrix.
    • scalePoint

      public static final double[] scalePoint(double[] point, double scale)
      Scale the point by scale parameter and store it into another vector.
      Parameters:
      point - the transformation vector.
      scale - the scale parameter.
      Returns:
      the scaled transformation vector
    • scalePoint

      public final double[] scalePoint(int index, double scale)
      Obtain the transformation vector and make a copy, then scale it by scale parameter.
      Parameters:
      index - the index of transformation vector
      scale - the scale parameter
      Returns:
      the new scaled transformation vector.
    • getMatrixHalf

      public TransMatrixd getMatrixHalf(int index, float sample)
      Obtain the transformation vector, scale it by 0.5, then convert it to transformation matrix and scale the translations by sample parameter.
      Parameters:
      index - the index of transformation vector.
      sample - the translation scaling parameter.
      Returns:
      the scaled transformation matrix.
    • convertToMidsagittal

      public double[] convertToMidsagittal(double[] point)
      Converts a full transformation vector into a midsagittal transformation vector.
      Parameters:
      point - the full 12-dimension transformation vector.
      Returns:
      the transformation vector complying with midsagittal alignment algorithm.
    • copyPoint

      public static final double[] copyPoint(double[] point)
      Make a copy of the transformation vector
      Parameters:
      point - a transformation vector.
      Returns:
      the copy of the transformation vector.
    • getMatrixMidsagittal

      public TransMatrixd getMatrixMidsagittal(int index)
      Accessor that returns the matrix representing the best tranformation. This transformation contains only the z rotation and the x and y translation, to be used in the midsagittal alignment algorithm.
      Returns:
      matrix representing the best transformation's z rot and x and y trans.
    • getMatrixMidsagittal

      public TransMatrixd getMatrixMidsagittal(int index, float sample)
      Accessor that returns the matrix representing the best tranformation. 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. This transformation contains only the z rotation and the x and y translation, to be used in the midsagittal alignment algorithm.
      Parameters:
      sample - the voxel resolution
      Returns:
      matrix representing the best transformation's z rot and x and y trans.
    • updatePoint

      public void updatePoint(double[] point, double cost, Vectornd v)
      See Also:
    • setMaxIterations

      public void setMaxIterations(int max)
      Accessor that sets the maximum number of iterations.
      Parameters:
      max - The max number of iterations.
    • getMaxIterations

      public int getMaxIterations()