Class AlgorithmRegOAR25D2

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmRegOAR25D2
    extends AlgorithmBase
    This is an automatic registration method 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.

    Internal registration is performed within one 3D image.

    In adjacent mode the first slice above the reference slice is registered to the reference slice, then the second slice above the reference slice is registered to the first slice above the reference slice, and so on until the last slice is registered the next to last slice. Then, the first slice below the reference slice is registered to the reference slice, the second slice below the reference slice is registered to first slice below the reference slice, and so on until the first slice is registered to the second slice. In reference mode every slice is simply registered to the reference slice.

    Our algorithm works as follows:
    1.) We find the minimum resolution of the images.
    2.) We transform the images into isotropic voxels.
    3.) We subsample the images by 2, 4, and 8 or 16, depending on the resolution.
    We loop thru a number of iterations equal to the number of slices - 1 in adjacent mode or equal to the number of slices in reference mode with one slice as the input slice and one slice as the reference slice. For each iteration: 4.) With the slices that were subsampled by 8 or 16, we call levelEight. This function will use the coarse sampling rate and optimize translations and global scale at the given rotation. So for example, if the coarse sampling range were -30 to 30 at every 15 degrees, we would optimize at rotations of -30, -15, 0, 15, 30.
    5.) Still in levelEight, we now measure the cost at the fine sampling rate. We interpolate the translations and global scale to come up with a good guess as to what the optimized translation would be at that point.
    6.) We take the top 20% of the points and optimize them.
    7.) We now have a large multi-array of costs. 20% of those have been optimized and placed back into their original position in the multi-array. We look at the 3 neighbors of a point: +, =, or - one fine sample. If our point has a cost greater than any of these, it is not a minima. Otherwise it is. We save it in a vector of minima.
    8.) We optimize the minima over rotation as well as translations and global scale. (Previously we had not optimized over rotation.) We return two vectors, one containing the minima before optimization, one containing the minima after optimization.
    9.) We now call levelFour with the slices subsampled by 4 and the vectors of minima. We measure the costs of the minima on the new slices and sort them. We take the top numMinima in each vector (pre-optimization and post-optimization) and optimize them. We put them all into one vector.
    10.) We perturb the rotation by zero and by plus-minus fineDelta. If it's not a rigid transformation, we then perturb the global scaling by factors of 0.8, 0.9, 1.0, 1.1, and 1.2.
    11.) We optimize the perturbations. We return a vector of the perturbed, optimized minima.
    12.) We now call levelTwo with the slices subsampled by 2. We measure the costs of the minima at the new slices. We optimize the best minimum with 4 degrees of freedom, then 5, then 6. If the user has limited the degrees of freedom to 3, there will only be one optimization run, with 3 degrees of freedom. The function returns the best minimum after optimization.
    13.) We call levelOne with the un-subsampled slices. At levelOne, one optimization run is performed, with the maximum allowable degrees of freedom, as specified by the user (the max is 6).
    14.) The best answer is returned from levelOne. The inverse of the matrix from this answer is used to register the input slice to the reference slice. The registered input slice data is imported into inputImage.

    Note that when 6 degrees of freedom is used the rotation is set equal to 0 because diffX sets (0,2), diffY sets (1,2), scaleX sets (0,0), scaleY sets (1,1), skewX sets (0,1), and skewY sets (1,0) so all 6 elements are set.

    Author:
    Matthew McAuliffe, Neva Cherniavsky, Benjamin Link - Added code to use less memory. (April 2003)
    • Field Detail

      • allowLevel16

        private boolean allowLevel16
        DOCUMENT ME!
      • allowLevel2

        private boolean allowLevel2
        Flags are true if weighted image is not present or if weighted image subsampling occurred, false if weighted image subsampling did not occur.
      • allowLevel4

        private boolean allowLevel4
        DOCUMENT ME!
      • allowLevel8

        private boolean allowLevel8
        DOCUMENT ME!
      • answer

        private MatrixListItem answer
        Final answer after registration.
      • buffer

        private float[] buffer
        DOCUMENT ME!
      • bufferA

        private float[] bufferA
        DOCUMENT ME!
      • bufferIW

        private float[] bufferIW
        DOCUMENT ME!
      • bufferW

        private float[] bufferW
        DOCUMENT ME!
      • coarseNum

        private final int coarseNum
        Number of passes that will be made in the coarse sampling and fine sampling.
      • fineNum

        private final int fineNum
      • colorFactor

        private final int colorFactor
        1 for black and white, 4 for color.
      • costChoice

        private final int costChoice
        Choice of which cost function to use.
      • doColor

        private final boolean doColor
        DOCUMENT ME!
      • DOF

        private final int DOF
        Maximum degrees of freedom when running the optimization.
      • doGraph

        private final boolean doGraph
        Produce 2 output graphs - 1 for rotation and 1 for 2 translations. Only can be used for DOF == 3 and register to reference slice
      • doSubsample

        private final boolean doSubsample
        if true subsample.
      • ignoreCOG

        private final boolean ignoreCOG
        whether or not to use center of gravity for first translation.
        See Also:
        Constant Field Values
      • imageWeightIso

        private ModelImage imageWeightIso
        DOCUMENT ME!
      • input1

        private ModelImage input1
        Image used to import a slice from inputImage.
      • input2

        private ModelImage input2
        Image used to import a slice from inputImage2.
      • input3

        private ModelImage input3
        Image used to import a slice from inputImage3.
      • inputImage

        private ModelImage inputImage
        This is the image in which internal registration will be performed.
      • inputImage2

        private ModelImage inputImage2
        Other images which will not determine the registration, but which will undergo the same transformations as input image. Useful if registering a color image based on only 1 of the colors
      • inputImage3

        private ModelImage inputImage3
        DOCUMENT ME!
      • inputw_1

        private ModelImage inputw_1
        Image used to import a slice from inputWeight.
      • inputWeight

        private ModelImage inputWeight
        This gives weights for the input image - higher weights mean a greater impact in that area on the registration.
      • interp

        private final int interp
        Interpolation method used in transformations.
      • interp2

        private final int interp2
        Interpolation method used in output.
      • iResols

        private float[] iResols
        The voxel resolutions of the input image.
      • isoImage

        private ModelImage isoImage
        new to this version: must keep isoImage around if image needed to be transformed.
      • level1Factor

        private float level1Factor
        Multiplication factor for level 1 - will be set based on subsampling.
      • level2Factor

        private float level2Factor
        Multiplication factor for level 2 - will be set based on subsampling.
      • level4Factor

        private float level4Factor
        Multiplication factor for level 4 - will be set based on subsampling.
      • maxDim

        private final float maxDim
        DOCUMENT ME!
      • baseNumIter

        private final int baseNumIter
        Limits number of iterations in Powell optimization. maxIter in the call to Powell's will be an integer multiple of baseNumIter
      • numMinima

        private final int numMinima
        Number of minima from level 8 to test at level 4.
      • output_1

        private ModelImage output_1
        DOCUMENT ME!
      • output_2

        private ModelImage output_2
        DOCUMENT ME!
      • output_3

        private ModelImage output_3
        DOCUMENT ME!
      • outsidePreReferenceSlice

        private ModelImage outsidePreReferenceSlice
        DOCUMENT ME!
      • outsideReferenceSlice

        private ModelImage outsideReferenceSlice
        DOCUMENT ME!
      • refImageNo

        private int refImageNo
        Indicates the first slice used as a reference slice, if regToAdjImage is true.
      • regToAdjImage

        private boolean regToAdjImage
        If true use adjacent image for registration. If false use image slice reference number to indicate the image slice to register all images to.
      • resample

        private boolean resample
        true if resolutions unequal, false if resolutions equal.
      • resampleW

        private boolean resampleW
        true if weight image must be resampled.
      • rigidFlag

        private boolean rigidFlag
        Flag used to indicate if the registration is ridgid (rotation and translation - DOF = 3.
      • rot

        private float[] rot
        Arrays used for producing graphs for DOF == 3 and register to reference image.
      • rotateBegin

        private final float rotateBegin
        Coarse and fine sampling parameters.
      • rotateEnd

        private final float rotateEnd
        Coarse and fine sampling parameters.
      • coarseRate

        private final float coarseRate
        Coarse and fine sampling parameters.
      • fineRate

        private final float fineRate
        Coarse and fine sampling parameters.
      • simpleInput_1

        private ModelSimpleImage simpleInput_1
        Simple version of an image slice of the input image.
      • simpleInputSub16_1

        private ModelSimpleImage simpleInputSub16_1
        Simple version of an image slice of the input image, subsampled by 16.
      • simpleInputSub2_1

        private ModelSimpleImage simpleInputSub2_1
        Simple version of an image slice of the input image, subsampled by 2.
      • simpleInputSub4_1

        private ModelSimpleImage simpleInputSub4_1
        Simple version of an image slice of the input image, subsampled by 4.
      • simpleInputSub8_1

        private ModelSimpleImage simpleInputSub8_1
        Simple version of an image slice of the input image, subsampled by 8.
      • simpleRef_1

        private ModelSimpleImage simpleRef_1
        Simple version of input image.
      • simpleRefSub16_1

        private ModelSimpleImage simpleRefSub16_1
        Simple version of input image, subsampled by 16.
      • simpleRefSub2_1

        private ModelSimpleImage simpleRefSub2_1
        Simple version of input image, subsampled by 2.
      • simpleRefSub4_1

        private ModelSimpleImage simpleRefSub4_1
        Simple version of input image, subsampled by 4.
      • simpleRefSub8_1

        private ModelSimpleImage simpleRefSub8_1
        Simple version of input image, subsampled by 8.
      • simpleWeightISub16_1

        private ModelSimpleImage simpleWeightISub16_1
        DOCUMENT ME!
      • simpleWeightISub2_1

        private ModelSimpleImage simpleWeightISub2_1
        DOCUMENT ME!
      • simpleWeightISub4_1

        private ModelSimpleImage simpleWeightISub4_1
        DOCUMENT ME!
      • simpleWeightISub8_1

        private ModelSimpleImage simpleWeightISub8_1
        DOCUMENT ME!
      • simpleWeightR_1

        private ModelSimpleImage simpleWeightR_1
        Simple version of weighted input image.
      • simpleWeightRSub16_1

        private ModelSimpleImage simpleWeightRSub16_1
        Simple version of weighted input image, subsampled by 16.
      • simpleWeightRSub2_1

        private ModelSimpleImage simpleWeightRSub2_1
        Simple version of weighted input image, subsampled by 2.
      • simpleWeightRSub4_1

        private ModelSimpleImage simpleWeightRSub4_1
        Simple version of weighted input image, subsampled by 4.
      • simpleWeightRSub8_1

        private ModelSimpleImage simpleWeightRSub8_1
        Simple version of weighted input image, subsampled by 8.
      • sliceCosts

        private double[] sliceCosts
        DOCUMENT ME!
      • trans

        private float[][] trans
        DOCUMENT ME!
      • transformVOIs

        private final boolean transformVOIs
        if true transform VOIs.
      • useOutsideReferenceSlice

        private boolean useOutsideReferenceSlice
        DOCUMENT ME!
      • weighted

        private final boolean weighted
        Flag to determine if there are weighted images or not.
      • weightSliceImage

        private ModelImage weightSliceImage
        DOCUMENT ME!
    • Constructor Detail

      • AlgorithmRegOAR25D2

        public AlgorithmRegOAR25D2​(ModelImage _image,
                                   int _costChoice,
                                   int _DOF,
                                   int _interp,
                                   int _interp2,
                                   boolean mode,
                                   int refImageNum,
                                   float _rotateBegin,
                                   float _rotateEnd,
                                   float _coarseRate,
                                   float _fineRate,
                                   boolean doGraph,
                                   boolean doSubsample,
                                   boolean transformVOIs,
                                   int _baseNumIter,
                                   int _numMinima)
        Creates new automatic internal registration algorithm and sets necessary variables.
        Parameters:
        _image - Input image
        _costChoice - Choice of cost functions, like correlation ratio or mutual information.
        _DOF - Degrees of freedom for registration
        _interp - Interpolation method used in transformations.
        _interp2 - Interpolation method used in output
        mode - If true, register to adjacent. If false, register to reference.
        refImageNum - If register to reference, the slice all other slices are registered to. If register to adjacent, the first slice used as a reference.
        _rotateBegin - Beginning of coarse sampling range (i.e., -60 degrees).
        _rotateEnd - End of coarse sampling range (i.e., 60 degrees).
        _coarseRate - Point at which coarse samples should be taken (i.e., every 45 degrees).
        _fineRate - Point at which fine samples should be taken (i.e., every 15 degrees).
        doGraph - If true produce 2 output graphs - one for rotation and one for 2 translations
        doSubsample - If true subsample
        transformVOIs - If true, transform VOIs
        _baseNumIter - Limits the number of iterations of Powell's algorithm. maxIter in the call to Powell's will be an integer multiple of baseNumIter
        _numMinima - Number of minima from level 8 to test at level 4
      • AlgorithmRegOAR25D2

        public AlgorithmRegOAR25D2​(ModelImage _image,
                                   ModelImage _inputWeight,
                                   int _costChoice,
                                   int _DOF,
                                   int _interp,
                                   int _interp2,
                                   boolean mode,
                                   int refImageNum,
                                   float _rotateBegin,
                                   float _rotateEnd,
                                   float _coarseRate,
                                   float _fineRate,
                                   boolean doGraph,
                                   boolean doSubsample,
                                   boolean transformVOIs,
                                   int _baseNumIter,
                                   int _numMinima)
        Creates new automatic internal registration algorithm and sets necessary variables.
        Parameters:
        _image - Input image
        _inputWeight - Input weighted image, used to give certain areas of the image greater impact on the registration.
        _costChoice - Choice of cost functions, like correlation ratio or mutual information.
        _DOF - DOCUMENT ME!
        _interp - Interpolation method used in transformations.
        _interp2 - Interpolation method used in output
        mode - If true, register to adjacent. If false, register to reference.
        refImageNum - If register to reference, the slice all other slices are registered to. If register to adjacent, the first slice used as a reference.
        _rotateBegin - Beginning of coarse sampling range (i.e., -60 degrees).
        _rotateEnd - End of coarse sampling range (i.e., 60 degrees).
        _coarseRate - Point at which coarse samples should be taken (i.e., every 45 degrees).
        _fineRate - Point at which fine samples should be taken (i.e., every 15 degrees).
        doGraph - If true produce 2 output graphs - 1 for rotation and one for 2 translations
        doSubsample - If true subsample
        transformVOIs - If true, transform VOIs
        _baseNumIter - Limits the number of iterations of Powell's algorithm. maxIter in the call to Powell's will be an integer multiple of baseNumIter
        _numMinima - Number of minima from level 8 to test at level 4
    • Method Detail

      • calculateCenterOfMass2D

        public static WildMagic.LibFoundation.Mathematics.Vector2f calculateCenterOfMass2D​(ModelSimpleImage image,
                                                                                           ModelSimpleImage wgtImage,
                                                                                           boolean isColor)
        Calculates the center of mass (gravity) of a 2D image. In image space where the upper left hand corner of the image is 0,0. The x axis goes left to right, y axis goes top to bottom. (i.e. the right hand rule). One could simply multiply by voxel resolutions.
        Parameters:
        image - DOCUMENT ME!
        wgtImage - DOCUMENT ME!
        isColor - DOCUMENT ME!
        Returns:
        the center of mass as a 2D point
      • disposeLocal

        public void disposeLocal()
        Dispose of local variables that may be taking up lots of room.
      • finalize

        public void finalize()
        Prepares this class for destruction.
        Overrides:
        finalize in class AlgorithmBase
      • getCosts

        public double[] getCosts()
        accessor for costs.
        Returns:
        double[] costs
      • getRot

        public float[] getRot()
        accessor for rot.
        Returns:
        rot
      • getTrans

        public float[][] getTrans()
        accessor for trans.
        Returns:
        trans
      • getTransformedImage

        public ModelImage getTransformedImage()
        accessor to get the internally registered image.
        Returns:
        inputImage
      • runAlgorithm

        public void runAlgorithm()
        Runs the image registration. If the resolutions are unequal, the image is transformed into isotropic pixels. The resolutions of the two images after the xy isotropic transformation will be the same in the x and y dimensions. That resolution will equal the minimum resolution. If the image is weighted, the weight image is transformed into isotropic pixels in the same manner as the original. Then the image is subsampled by 2, 4, and 8 or 16. If the image is too small it will not be subsampled down to the smallest level; if it is too big, it will be subsampled to 16. The same is done with the weight image if necessary. The program loops thru levelEight, levelFour, levelTwo, and levelOne with one slice as the reference slice and one slice as the input slice. The function levelEight is called with the slices subsampled by 8 or 16; it returns two vectors with minima. Then the function levelFour is called with slices subsampled by 4 and the two vectors; it returns one vector of minima. The function levelTwo is called with slices subsampled by 2 and the vector; it returns an "answer" in the form of a MatrixListItem, which is a convenient way of storing the point, the matrix, and the cost of the minimum. Then the function levelOne is called with the minimum; it returns a final "answer", or minimum, which is used to register the input slice to the reference slice. The registered input slice data is imported into inputImage.
        Specified by:
        runAlgorithm in class AlgorithmBase
      • runAlgorithmTest

        public void runAlgorithmTest()
      • registerSlice

        private void registerSlice​(int rNumber,
                                   int startIndex,
                                   int endIndex,
                                   int sliceSize,
                                   int[] iExtents)
      • setInputImage2

        public void setInputImage2​(ModelImage inputImage2)
        inputImage2 is not used to determine the registration, but each slice of inputImage2 undergoes the same transformation as inputImage. This is useful for color images where you wish the registration to be determined by only 1 of the colors
        Parameters:
        inputImage2 - DOCUMENT ME!
      • setInputImage3

        public void setInputImage3​(ModelImage inputImage3)
        inputImage3 is not used to determine the registration, but each slice of inputImage3 undergoes the same transformation as inputImage. This is useful for color images where you wish the registration to be determined by only 1 of the colors
        Parameters:
        inputImage3 - DOCUMENT ME!
      • setReferenceSlice

        public boolean setReferenceSlice​(ModelImage refSlice)
        allows the user to pass in an OUTSIDE reference slice.
        Parameters:
        refSlice - 2-Dim image for reference
        Returns:
        DOCUMENT ME!
      • subSample2DimBy2

        private static ModelSimpleImage subSample2DimBy2​(ModelSimpleImage srcImage,
                                                         ModelSimpleImage resultImage,
                                                         boolean isColor)
        DOCUMENT ME!
        Parameters:
        srcImage - DOCUMENT ME!
        resultImage - DOCUMENT ME!
        isColor - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • copyFloatData

        private static void copyFloatData​(ModelSimpleImage srcImage,
                                          ModelSimpleImage resultImage)
        DOCUMENT ME!
        Parameters:
        srcImage - DOCUMENT ME!
        resultImage - DOCUMENT ME!
      • getConstructionInfo

        private java.lang.String getConstructionInfo()
        Creates a string with the parameters that the image was constructed with.
        Returns:
        Construction info.
      • getTolerance

        private double[] getTolerance​(int DOF)
        Gets the tolerance vector based on the degrees of freedom (the length of the tolerance is the degrees of freedom) and.
        Parameters:
        DOF - Degrees of freedom, will be length of vector.
        Returns:
        New tolerance vector to send to optimization.

        Based on FLIRT paper: let n=pixel dimension (in one dimension) R=brain radius, here assumed to be half of field-of-view Translation tolerance = n/2 Rotation tolerance = (180/PI)*n/(2R) (converted to degrees because AlgorithmPowell works in degrees) Scaling tolerance = n/(2R) Skewing tolerance = n/(2R)

      • getTolerance

        private static double[] getTolerance​(int DOF,
                                             boolean rigidFlag,
                                             float maxDim)
      • interpolate

        private void interpolate​(double x,
                                 double[] initial,
                                 double[][] tranforms,
                                 boolean scale)
        Performs a bilinear interpolation on points. Takes an initial point, a vector of values to set, and an array in which to look at neighbors of that point. Sets the appropriate values in the vector. Does not set scale if the scale parameter is false.
        Parameters:
        x - Initial index into array.
        initial - Vector to set; if scale is true, set two translations and a scale. Otherwise just set translations.
        tranforms - DOCUMENT ME!
        scale - true means set the scale in the vector.
      • interpolate

        private static void interpolate​(double x,
                                        double[] initial,
                                        double[][] tranforms,
                                        boolean scale,
                                        int coarseNum)
      • levelEight

        private java.util.Vector<MatrixListItem>[] levelEight​(ModelSimpleImage ref,
                                                              ModelSimpleImage input)
        Takes two slices that have been subsampled by a factor of 8 or 16. Sets up the cost function with the slices and the weighted slices, if necessary. Uses the coarse sampling rate and optimize translations and global scale at the given rotation. So for example, if the coarse sampling range were -30 to 30 at every 15 degrees, we would optimize at rotations of -30, -15, 0, 15, 30. Measures the cost at the fine sampling rate. Interpolates the translations and global scale to come up with a good guess as to what the optimized translation would be at that point. Takes the top 20% of the points and optimizes them. Now have a large multi-array of costs. 20% of those have been optimized and placed back into their original position in the multi-array. Looks at the 3 neighbors of a point: +, =, or - one fine sample. If the point has a cost greater than any of these, it is not a minima. Otherwise it is. Saves it in a vector of minima. Optimizes the minima over rotation as well as translations and global scale. (Previously had not optimized over rotation.) Returns two vectors, one containing the minima before optimization, one containing the minima after optimization.
        Parameters:
        ref - Subsampled by 8 or 16 reference slice.
        input - Subsampled by 8 or 16 input slice.
        Returns:
        List of preoptimized and optimized points.
      • levelFour

        private java.util.Vector<MatrixListItem> levelFour​(ModelSimpleImage ref,
                                                           ModelSimpleImage input,
                                                           java.util.Vector<MatrixListItem> minima,
                                                           java.util.Vector<MatrixListItem> optMinima)
        Takes two slices that have been subsampled by a factor of four, and two vectors of minima. Sets up the cost function with the slices and the weighted slices, if necessary. Adds the level4Factor determined during subsampling. Measures the costs of the minima on the images and sort them. Takes the top three in each vector (pre-optimization and post-optimization) and optimizes them. Puts them all into one vector. Perturbs the rotation by zero and by plus-minus fineDelta. If it's not a rigid transformation, perturbs the scales by 0, plus-minus .1, then plus-minus .2. Optimize the perturbations. Returns a vector of the perturbed, optimized minima.
        Parameters:
        ref - Reference slice, subsampled by 4.
        input - Input slice, subsampled by 4.
        minima - Preoptimized minima.
        optMinima - DOCUMENT ME!
        Returns:
        A vector of perturbed, optimized minima.
      • levelOne

        private MatrixListItem levelOne​(ModelSimpleImage ref,
                                        ModelSimpleImage input,
                                        MatrixListItem item,
                                        int frame)
        Takes the two slices, no subsampling, and the best minimum so far. Sets up the cost function with the slices and the weighted slices, if necessary. Adds the level1Factor determined during subsampling. Performs one optimization run, with the maximum allowable degrees of freedom as specified by the user (the max is 7). Returns the best minimum.
        Parameters:
        ref - Reference slice.
        input - Input slice.
        item - Best minimum so far.
        frame - DOCUMENT ME!
        Returns:
        Best minimum after optimization.
      • levelOne2D

        private MatrixListItem levelOne2D​(ModelSimpleImage ref,
                                          ModelSimpleImage input)
        This routine is used only with DOF = 2, translations only. LevelEight, levelFour, and levelTwo are skipped Takes the two slices, no subsampling. Sets up the cost function with the slices and the weighted slices. Adds the level1Factor determined during subsampling. Performs one optimization run, with 2 degrees of freedom
        Parameters:
        ref - Reference slice.
        input - Input slice.
        Returns:
        Best minimum after optimization.
      • levelTwo

        private MatrixListItem levelTwo​(ModelSimpleImage ref,
                                        ModelSimpleImage input,
                                        java.util.Vector<MatrixListItem> minima)
        Takes two slices that have been subsampled by a factor of 2 and a vector of minima. Sets up the cost function with the images and the weighted images, if necessary. Adds the level2Factor determined during subsampling. Measures the costs of the minima at the images. Optimizes the best minimum with 4 degrees of freedom, then 5, then 7. If the user has limited the degrees of freedom to 3, there will only be one optimization run, with 3 degrees of freedom. Returns the best minimum after optimization.
        Parameters:
        ref - Reference slice, subsampled by 2.
        input - Input slice, subsampled by 2.
        minima - Minima.
        Returns:
        The optimized minimum.
      • levelEightMultiThread

        private static java.util.Vector<MatrixListItem>[] levelEightMultiThread​(ModelSimpleImage ref,
                                                                                ModelSimpleImage input,
                                                                                int DOF,
                                                                                boolean rigidFlag,
                                                                                float maxDim,
                                                                                int baseNumIter,
                                                                                float rotateBegin,
                                                                                float rotateEnd,
                                                                                float coarseRate,
                                                                                float fineRate,
                                                                                int coarseNum,
                                                                                int fineNum,
                                                                                int costChoice,
                                                                                boolean doColor,
                                                                                boolean ignoreCOG,
                                                                                boolean weighted,
                                                                                boolean allowLevel16,
                                                                                ModelSimpleImage simpleWeightRSub16_1,
                                                                                ModelSimpleImage simpleWeightRSub8_1,
                                                                                ModelSimpleImage simpleWeightISub16_1,
                                                                                ModelSimpleImage simpleWeightISub8_1)
      • levelFourMultiThread

        private static java.util.Vector<MatrixListItem> levelFourMultiThread​(ModelSimpleImage ref,
                                                                             ModelSimpleImage input,
                                                                             java.util.Vector<MatrixListItem> minima,
                                                                             java.util.Vector<MatrixListItem> optMinima,
                                                                             int numMinima,
                                                                             int DOF,
                                                                             boolean rigidFlag,
                                                                             float maxDim,
                                                                             int baseNumIter,
                                                                             float rotateBegin,
                                                                             float rotateEnd,
                                                                             float coarseRate,
                                                                             float fineRate,
                                                                             int coarseNum,
                                                                             int fineNum,
                                                                             int costChoice,
                                                                             boolean doColor,
                                                                             boolean ignoreCOG,
                                                                             boolean weighted,
                                                                             float level4Factor,
                                                                             ModelSimpleImage simpleWeightRSub4_1,
                                                                             ModelSimpleImage simpleWeightISub4_1)
      • levelTwoMultiThread

        private static MatrixListItem levelTwoMultiThread​(ModelSimpleImage ref,
                                                          ModelSimpleImage input,
                                                          java.util.Vector<MatrixListItem> minima,
                                                          int numMinima,
                                                          int DOF,
                                                          boolean rigidFlag,
                                                          float maxDim,
                                                          int baseNumIter,
                                                          float rotateBegin,
                                                          float rotateEnd,
                                                          float coarseRate,
                                                          float fineRate,
                                                          int coarseNum,
                                                          int fineNum,
                                                          int costChoice,
                                                          boolean doColor,
                                                          boolean ignoreCOG,
                                                          boolean weighted,
                                                          float level2Factor,
                                                          ModelSimpleImage simpleWeightRSub2_1,
                                                          ModelSimpleImage simpleWeightISub2_1)
      • levelOneMultiThread

        private static MatrixListItem levelOneMultiThread​(ModelSimpleImage ref,
                                                          ModelSimpleImage input,
                                                          MatrixListItem item,
                                                          int frame,
                                                          int DOF,
                                                          boolean rigidFlag,
                                                          float maxDim,
                                                          int baseNumIter,
                                                          float rotateBegin,
                                                          float rotateEnd,
                                                          float coarseRate,
                                                          float fineRate,
                                                          int coarseNum,
                                                          int fineNum,
                                                          int costChoice,
                                                          boolean doColor,
                                                          boolean ignoreCOG,
                                                          boolean weighted,
                                                          float level1Factor,
                                                          ModelSimpleImage simpleWeightR_1,
                                                          ModelSimpleImage simpleWeightI_1,
                                                          double[] sliceCosts)
      • levelOne2DMultiThread

        private static MatrixListItem levelOne2DMultiThread​(ModelSimpleImage ref,
                                                            ModelSimpleImage input,
                                                            int frame,
                                                            int DOF,
                                                            boolean rigidFlag,
                                                            float maxDim,
                                                            int baseNumIter,
                                                            float rotateBegin,
                                                            float rotateEnd,
                                                            float coarseRate,
                                                            float fineRate,
                                                            int coarseNum,
                                                            int fineNum,
                                                            int costChoice,
                                                            boolean doColor,
                                                            boolean ignoreCOG,
                                                            boolean weighted,
                                                            float level1Factor,
                                                            ModelSimpleImage simpleWeightR_1,
                                                            ModelSimpleImage simpleWeightI_1,
                                                            double[] sliceCosts)