Class AlgorithmConstPowellOpt3D

  • 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 AlgorithmConstPowellOpt3D
    extends AlgorithmConstPowellOptBase
    Runs Powell's method for a 3D image. Check the parent class comment for more detailed information.
    Version:
    0.1 Oct 1, 2001
    Author:
    Neva Cherniavsky
    • Constructor Detail

      • AlgorithmConstPowellOpt3D

        public AlgorithmConstPowellOpt3D​(AlgorithmBase parent,
                                         WildMagic.LibFoundation.Mathematics.Vector3f com,
                                         int degreeOfFreedom,
                                         AlgorithmOptimizeFunctionBase costFunc,
                                         double[] initial,
                                         double[] tols,
                                         int maxIter,
                                         int bracketBound)
        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.
        initial - Initial point to start from, length of 12.
        tols - Tolerance for each dimension (tols.length == degreeOfFreedom).
        maxIter - Maximum number of iterations.
        bracketBound - DOCUMENT ME!
    • Method Detail

      • convertToMatrix

        public TransMatrixd convertToMatrix​(double[] vector)
        Helper method to take the "point" we've been working with as a vector, and convert it into a transformation matrix. The length of the vector should be equal to the global variable nDims, which in turn was initialized by the degrees of freedom originally sent to this algorithm. Therefore, if there are 3 degrees of freedom, we set only the translations; 4 means translation and global scaling; 6 means rotation and translation; 7 means rotation, translation, and global scaling; 9 means rotation, translation, and scaling; and 12 means rotation, translation, scaling, and skewing.
        Specified by:
        convertToMatrix in class AlgorithmConstPowellOptBase
        Parameters:
        vector - Vector that represented a "point" in the algorithm which needs to be converted to a matrix.
        Returns:
        The transformation matrix created from the vector.
      • convertToMatrixHalf

        public TransMatrixd convertToMatrixHalf​(double[] vector)
        Helper method to take the "point" we've been working with as a vector, and convert it into a transformation matrix. The length of the vector should be equal to the global variable nDims, which in turn was initialized by the degrees of freedom originally sent to this algorithm. Therefore, if there are 3 degrees of freedom, we set only the translations; 4 means translation and global scaling; 6 means rotation and translation; 7 means rotation, translation, and global scaling; 9 means rotation, translation, and scaling; and 12 means rotation, translation, scaling, and skewing.
        Parameters:
        vector - Vector that represented a "point" in the algorithm which needs to be converted to a matrix.
        Returns:
        The transformation matrix created from the vector.
      • convertToMatrixMidsagittal

        public TransMatrixd convertToMatrixMidsagittal​(double[] vector)
        Helper method to take the "point" we've been working with as a vector, and convert it into a transformation matrix. The length of the vector should be equal to the global variable nDims, which in turn was initialized by the degrees of freedom originally sent to this algorithm. Therefore, if there are 3 degrees of freedom, we set only the translations; 4 means translation and global scaling; 6 means rotation and translation; 7 means rotation, translation, and global scaling; 9 means rotation, translation, and scaling; and 12 means rotation, translation, scaling, and skewing.
        Parameters:
        vector - Vector that represented a "point" in the algorithm which needs to be converted to a matrix.
        Returns:
        The transformation matrix created from the vector.
      • getFinal

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

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

        public double[] getFinal​(float sample)
        Accessor that returns the final point with translations, rotations, scales, and skews representing the best tranformation.
        Parameters:
        sample - the voxel resolution
        Returns:
        vector representing the best transformation in terms of translations, rotations, scales, and skews.
      • getMatrix

        public TransMatrixd getMatrix​(double sample)
        Accessor that 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.
        Specified by:
        getMatrix in class AlgorithmConstPowellOptBase
        Parameters:
        sample - the voxel resolution
        Returns:
        matrix representing the best transformation.
      • getMatrixHalf

        public TransMatrixd getMatrixHalf()
        Accessor that returns the matrix representing the best tranformation. All of the components of the transformation are halved from the 'best transformation' matrix.
        Returns:
        matrix representing the best transformation with its components halved.
      • getMatrixHalf

        public TransMatrixd getMatrixHalf​(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. All of the components of the transformation are halved from the 'best transformation' matrix.
        Parameters:
        sample - the voxel resolution
        Returns:
        matrix representing the best transformation with its components halved.
      • getMatrixMidsagittal

        public TransMatrixd getMatrixMidsagittal()
        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​(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.
      • runAlgorithm

        public void runAlgorithm()
        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 golden search. It then resets the point and minimizes again, until the point moves by less than the tolerance. This method 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".
        Specified by:
        runAlgorithm in class AlgorithmBase
      • setInitialPoint

        public void setInitialPoint​(double[] initial)
        Sets the initial point to the value passed in.
        Specified by:
        setInitialPoint in class AlgorithmConstPowellOptBase
        Parameters:
        initial - Initial point.
      • setLimits

        public void setLimits​(float[][] limits)
        Sets the limits on rotation and translation.
        Specified by:
        setLimits in class AlgorithmConstPowellOptBase
        Parameters:
        limits - limits
      • setProgressBar

        public void setProgressBar​(ViewJProgressBar progress,
                                   int begin,
                                   int max)
        Accessor that sets the progress bar so it can be updated from here.
        Parameters:
        progress - DOCUMENT ME!
        begin - Value of progress bar when sent here.
        max - Maximum value allowed.