Package gov.nih.mipav.model.algorithms
Class AlgorithmPowellOpt3D
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmPowellOptBase
-
- gov.nih.mipav.model.algorithms.AlgorithmPowellOpt3D
-
- All Implemented Interfaces:
de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
,java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmPowellOpt3D extends AlgorithmPowellOptBase
Runs Powell's method for a 3D image. Check the parent class comment for more detailed information.- Version:
- 0.1 Oct 1, 2001, 0.2 March 27, 2008
- Author:
- Neva Cherniavsky, Hailong Wang, Ph.D
-
-
Field Summary
-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmPowellOptBase
costFunction, dof, fromOrigin, maxIterations, parallelPowell, parent, pathRecorded, paths, points, savedStartPoint, tolerance, toOrigin, useJTEM
-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description AlgorithmPowellOpt3D(AlgorithmBase parent, WildMagic.LibFoundation.Mathematics.Vector3f com, int degreeOfFreedom, AlgorithmOptimizeFunctionBase costFunc, double[] tols, int maxIter)
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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
adjustTranslation(TransMatrixd mat, double sample)
Adjust the translation of the transformation matrix by the sample pararmeter.double[]
constructPoint(double[] defaultPoint, double[] point)
Construct a full 12-dimension transformation vector from the partial transformation vector.TransMatrixd
convertToMatrix(TransMatrixd toOrigin, TransMatrixd fromOrigin, double[] vector)
Convert a 12-dimension transformation vector to a 4x4 transformation matrix.double[]
convertToMidsagittal(double[] point)
Converts a full transformation vector into a midsagittal transformation vector.double[]
extractPoint(double[] startPoint)
Extract the partial or full transformation vector from the start transformation vector, which will be optimized.TransMatrixd
getMatrix(double[] point, double sample)
TransMatrixd
getMatrix(int index, double sample)
Obtain the transformation vector and convert to the matrix representation, then scale the translation by sample.TransMatrixd
getMatrixHalf(int index)
Obtain the transformation vector, scale it by 0.5, then convert it to transformation matrix.TransMatrixd
getMatrixHalf(int index, double sample)
Obtain the transformation vector, scale it by 0.5, then convert it to transformation matrix and scale the translations by sample parameter.TransMatrixd
getMatrixMidsagittal(int index)
Accessor that returns the matrix representing the best tranformation.TransMatrixd
getMatrixMidsagittal(int index, double sample)
Accessor that returns the matrix representing the best tranformation.void
updatePoint(double[] point, double cost, Vectornd v)
Store the optimal point and cost to v-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmPowellOptBase
convertToMatrix, convertToMatrix, copyPoint, createTerrain, disposeLocal, eval, getCost, getFromOrigin, getMatrix, getMaxIterations, getNumberOfVariables, getPoint, getPoint, getPoints, getToOrigin, isParallelPowell, isPathRecorded, lineMinimization, measureCost, measureCost, optimize, optimizeBlock, print, runAlgorithm, scalePoint, scalePoint, setMaxIterations, setParallelPowell, setPathRecorded, setPoints, setUseJTEM
-
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, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods 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, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Constructor Detail
-
AlgorithmPowellOpt3D
public AlgorithmPowellOpt3D(AlgorithmBase parent, WildMagic.LibFoundation.Mathematics.Vector3f com, int degreeOfFreedom, AlgorithmOptimizeFunctionBase costFunc, double[] tols, int maxIter)
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.
-
-
Method Detail
-
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.- Specified by:
constructPoint
in classAlgorithmPowellOptBase
- Parameters:
defaultPoint
- a default full 12-dimension transformation vector.point
- a partial or full transformation vector.- Returns:
- a full transformation vector.
-
convertToMatrix
public TransMatrixd convertToMatrix(TransMatrixd toOrigin, TransMatrixd fromOrigin, double[] vector)
Convert a 12-dimension transformation vector to a 4x4 transformation matrix.- Specified by:
convertToMatrix
in classAlgorithmPowellOptBase
- Parameters:
vector
- a 12-dimension transformation vector including 3 rotations, translations, scalings and skews.toOrigin
- the matrix translating the origin to some specified pointfromOrigin
- the matrix translating the origin back.- 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.- Specified by:
extractPoint
in classAlgorithmPowellOptBase
- 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, double sample)
Description copied from class:AlgorithmPowellOptBase
Obtain the transformation vector and convert to the matrix representation, then scale the translation by sample.- Specified by:
getMatrix
in classAlgorithmPowellOptBase
- Parameters:
index
- the index of transformation vector.sample
- the translation scaling parameter.- Returns:
- the scaled transformation matrix.
- See Also:
AlgorithmPowellOptBase.getMatrix(int, double)
-
getMatrix
public TransMatrixd getMatrix(double[] point, double sample)
-
adjustTranslation
public void adjustTranslation(TransMatrixd mat, double sample)
Description copied from class:AlgorithmPowellOptBase
Adjust the translation of the transformation matrix by the sample pararmeter.- Specified by:
adjustTranslation
in classAlgorithmPowellOptBase
- Parameters:
mat
- the transformation matrixsample
- the resolution adjusting parameter.- See Also:
AlgorithmPowellOptBase#adjustTranslation(TransMatrix, double)
-
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.
-
getMatrixHalf
public TransMatrixd getMatrixHalf(int index, double 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.
-
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, double 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)
Description copied from class:AlgorithmPowellOptBase
Store the optimal point and cost to v- Specified by:
updatePoint
in classAlgorithmPowellOptBase
- Parameters:
point
- the optimal point.cost
- the optimal cost.v
- the Vectornd variable used by upper level algorithm.- See Also:
AlgorithmPowellOptBase.updatePoint(double[], double, Vectornd)
-
-