Class AlgorithmRegOAR35D
- java.lang.Object
- 
- java.lang.Thread
- 
- gov.nih.mipav.model.algorithms.AlgorithmBase
- 
- gov.nih.mipav.model.algorithms.registration.AlgorithmRegOAR35D
 
 
 
- 
- All Implemented Interfaces:
- java.awt.event.ActionListener,- java.awt.event.WindowListener,- java.lang.Runnable,- java.util.EventListener
 
 public class AlgorithmRegOAR35D 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 4D image. In adjacent mode the first volume above the reference volume is registered to the reference volume, then the second volume above the reference volume is registered to the first volume above the reference volume, and so on until the last volume is registered the next to last volume. Then, the first volume below the reference volume is registered to the reference volume, the second volume below the reference volume is registered to first volume below the reference volume, and so on until the first volume is registered to the second volume. In reference mode every volume is simply registered to the reference volume. In average mode every volume is simply registered to the average of all the volumes. 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.
 Subsampling can be in x, y, and z or in only x and y. We loop thru a number of iterations equal to the number of volumes - 1 for adjacent mode or equal to the number of volumes in average or reference mode with one volume as the input volume and one volume as the reference volume.
 For each iteration:
 4.) With the volumes 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 9 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 volumes subsampled by 4 and the vectors of minima. We measure the costs of the minima on the new volumes 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 volumes subsampled by 2. We measure the costs of the minima at the new volumes. We optimize the best minimum with 7 degrees of freedom, then 9, then 12. If the user has limited the degrees of freedom to 6, there will only be one optimization run, with 6 degrees of freedom. The function returns the best minimum after optimization.
 13.) We call levelOne with the un-subsampled volumes. At levelOne, one optimization run is performed, with the maximum allowable degrees of freedom, as specified by the user (the max is 12).
 14.) The best answer is returned from levelOne. The inverse of the matrix from this answer is used to register the input volume to the reference volume. The registered input volume data is imported into inputImage.
 Only subsample if 16 or more z slices are present, so that the number of z slices will not be reduced below 8. - Author:
- Matthew McAuliffe, Neva Cherniavsky, Benjamin Link - Added code to use less memory. (April 2003)
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description (package private) classAlgorithmRegOAR35D.MatrixListItemHelper class to make it easy to store the necessary information about a minimum.
 - 
Field SummaryFields Modifier and Type Field Description private static intADJACENTDOCUMENT ME!private booleanallowLevel16XYDOCUMENT ME!private booleanallowLevel16ZDOCUMENT ME!private booleanallowLevel2XYFlags are true if weighted image is not present or if weighted image subsampling occurred, false if weighted image subsampling did not occur.private booleanallowLevel2ZDOCUMENT ME!private booleanallowLevel4XYDOCUMENT ME!private booleanallowLevel4ZDOCUMENT ME!private booleanallowLevel8XYDOCUMENT ME!private booleanallowLevel8ZDOCUMENT ME!private AlgorithmRegOAR35D.MatrixListItemanswerFinal answer after registration.private static intAVERAGEDOCUMENT ME!private intbaseNumIterLimits number of iterations in Powell optimization. maxIter in the call to Powell's will be an integer multiple of baseNumIterprivate float[]bufferDOCUMENT ME!private float[]bufferADOCUMENT ME!private float[]bufferIWDOCUMENT ME!private float[]bufferWDOCUMENT ME!private booleancalcCOGIf true calculate the center of gravity (mass) and use the difference to intialize the translation.private intcoarseNumNumber of passes that will be made in the coarse sampling and fine sampling.private floatcoarseRateCoarse and fine sampling parameters.private intcolorFactor1 for black and white, 4 for color.private intcostChoiceChoice of which cost function to use.private booleandoColorDOCUMENT ME!private intDOFMaximum degrees of freedom when running the optimization.private booleandoGraphProduce 2 output graphs - 1 for 3 rotations and 1 for 3 translations.private booleandoJTEMTurns the full version of Powell's algorithm on/off.private booleandoMultiThreadprivate booleandoSubsampleif true subsample.private booleanfastModeIf true this algorithm skips all subsample and goes directly to the level 1 optimization.private intfineNumNumber of passes that will be made in the coarse sampling and fine sampling.private floatfineRateCoarse and fine sampling parameters.private ModelImageimageWeightIsoDOCUMENT ME!private ModelImageinput1Image used to import a volume from inputImage.private ModelImageinputImageThis is the image in which internal registration will be performed.private ModelImageinputw_1Image used to import a volume from inputWeight.private ModelImageinputWeightThis gives weights for the input image - higher weights mean a greater impact in that area on the registration.private intinterpInterpolation method used in transformations.private intinterp2Interpolation method used in output.private float[]iResolsThe voxel resolutions of the input image.private ModelImageisoImagenew to this version: must keep isoImage around if image needed to be transformed.private floatlevel1FactorXYMultiplication factor for level 1 - will be set based on subsampling.private floatlevel1FactorZDOCUMENT ME!private floatlevel2FactorXYMultiplication factor for level 2 - will be set based on subsampling.private floatlevel2FactorZDOCUMENT ME!private floatlevel4FactorXYMultiplication factor for level 4 - will be set based on subsampling.private floatlevel4FactorZDOCUMENT ME!private intmaxDimDOCUMENT ME!private intmaxIterLimits number of iterations in Powell optimization. maxIter in the call to Powell's will be an integer multiple of baseNumIterprivate static intminimumZForSubDOCUMENT ME!private intmodeDOCUMENT ME!private intnumMinimaNumber of minima from level 8 to test at level 4.private ModelImageoutput_1DOCUMENT ME!private ModelImageoutsidePreReferenceVolumeDOCUMENT ME!private ModelImageoutsideReferenceVolumeDOCUMENT ME!private intrefImageNoIndicates the first volume used as a reference volume, if mode == ADJACENT.private booleanregToAdjImageIf true use adjacent image for registration.private booleanresampletrue if resolutions unequal, false if resolutions equal.private booleanresampleWtrue if weight image is resampled.private float[][]rotArrays used for producing graphs for DOF == 6 and register to average or reference image.private floatrotateBeginCoarse and fine sampling parameters.private floatrotateEndCoarse and fine sampling parameters.private ModelSimpleImagesimpleInput_1Simple version of an image volume of the input image.private ModelSimpleImagesimpleInputSub16_1Simple version of an image volume of the input image, subsampled by 16.private ModelSimpleImagesimpleInputSub2_1Simple version of an image volume of the input image, subsampled by 2.private ModelSimpleImagesimpleInputSub4_1Simple version of an image volume of the input image, subsampled by 4.private ModelSimpleImagesimpleInputSub8_1Simple version of an image volume of the input image, subsampled by 8.private ModelSimpleImagesimpleRef_1Simple version of input image.private ModelSimpleImagesimpleRefSub16_1Simple version of input image, subsampled by 16.private ModelSimpleImagesimpleRefSub2_1Simple version of input image, subsampled by 2.private ModelSimpleImagesimpleRefSub4_1Simple version of input image, subsampled by 4.private ModelSimpleImagesimpleRefSub8_1Simple version of input image, subsampled by 8.private ModelSimpleImagesimpleWeightI_1DOCUMENT ME!private ModelSimpleImagesimpleWeightISub16_1DOCUMENT ME!private ModelSimpleImagesimpleWeightISub2_1DOCUMENT ME!private ModelSimpleImagesimpleWeightISub4_1DOCUMENT ME!private ModelSimpleImagesimpleWeightISub8_1DOCUMENT ME!private ModelSimpleImagesimpleWeightR_1Simple version of weighted input image.private ModelSimpleImagesimpleWeightRSub16_1Simple version of weighted input image, subsampled by 16.private ModelSimpleImagesimpleWeightRSub2_1Simple version of weighted input image, subsampled by 2.private ModelSimpleImagesimpleWeightRSub4_1Simple version of weighted input image, subsampled by 4.private ModelSimpleImagesimpleWeightRSub8_1Simple version of weighted input image, subsampled by 8.private float[][]transDOCUMENT ME!private int[]TransMatsInumberprivate booleanuseOutsideReferenceVolumeDOCUMENT ME!private TransMatrix[]VolumesToReferenceTransformationsprivate booleanweightedFlag to determine if there are weighted images or not.private ModelImageweightVolumeImageDOCUMENT ME!- 
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBasedestFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
 
- 
 - 
Constructor SummaryConstructors Constructor Description AlgorithmRegOAR35D(ModelImage _image, int _costChoice, int _DOF, int _interp, int _interp2, int mode, int refImageNum, float _rotateBegin, float _rotateEnd, float _coarseRate, float _fineRate, boolean doGraph, boolean doSubsample, boolean fastMode, int _baseNumIter, int _numMinima)Creates new automatic internal registration algorithm and sets necessary variables.AlgorithmRegOAR35D(ModelImage _image, ModelImage _inputWeight, int _costChoice, int _DOF, int _interp, int _interp2, int mode, int refImageNum, float _rotateBegin, float _rotateEnd, float _coarseRate, float _fineRate, boolean doGraph, boolean doSubsample, boolean fastMode, int _baseNumIter, int _numMinima)Creates new automatic internal registration algorithm and sets necessary variables.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static WildMagic.LibFoundation.Mathematics.Vector3fcalculateCenterOfMass3D(ModelSimpleImage image, ModelSimpleImage wgtImage, boolean isColor)Calculates the center of mass (gravity) of a 3D image.private voidcopyFloatData(ModelSimpleImage srcImage, ModelSimpleImage resultImage)DOCUMENT ME!voiddisposeLocal()Dispose of local variables that may be taking up lots of room.voidfinalize()Prepares this class for destruction.voidgenerateTestImages()A test of the diffeomorphic demons is to transform a circle image to a letter C image.doublegetAnswer()TransMatrix[]getArrayTransMatrix()Sorts the array of transformation matricies and returns the sorted array.TransMatrix[]getArrayTransMatrix2()Sorts the array of transformation matricies and returns the sorted array.private java.lang.StringgetConstructionInfo()Creates a string with the parameters that the image was constructed with.float[][]getRot()accessor for rot.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 the level of subsampling (1, 2, 4, 8).float[][]getTrans()accessor for trans.TransMatrixgetTransform()ModelImagegetTransformedImage()accessor to get the internally registered image.private voidinterpolate(double x, double[] initial, double[][] tranforms, boolean scale)Performs a bilinear interpolation on points.private voidinterpolate(double x, double y, double z, double[] initial, double[][][][] tranforms, boolean scale)Performs a trilinear interpolation on points.private java.util.Vector<AlgorithmRegOAR35D.MatrixListItem>[]levelEight(ModelSimpleImage ref, ModelSimpleImage input)Takes two images that have been subsampled by a factor of eight.private java.util.Vector<AlgorithmRegOAR35D.MatrixListItem>levelFour(ModelSimpleImage ref, ModelSimpleImage input, java.util.Vector<AlgorithmRegOAR35D.MatrixListItem> minima, java.util.Vector<AlgorithmRegOAR35D.MatrixListItem> optMinima)Takes two images that have been subsampled by a factor of four, and two vectors of minima.private AlgorithmRegOAR35D.MatrixListItemlevelOne(ModelSimpleImage ref, ModelSimpleImage input, AlgorithmRegOAR35D.MatrixListItem item, int maxIter)Takes the two images, no subsampling, and the best minimum so far.private AlgorithmRegOAR35D.MatrixListItemlevelTwo(ModelSimpleImage ref, ModelSimpleImage input, java.util.Vector<AlgorithmRegOAR35D.MatrixListItem> minima)Takes two images that have been subsampled by a factor of 2 and a vector of minima.voidrunAlgorithm()Runs the image registration.voidsetJTEM(boolean bOn)Turns the full version of Powell's algorithm on/off.booleansetReferenceVolume(ModelImage refVolume)allows the user to pass in an OUTSIDE reference volume.private voidsubSampleBy2(ModelSimpleImage srcImage, ModelSimpleImage resultImage, boolean isColor)Takes a simple image and subsamples it by 2, interpolating so that the new values are averages.private static ModelSimpleImagesubSampleBy2XY(ModelSimpleImage srcImage, ModelSimpleImage resultImage, boolean isColor)Takes a simple image and subsamples XY by 2, interpolating so that the new XY values are averages.- 
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBaseactionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, 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.ThreadactiveCount, 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
 
- 
 
- 
- 
- 
Field Detail- 
ADJACENTprivate static final int ADJACENT DOCUMENT ME!- See Also:
- Constant Field Values
 
 - 
AVERAGEprivate static final int AVERAGE DOCUMENT ME!- See Also:
- Constant Field Values
 
 - 
minimumZForSubprivate static final int minimumZForSub DOCUMENT ME!- See Also:
- Constant Field Values
 
 - 
allowLevel16XYprivate boolean allowLevel16XY DOCUMENT ME!
 - 
allowLevel16Zprivate boolean allowLevel16Z DOCUMENT ME!
 - 
allowLevel2XYprivate boolean allowLevel2XY Flags are true if weighted image is not present or if weighted image subsampling occurred, false if weighted image subsampling did not occur.
 - 
allowLevel2Zprivate boolean allowLevel2Z DOCUMENT ME!
 - 
allowLevel4XYprivate boolean allowLevel4XY DOCUMENT ME!
 - 
allowLevel4Zprivate boolean allowLevel4Z DOCUMENT ME!
 - 
allowLevel8XYprivate boolean allowLevel8XY DOCUMENT ME!
 - 
allowLevel8Zprivate boolean allowLevel8Z DOCUMENT ME!
 - 
answerprivate AlgorithmRegOAR35D.MatrixListItem answer Final answer after registration.
 - 
bufferprivate float[] buffer DOCUMENT ME!
 - 
bufferAprivate float[] bufferA DOCUMENT ME!
 - 
bufferIWprivate float[] bufferIW DOCUMENT ME!
 - 
bufferWprivate float[] bufferW DOCUMENT ME!
 - 
calcCOGprivate boolean calcCOG If true calculate the center of gravity (mass) and use the difference to intialize the translation. If false, images are pretty much aligned and don't calculate COG.
 - 
coarseNumprivate int coarseNum Number of passes that will be made in the coarse sampling and fine sampling.
 - 
fineNumprivate int fineNum Number of passes that will be made in the coarse sampling and fine sampling.
 - 
colorFactorprivate int colorFactor 1 for black and white, 4 for color.
 - 
costChoiceprivate int costChoice Choice of which cost function to use.
 - 
doColorprivate boolean doColor DOCUMENT ME!
 - 
VolumesToReferenceTransformationsprivate TransMatrix[] VolumesToReferenceTransformations 
 - 
DOFprivate int DOF Maximum degrees of freedom when running the optimization.
 - 
doGraphprivate boolean doGraph Produce 2 output graphs - 1 for 3 rotations and 1 for 3 translations. Only can be used for DOF == 6 and register to average or reference volume
 - 
doSubsampleprivate boolean doSubsample if true subsample.
 - 
fastModeprivate boolean fastMode If true this algorithm skips all subsample and goes directly to the level 1 optimization. This assumes that images are fairly well aligned to begin with and therefore no sophisticated search is needed.
 - 
imageWeightIsoprivate ModelImage imageWeightIso DOCUMENT ME!
 - 
input1private ModelImage input1 Image used to import a volume from inputImage.
 - 
inputImageprivate ModelImage inputImage This is the image in which internal registration will be performed.
 - 
inputw_1private ModelImage inputw_1 Image used to import a volume from inputWeight.
 - 
inputWeightprivate ModelImage inputWeight This gives weights for the input image - higher weights mean a greater impact in that area on the registration.
 - 
interpprivate int interp Interpolation method used in transformations.
 - 
interp2private int interp2 Interpolation method used in output.
 - 
iResolsprivate float[] iResols The voxel resolutions of the input image.
 - 
isoImageprivate ModelImage isoImage new to this version: must keep isoImage around if image needed to be transformed.
 - 
level1FactorXYprivate float level1FactorXY Multiplication factor for level 1 - will be set based on subsampling.
 - 
level1FactorZprivate float level1FactorZ DOCUMENT ME!
 - 
level2FactorXYprivate float level2FactorXY Multiplication factor for level 2 - will be set based on subsampling.
 - 
level2FactorZprivate float level2FactorZ DOCUMENT ME!
 - 
level4FactorXYprivate float level4FactorXY Multiplication factor for level 4 - will be set based on subsampling.
 - 
level4FactorZprivate float level4FactorZ DOCUMENT ME!
 - 
maxDimprivate int maxDim DOCUMENT ME!
 - 
maxIterprivate int maxIter Limits number of iterations in Powell optimization. maxIter in the call to Powell's will be an integer multiple of baseNumIter
 - 
baseNumIterprivate int baseNumIter Limits number of iterations in Powell optimization. maxIter in the call to Powell's will be an integer multiple of baseNumIter
 - 
modeprivate int mode DOCUMENT ME!
 - 
numMinimaprivate int numMinima Number of minima from level 8 to test at level 4.
 - 
output_1private ModelImage output_1 DOCUMENT ME!
 - 
outsidePreReferenceVolumeprivate ModelImage outsidePreReferenceVolume DOCUMENT ME!
 - 
outsideReferenceVolumeprivate ModelImage outsideReferenceVolume DOCUMENT ME!
 - 
refImageNoprivate int refImageNo Indicates the first volume used as a reference volume, if mode == ADJACENT.
 - 
regToAdjImageprivate boolean regToAdjImage If true use adjacent image for registration. If false use the average volume or use the image volume reference number to indicate the image volume to register all images to.
 - 
resampleprivate boolean resample true if resolutions unequal, false if resolutions equal.
 - 
resampleWprivate boolean resampleW true if weight image is resampled.
 - 
rotprivate float[][] rot Arrays used for producing graphs for DOF == 6 and register to average or reference image.
 - 
rotateBeginprivate float rotateBegin Coarse and fine sampling parameters.
 - 
rotateEndprivate float rotateEnd Coarse and fine sampling parameters.
 - 
coarseRateprivate float coarseRate Coarse and fine sampling parameters.
 - 
fineRateprivate float fineRate Coarse and fine sampling parameters.
 - 
simpleInput_1private ModelSimpleImage simpleInput_1 Simple version of an image volume of the input image.
 - 
simpleInputSub16_1private ModelSimpleImage simpleInputSub16_1 Simple version of an image volume of the input image, subsampled by 16.
 - 
simpleInputSub2_1private ModelSimpleImage simpleInputSub2_1 Simple version of an image volume of the input image, subsampled by 2.
 - 
simpleInputSub4_1private ModelSimpleImage simpleInputSub4_1 Simple version of an image volume of the input image, subsampled by 4.
 - 
simpleInputSub8_1private ModelSimpleImage simpleInputSub8_1 Simple version of an image volume of the input image, subsampled by 8.
 - 
simpleRef_1private ModelSimpleImage simpleRef_1 Simple version of input image.
 - 
simpleRefSub16_1private ModelSimpleImage simpleRefSub16_1 Simple version of input image, subsampled by 16.
 - 
simpleRefSub2_1private ModelSimpleImage simpleRefSub2_1 Simple version of input image, subsampled by 2.
 - 
simpleRefSub4_1private ModelSimpleImage simpleRefSub4_1 Simple version of input image, subsampled by 4.
 - 
simpleRefSub8_1private ModelSimpleImage simpleRefSub8_1 Simple version of input image, subsampled by 8.
 - 
simpleWeightI_1private ModelSimpleImage simpleWeightI_1 DOCUMENT ME!
 - 
simpleWeightISub16_1private ModelSimpleImage simpleWeightISub16_1 DOCUMENT ME!
 - 
simpleWeightISub2_1private ModelSimpleImage simpleWeightISub2_1 DOCUMENT ME!
 - 
simpleWeightISub4_1private ModelSimpleImage simpleWeightISub4_1 DOCUMENT ME!
 - 
simpleWeightISub8_1private ModelSimpleImage simpleWeightISub8_1 DOCUMENT ME!
 - 
simpleWeightR_1private ModelSimpleImage simpleWeightR_1 Simple version of weighted input image.
 - 
simpleWeightRSub16_1private ModelSimpleImage simpleWeightRSub16_1 Simple version of weighted input image, subsampled by 16.
 - 
simpleWeightRSub2_1private ModelSimpleImage simpleWeightRSub2_1 Simple version of weighted input image, subsampled by 2.
 - 
simpleWeightRSub4_1private ModelSimpleImage simpleWeightRSub4_1 Simple version of weighted input image, subsampled by 4.
 - 
simpleWeightRSub8_1private ModelSimpleImage simpleWeightRSub8_1 Simple version of weighted input image, subsampled by 8.
 - 
transprivate float[][] trans DOCUMENT ME!
 - 
useOutsideReferenceVolumeprivate boolean useOutsideReferenceVolume DOCUMENT ME!
 - 
weightedprivate boolean weighted Flag to determine if there are weighted images or not.
 - 
weightVolumeImageprivate ModelImage weightVolumeImage DOCUMENT ME!
 - 
doJTEMprivate boolean doJTEM Turns the full version of Powell's algorithm on/off. When off the JTEM line minimization used.
 - 
doMultiThreadprivate boolean doMultiThread 
 - 
TransMatsInumberprivate int[] TransMatsInumber 
 
- 
 - 
Constructor Detail- 
AlgorithmRegOAR35Dpublic AlgorithmRegOAR35D(ModelImage _image, int _costChoice, int _DOF, int _interp, int _interp2, int mode, int refImageNum, float _rotateBegin, float _rotateEnd, float _coarseRate, float _fineRate, boolean doGraph, boolean doSubsample, boolean fastMode, 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- 1 = adjacent, 2 = average, 3 = reference
- refImageNum- If mode == REFERENCE, the volume all other volumes are registered to. If mode == ADJACENT, the first volume 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 3 rotations and one for 3 translations
- doSubsample- If true subsample
- fastMode- If true skip subsample and go directly to level 1 optimization
- _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
 
 - 
AlgorithmRegOAR35Dpublic AlgorithmRegOAR35D(ModelImage _image, ModelImage _inputWeight, int _costChoice, int _DOF, int _interp, int _interp2, int mode, int refImageNum, float _rotateBegin, float _rotateEnd, float _coarseRate, float _fineRate, boolean doGraph, boolean doSubsample, boolean fastMode, 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- 1 = adjacent, 2 = average, 3 = average
- refImageNum- If mode == REFERENCE, the volume all other volumes are registered to. If mode == ADJACENT, the first volume 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 3 rotations and one for 3 translations
- doSubsample- If true subsample
- fastMode- If true skip subsample and go directly to level 1 optimization
- _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- 
setJTEMpublic void setJTEM(boolean bOn) Turns the full version of Powell's algorithm on/off.- Parameters:
- bOn-
 
 - 
calculateCenterOfMass3Dpublic static WildMagic.LibFoundation.Mathematics.Vector3f calculateCenterOfMass3D(ModelSimpleImage image, ModelSimpleImage wgtImage, boolean isColor) Calculates the center of mass (gravity) of a 3D 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 and z axis goes into the screen. (i.e. the right hand rule). One could simply multiply by voxel resolutions.- Parameters:
- image- the center of mass will be calculated from this image data
- wgtImage- DOCUMENT ME!
- isColor- DOCUMENT ME!
- Returns:
- the center of mass as a 3D point
 
 - 
disposeLocalpublic void disposeLocal() Dispose of local variables that may be taking up lots of room.
 - 
finalizepublic void finalize() Prepares this class for destruction.- Overrides:
- finalizein class- AlgorithmBase
 
 - 
getRotpublic float[][] getRot() accessor for rot.- Returns:
- rot
 
 - 
getTranspublic float[][] getTrans() accessor for trans.- Returns:
- trans
 
 - 
getArrayTransMatrix2public TransMatrix[] getArrayTransMatrix2() Sorts the array of transformation matricies and returns the sorted array. If the sub-volumes are sorted to a sub-volume within the 4D image, then the matrix for the reference volume is the identity matrix.- Returns:
- Array of TransMatrix, one for each sub-volume in the 4D image.
 
 - 
getArrayTransMatrixpublic TransMatrix[] getArrayTransMatrix() Sorts the array of transformation matricies and returns the sorted array. If the sub-volumes are sorted to a sub-volume within the 4D image, then the matrix for the reference volume is the identity matrix.- Returns:
- Array of TransMatrix, one for each sub-volume in the 4D image.
 
 - 
getTransformpublic TransMatrix getTransform() 
 - 
getAnswerpublic double getAnswer() 
 - 
getTransformedImagepublic ModelImage getTransformedImage() accessor to get the internally registered image.- Returns:
- inputImage
 
 - 
runAlgorithmpublic 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 xyz isotropic transformation will be the same in the x, y, and z 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 8 or 16. The same is done with the weight image if necessary. The program loops thru levelEight, levelFour, levelTwo, and levelOne with one volume as the reference volume and one volume as the input volume. The function levelEight is called with the volumes subsampled by 8 or 16; it returns two vectors with minima. Then the function levelFour is called with volumes subsampled by 4 and the two vectors; it returns one vector of minima. The function levelTwo is called with volumes 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 volume to the reference volume. The registered input volume data is imported into inputImage.- Specified by:
- runAlgorithmin class- AlgorithmBase
 
 - 
generateTestImagespublic void generateTestImages() A test of the diffeomorphic demons is to transform a circle image to a letter C image.
 - 
setReferenceVolumepublic boolean setReferenceVolume(ModelImage refVolume) allows the user to pass in an OUTSIDE reference volume.- Parameters:
- refVolume- 3-Dim image for reference
- Returns:
- DOCUMENT ME!
 
 - 
subSampleBy2XYprivate static ModelSimpleImage subSampleBy2XY(ModelSimpleImage srcImage, ModelSimpleImage resultImage, boolean isColor) Takes a simple image and subsamples XY by 2, interpolating so that the new XY values are averages.- Parameters:
- srcImage- Image to subsample.
- resultImage- DOCUMENT ME!
- isColor- DOCUMENT ME!
- Returns:
- Subsampled image.
 
 - 
copyFloatDataprivate void copyFloatData(ModelSimpleImage srcImage, ModelSimpleImage resultImage) DOCUMENT ME!- Parameters:
- srcImage- DOCUMENT ME!
- resultImage- DOCUMENT ME!
 
 - 
getConstructionInfoprivate java.lang.String getConstructionInfo() Creates a string with the parameters that the image was constructed with.- Returns:
- Construction info.
 
 - 
getToleranceprivate 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 the level of subsampling (1, 2, 4, 8).- 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) 
 
 - 
interpolateprivate 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 isfalse.- 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-- truemeans set the scale in the vector.
 
 - 
interpolateprivate void interpolate(double x, double y, double z, double[] initial, double[][][][] tranforms, boolean scale)Performs a trilinear interpolation on points. Takes 3 initial points, a vector of values to set, and an array in which to look at neighbors of those points. Sets the appropriate values in the vector. Does not set scale if the scale parameter isfalse.- Parameters:
- x- X rotation initial index into array.
- y- Y rotation initial index into array.
- z- Z rotation initial index into array.
- initial- Vector to set; if scale is- true, set three translations and a scale. Otherwise just set translations.
- tranforms- DOCUMENT ME!
- scale-- truemeans set the scale in the vector.
 
 - 
levelEightprivate java.util.Vector<AlgorithmRegOAR35D.MatrixListItem>[] levelEight(ModelSimpleImage ref, ModelSimpleImage input) Takes two images that have been subsampled by a factor of eight. Sets up the cost function with the images and the weighted images, if necessary. Uses the coarse sampling rate and optimizes 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, -30, -30), (-30, -30, -15), (-30, -30, 0), etc. In this case there would be a total of 125 calls to the optimization method. 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 8 neighbors of a point: +, =, or - one fine sample in each of the three directions. 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 rotations as well as translations and global scale. (Previously had not optimized over rotations.) Returns two vectors, one containing the minima before optimization, one containing the minima after optimization.- Parameters:
- ref- Subsampled by 8 reference image.
- input- Subsampled by 8 input image.
- Returns:
- List of preoptimized and optimized points.
 
 - 
levelFourprivate java.util.Vector<AlgorithmRegOAR35D.MatrixListItem> levelFour(ModelSimpleImage ref, ModelSimpleImage input, java.util.Vector<AlgorithmRegOAR35D.MatrixListItem> minima, java.util.Vector<AlgorithmRegOAR35D.MatrixListItem> optMinima) Takes two images that have been subsampled by a factor of four, and two vectors of minima. Sets up the cost function with the images and the weighted images, 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 rotations in each dimension by zero and plus-minus fineDelta. If it's not a rigid transformation, perturbs the scales by factors of 0.8, 0.9, 1.0, 1.1, and 1.2. Optimize the perturbations. Returns a vector of the perturbed, optimized minima.- Parameters:
- ref- Reference image, subsampled by 4.
- input- Input image, subsampled by 4.
- minima- Preoptimized minima.
- optMinima- Optimized minima.
- Returns:
- A vector of perturbed, optimized minima.
 
 - 
levelOneprivate AlgorithmRegOAR35D.MatrixListItem levelOne(ModelSimpleImage ref, ModelSimpleImage input, AlgorithmRegOAR35D.MatrixListItem item, int maxIter) Takes the two images, no subsampling, and the best minimum so far. Sets up the cost function with the images and the weighted images, 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 12). Returns the best minimum.- Parameters:
- ref- Reference image.
- input- Input image.
- item- Best minimum so far.
- maxIter- DOCUMENT ME!
- Returns:
- Best minimum after optimization.
 
 - 
levelTwoprivate AlgorithmRegOAR35D.MatrixListItem levelTwo(ModelSimpleImage ref, ModelSimpleImage input, java.util.Vector<AlgorithmRegOAR35D.MatrixListItem> minima) Takes two images 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 7 degrees of freedom, then 9, then 12. If the user has limited the degrees of freedom to 6, there will only be one optimization run, with 6 degrees of freedom. Returns the best minimum after optimization.- Parameters:
- ref- Reference image, subsampled by 2.
- input- Input image, subsampled by 2.
- minima- Minima.
- Returns:
- The optimized minimum.
 
 - 
subSampleBy2private void subSampleBy2(ModelSimpleImage srcImage, ModelSimpleImage resultImage, boolean isColor) Takes a simple image and subsamples it by 2, interpolating so that the new values are averages.- Parameters:
- srcImage- Image to subsample.
- resultImage- DOCUMENT ME!
- isColor- DOCUMENT ME!
 
 
- 
 
-