Class AlgorithmConstPowellOptBase
- All Implemented Interfaces:
de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables,ActionListener,WindowListener,Runnable,EventListener
- Direct Known Subclasses:
AlgorithmConstPowellOpt3D
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe initial bracket size for first iteration of Powell.protected AlgorithmOptimizeFunctionBaseCost function called to measure cost - 1D.protected double[]Final point when optimization is complete.protected TransMatrixdThe transformation matrix from the origin of the input image.protected doubleThe cost of the function at the best minimum.protected intThe maximum number of iterations the optimization allows.protected ViewJProgressBarProgress bar that may be set for long optimization runs.protected intDegress of freedom.protected AlgorithmBaseParent algorithm that called this optimization.protected double[]Point that is currently being optimized.protected intWhere progress is when sent in.protected intThe max the progress can go to.protected double[]Point that was initially passed into function.protected booleanIndicates whether the Powell algorithm succeeded in finding a minimum.protected double[]Array of tolerances for each dimension.protected TransMatrixdThe transformation matrix to the origin of the input image.protected float[][]Array of translation and rotation limits for each dimension.Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmConstPowellOptBase(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. -
Method Summary
Modifier and TypeMethodDescriptionabstract TransMatrixdconvertToMatrix(double[] vector) Helper method that converts a vector with certain values set to a matrix.protected voiddebugPoint(double[] point, String message) Method to display current point values.booleanReturns whether or not a minimum was found.voidSets everything to null and prepares this class for destruction.doubleeval(double[] x) doublegetCost()Returns the cost of the best transformation.abstract double[]getFinal()Returns the final point with translations, rotations, scales, and skews representing the best Transformation.abstract double[]getFinal(double[] point) Returns the final point with translations, rotations, scales, and skews representing the best Transformation.abstract TransMatrixdReturns the matrix representing the best transformation.abstract TransMatrixdgetMatrix(double sample) Returns the matrix representing the best transformation.intdouble[]getPoint()Returns the optimized point, with length == degrees of freedom.abstract voidCalls cost function with inputed point and saves result in functionAtBest.abstract voidsetInitialPoint(double[] initial) Sets the initial point to the value passed in.abstract voidsetLimits(float[][] limits) Sets the limits on rotation and translation.voidsetMaxIterations(int max) Sets the maximum number of iterations.Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, finalize, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, runAlgorithm, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpenedMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
bracketBound
protected int bracketBoundThe initial bracket size for first iteration of Powell. -
costFunction
Cost function called to measure cost - 1D. -
finalPoint
protected double[] finalPointFinal point when optimization is complete. -
fromOrigin
The transformation matrix from the origin of the input image. -
functionAtBest
protected double functionAtBestThe cost of the function at the best minimum. -
maxIterations
protected int maxIterationsThe maximum number of iterations the optimization allows. -
myProgressBar
Progress bar that may be set for long optimization runs. -
nDims
protected int nDimsDegress of freedom. -
parent
Parent algorithm that called this optimization. -
point
protected double[] pointPoint that is currently being optimized. -
progressBegin
protected int progressBeginWhere progress is when sent in. -
progressMax
protected int progressMaxThe max the progress can go to. -
start
protected double[] startPoint that was initially passed into function. -
success
protected boolean successIndicates whether the Powell algorithm succeeded in finding a minimum. -
tolerance
protected double[] toleranceArray of tolerances for each dimension. -
toOrigin
The transformation matrix to the origin of the input image. -
trLimits
protected float[][] trLimitsArray 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 3Dbracket- the bracket bound for the first iteration of powell
-
-
Method Details
-
convertToMatrix
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
Returns the matrix representing the best transformation.- Returns:
- A matrix representing the best transformation.
-
getMatrix
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
Method to display current point values.- Parameters:
point- DOCUMENT ME!message- DOCUMENT ME!
-
eval
public double eval(double[] x) - Specified by:
evalin interfacede.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
-
getNumberOfVariables
public int getNumberOfVariables()- Specified by:
getNumberOfVariablesin interfacede.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
-