Class AlgorithmRegELSUNCOAR3D
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.registration.AlgorithmRegELSUNCOAR3D
-
- All Implemented Interfaces:
AlgorithmInterface
,java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmRegELSUNCOAR3D extends AlgorithmBase implements AlgorithmInterface
This is an automatic registration method based on FLIRT. FLIRT stands for FMRIB's Linear Image Registration Tool 1.3. 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.
Our algorithm works as follows:
1.) We find the minimum resolution of the images and blur them if neccessary.
2.) We transform the images into isotropic voxels.
3.) We subsample the images by 2, 4, and 8, depending on the resolution.
Subsampling can be performed for x, y, and z or for only x and y. 4.) With the images that were subsampled by 8, 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, -30, -30), (-30, -30, -15), (-30, -30, 0), etc. In this case there would be a total of 125 calls to the optimization method.
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 in each of the three directions. 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 rotations as well as translations and global scale. (Previously we had not optimized over rotations.) We return two vectors, one containing the minima before optimization, one containing the minima after optimization.
9.) We now call levelFour with the images subsampled by 4 and the vectors of minima. We measure the costs of the minima on the new images 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 rotations in each dimension by zero and plus-minus fineDelta. If it's not a rigid transformation, we then perturb the 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 images subsampled by 2. We measure the costs of the minima at the new images. 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 images. 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 matrix from this answer is saved in a file and also accessed by the dialog that called this algorithm.
Only subsample if 16 or more z slices are present so that the number of z slices will not be reduced below 8.
- Author:
- Neva Cherniavsky, Matthew McAuliffe
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowLevel16XY
DOCUMENT ME!private boolean
allowLevel16Z
DOCUMENT ME!private boolean
allowLevel2XY
DOCUMENT ME!private boolean
allowLevel2Z
DOCUMENT ME!private boolean
allowLevel4XY
DOCUMENT ME!private boolean
allowLevel4Z
DOCUMENT ME!private boolean
allowLevel8XY
DOCUMENT ME!private boolean
allowLevel8Z
DOCUMENT ME!private MatrixListItem
answer
Final answer after registration.(package private) int
baseNumIter
private MatrixListItem
bestGuessLevel2
DOCUMENT ME!private ModelImage
blurredInput
Blurred input image.private ModelImage
blurredRef
Blurred reference image.private boolean
calcCOG
If true calculate the center of gravity (mass) and use the difference to intialize the translation.private int
coarseNumX
Number of passes that will be made in the coarse sampling and fine sampling.private int
coarseNumY
DOCUMENT ME!private int
coarseNumZ
DOCUMENT ME!private float
coarseRateX
Coarse and fine sampling parameters.private float
coarseRateY
DOCUMENT ME!private float
coarseRateZ
DOCUMENT ME!private int
costChoice
Choice of which cost function to use.private boolean
doColor
DOCUMENT ME!private int
DOF
Maximum degrees of freedom when running the optimization.private boolean
doMultiThread
private java.util.concurrent.CountDownLatch
doneSignal
private boolean
doSubsample
If true subsample for levelEight, levelFour and levelTwo analyses.private boolean
fastMode
If true this algorithm skips all subsample and goes directly to the level 1 optimization.private int
fineNumX
Number of passes that will be made in the coarse sampling and fine sampling.private int
fineNumY
DOCUMENT ME!private int
fineNumZ
DOCUMENT ME!private float
fineRateX
Coarse and fine sampling parameters.private float
fineRateY
DOCUMENT ME!private float
fineRateZ
DOCUMENT ME!private boolean
fullAnalysisMode
If true this algorithm skips all subsample and goes directly to the level 1 optimization.private ModelImage
imageInputIso
Isotropic input image.private ModelImage
imageRefIso
Isotropic reference image.private ModelImage
imageWeightInputIso
Isotropic weighted input image.private ModelImage
imageWeightRefIso
Isotropic weighted reference image.(package private) double
initialCost
DOCUMENT ME!private ModelImage
inputImage
This image is to registered to the reference image.private ModelImage
inputWeight
This gives weights for the input image - higher weights mean a greater impact in that area on the registration.private int
interp
Interpolation method.private float
level1FactorXY
Multiplication factor for level 1 - will be set based on subsampling.private float
level1FactorZ
DOCUMENT ME!private float
level2FactorXY
Multiplication factor for level 2 - will be set based on subsampling.private float
level2FactorZ
DOCUMENT ME!private float
level4FactorXY
Multiplication factor for level 4 - will be set based on subsampling.private float
level4FactorZ
DOCUMENT ME!private ImageRegistrationGPU
m_kGPUCost
private int
maxDim
DOCUMENT ME!private int
maxIter
Advanced optimization settings maxIter in the call to ELSUNC will be an integer multiple of baseNumIter.private boolean
maxResol
Flag to determine if the maximum of the minimum resolutions of the two datasets should be used.private static int
minimumZForSub
DOCUMENT ME!private int
numMinima
Number of minima from level 8 to test at level 4.private ModelImage
refImage
The inputImage will be registered to this reference image.private ModelImage
refWeight
This gives weights for the reference image - higher weights mean a greater impact in that area on the registration.private boolean
resampleInput
DOCUMENT ME!private boolean
resampleRef
DOCUMENT ME!private float[]
resInput
The voxel resolutions of the image to be registered to the reference image.private float[]
resRef
The voxel resolutions of the reference image.private float
rotateBeginX
Coarse and fine sampling parameters.private float
rotateBeginY
DOCUMENT ME!private float
rotateBeginZ
DOCUMENT ME!private float
rotateEndX
Coarse and fine sampling parameters.private float
rotateEndY
DOCUMENT ME!private float
rotateEndZ
DOCUMENT ME!private int
searchAlgorithm
private ModelSimpleImage
simpleInput
Simple version of input image.private ModelSimpleImage
simpleInputSub2
Simple version of input image, subsampled by 2.private ModelSimpleImage
simpleInputSub4
Simple version of input image, subsampled by 4.private ModelSimpleImage
simpleInputSub8
Simple version of input image, subsampled by 8.private ModelSimpleImage
simpleRef
Simple version of reference image.private ModelSimpleImage
simpleRefSub2
Simple version of reference image, subsampled by 2.private ModelSimpleImage
simpleRefSub4
Simple version of reference image, subsampled by 4.private ModelSimpleImage
simpleRefSub8
Simple version of reference image, subsampled by 8.private ModelSimpleImage
simpleWeightInput
Simple version of weighted input image.private ModelSimpleImage
simpleWeightInputSub2
Simple version of weighted input image, subsampled by 2.private ModelSimpleImage
simpleWeightInputSub4
Simple version of weighted input image, subsampled by 4.private ModelSimpleImage
simpleWeightInputSub8
Simple version of weighted input image, subsampled by 8.private ModelSimpleImage
simpleWeightRef
Simple version of weighted reference image.private ModelSimpleImage
simpleWeightRefSub2
Simple version of weighted reference image, subsampled by 2.private ModelSimpleImage
simpleWeightRefSub4
Simple version of weighted reference image, subsampled by 4.private ModelSimpleImage
simpleWeightRefSub8
Simple version of weighted reference image, subsampled by 8.(package private) long
timeElapsed
DOCUMENT ME!(package private) long
timeLater
DOCUMENT ME!(package private) long
timeNow
DOCUMENT ME!(package private) TransMatrix
tMatrix
DOCUMENT ME!private AlgorithmTransform
transform
Transformation algorithm for creating an isotropic reference image.private AlgorithmTransform
transform2
Transformation algorithm for creating an isotropic input image.private boolean
weighted
Flag to determine if there are weighted images or not.private int
weightedInputPixels
DOCUMENT ME!private int
weightedInputPixelsSub2
DOCUMENT ME!private int
weightedInputPixelsSub4
DOCUMENT ME!private int
weightedInputPixelsSub8
DOCUMENT ME!private int
weightedRefPixels
DOCUMENT ME!private int
weightedRefPixelsSub2
DOCUMENT ME!private int
weightedRefPixelsSub4
DOCUMENT ME!private int
weightedRefPixelsSub8
DOCUMENT ME!-
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 AlgorithmRegELSUNCOAR3D(ModelImage _imageA, ModelImage _imageB, int _costChoice, int _DOF, int _interp, float _rotateBeginX, float _rotateEndX, float _coarseRateX, float _fineRateX, float _rotateBeginY, float _rotateEndY, float _coarseRateY, float _fineRateY, float _rotateBeginZ, float _rotateEndZ, float _coarseRateZ, float _fineRateZ, boolean _maxResol, boolean _doSubsample, boolean _doMultiThread, boolean _fastMode, int _baseNumIter, int _numMinima, int searchAlgorithm)
Creates new automatic linear registration algorithm and sets necessary variables.AlgorithmRegELSUNCOAR3D(ModelImage _imageA, ModelImage _imageB, int _costChoice, int _DOF, int _interp, float _rotateBeginX, float _rotateEndX, float _coarseRateX, float _fineRateX, float _rotateBeginY, float _rotateEndY, float _coarseRateY, float _fineRateY, float _rotateBeginZ, float _rotateEndZ, float _coarseRateZ, float _fineRateZ, boolean _maxResol, boolean _doSubsample, boolean _fastMode, int _baseNumIter, int _numMinima, int searchAlgorithm)
Creates new automatic linear registration algorithm and sets necessary variables.AlgorithmRegELSUNCOAR3D(ModelImage _imageA, ModelImage _imageB, ModelImage _refWeight, ModelImage _inputWeight, int _costChoice, int _DOF, int _interp, float _rotateBeginX, float _rotateEndX, float _coarseRateX, float _fineRateX, float _rotateBeginY, float _rotateEndY, float _coarseRateY, float _fineRateY, float _rotateBeginZ, float _rotateEndZ, float _coarseRateZ, float _fineRateZ, boolean _maxResol, boolean _doSubsample, boolean _doMultiThread, boolean _fastMode, int _baseNumIter, int _numMinima, int searchAlgorithm)
Creates new automatic linear registration algorithm and sets necessary variables.AlgorithmRegELSUNCOAR3D(ModelImage _imageA, ModelImage _imageB, ModelImage _refWeight, ModelImage _inputWeight, int _costChoice, int _DOF, int _interp, float _rotateBeginX, float _rotateEndX, float _coarseRateX, float _fineRateX, float _rotateBeginY, float _rotateEndY, float _coarseRateY, float _fineRateY, float _rotateBeginZ, float _rotateEndZ, float _coarseRateZ, float _fineRateZ, boolean _maxResol, boolean _doSubsample, boolean _fastMode, int _baseNumIter, int _numMinima, int searchAlgorithm)
Creates new automatic linear registration algorithm and sets necessary variables.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
algorithmPerformed(AlgorithmBase algorithm)
Called after an algorithm this listener is registered to exits (maybe successfully, maybe not).static WildMagic.LibFoundation.Mathematics.Vector3f
calculateCenterOfMass3D(ModelSimpleImage image, ModelSimpleImage wgtImage, boolean isColor)
Calculates the center of mass (gravity) of a 3D image.void
disposeLocal()
Dispose of local variables that may be taking up lots of room.void
finalize()
Prepares this class for destruction.double
getAnswer()
Accessor that returns the final cost function.private java.lang.String
getConstructionInfo()
Creates a string with the parameters that the image was constructed with.float
getLevel1FactorXY()
float
getLevel1FactorZ()
float
getLevel2FactorXY()
float
getLevel2FactorZ()
float
getLevel4FactorXY()
float
getLevel4FactorZ()
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).double[]
getTransArray()
Access that returns an array containing the transformation parameters.TransMatrix
getTransform()
Accessor that returns the matrix calculated in this algorithm.TransMatrix
getTransformHalf()
Accessor that returns the matrix calculated in this algorithm divided by 2.TransMatrix
getTransformMigsagittal()
Accessor that returns the z rot and x and y trans from the matrix calculated in this algorithm.private void
interpolate(double x, double y, double z, double[] initial, double[][][][] tranforms, boolean scale)
Performs a trilinear interpolation on points.java.util.Vector<MatrixListItem>[]
levelEight(ModelSimpleImage ref, ModelSimpleImage input, float progressFrom, float progressTo)
Takes two images that have been subsampled by a factor of eight.java.util.Vector<MatrixListItem>
levelFour(ModelSimpleImage ref, ModelSimpleImage input, java.util.Vector<MatrixListItem> minima, java.util.Vector<MatrixListItem> optMinima, float progressFrom, float progressTo)
Takes two images that have been subsampled by a factor of four, and two vectors of minima.MatrixListItem
levelOne(ModelSimpleImage ref, ModelSimpleImage input, MatrixListItem item, int maxIter, float progressFrom, float progressTo)
Takes the two images, no subsampling, and the best minimum so far.MatrixListItem
levelTwo(ModelSimpleImage ref, ModelSimpleImage input, java.util.Vector<MatrixListItem> minima, float progressFrom, float progressTo)
Takes two images that have been subsampled by a factor of 2 and a vector of minima.void
runAlgorithm()
Runs the image registration.void
setLevel1FactorXY(float level1FactorXY)
void
setLevel1FactorZ(float level1FactorZ)
void
setLevel2FactorXY(float level2FactorXY)
void
setLevel2FactorZ(float level2FactorZ)
void
setLevel4FactorXY(float level4FactorXY)
void
setLevel4FactorZ(float level4FactorZ)
static ModelSimpleImage
subsampleBy2(ModelSimpleImage srcImage, boolean isColor)
Takes a simple image and subsamples it by 2, interpolating so that the new values are averages.static ModelSimpleImage
subsampleBy2XY(ModelSimpleImage srcImage, 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.AlgorithmBase
actionPerformed, 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.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
-
-
-
-
Field Detail
-
minimumZForSub
private static final int minimumZForSub
DOCUMENT ME!- See Also:
- Constant Field Values
-
initialCost
double initialCost
DOCUMENT ME!
-
timeElapsed
long timeElapsed
DOCUMENT ME!
-
timeLater
long timeLater
DOCUMENT ME!
-
timeNow
long timeNow
DOCUMENT ME!
-
tMatrix
TransMatrix tMatrix
DOCUMENT ME!
-
allowLevel16XY
private boolean allowLevel16XY
DOCUMENT ME!
-
allowLevel16Z
private boolean allowLevel16Z
DOCUMENT ME!
-
allowLevel2XY
private boolean allowLevel2XY
DOCUMENT ME!
-
allowLevel2Z
private boolean allowLevel2Z
DOCUMENT ME!
-
allowLevel4XY
private boolean allowLevel4XY
DOCUMENT ME!
-
allowLevel4Z
private boolean allowLevel4Z
DOCUMENT ME!
-
allowLevel8XY
private boolean allowLevel8XY
DOCUMENT ME!
-
allowLevel8Z
private boolean allowLevel8Z
DOCUMENT ME!
-
answer
private MatrixListItem answer
Final answer after registration.
-
bestGuessLevel2
private MatrixListItem bestGuessLevel2
DOCUMENT ME!
-
blurredInput
private ModelImage blurredInput
Blurred input image.
-
blurredRef
private ModelImage blurredRef
Blurred reference image.
-
calcCOG
private final 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 then don't calculated COG.- See Also:
- Constant Field Values
-
coarseNumX
private final int coarseNumX
Number of passes that will be made in the coarse sampling and fine sampling.
-
fineNumX
private final int fineNumX
Number of passes that will be made in the coarse sampling and fine sampling.
-
coarseNumY
private final int coarseNumY
DOCUMENT ME!
-
fineNumY
private final int fineNumY
DOCUMENT ME!
-
coarseNumZ
private final int coarseNumZ
DOCUMENT ME!
-
fineNumZ
private final int fineNumZ
DOCUMENT ME!
-
costChoice
private int costChoice
Choice of which cost function to use.
-
doColor
private boolean doColor
DOCUMENT ME!
-
DOF
private final int DOF
Maximum degrees of freedom when running the optimization.
-
doSubsample
private boolean doSubsample
If true subsample for levelEight, levelFour and levelTwo analyses.
-
doMultiThread
private boolean doMultiThread
-
fastMode
private 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.
-
fullAnalysisMode
private boolean fullAnalysisMode
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.
-
imageInputIso
private ModelImage imageInputIso
Isotropic input image.
-
imageRefIso
private ModelImage imageRefIso
Isotropic reference image.
-
imageWeightInputIso
private ModelImage imageWeightInputIso
Isotropic weighted input image.
-
imageWeightRefIso
private ModelImage imageWeightRefIso
Isotropic weighted reference image.
-
inputImage
private ModelImage inputImage
This image is to registered to the reference image.
-
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.
-
level1FactorXY
private float level1FactorXY
Multiplication factor for level 1 - will be set based on subsampling.
-
level1FactorZ
private float level1FactorZ
DOCUMENT ME!
-
level2FactorXY
private float level2FactorXY
Multiplication factor for level 2 - will be set based on subsampling.
-
level2FactorZ
private float level2FactorZ
DOCUMENT ME!
-
level4FactorXY
private float level4FactorXY
Multiplication factor for level 4 - will be set based on subsampling.
-
level4FactorZ
private float level4FactorZ
DOCUMENT ME!
-
maxDim
private int maxDim
DOCUMENT ME!
-
maxIter
private int maxIter
Advanced optimization settings maxIter in the call to ELSUNC will be an integer multiple of baseNumIter.
-
baseNumIter
final int baseNumIter
-
searchAlgorithm
private int searchAlgorithm
-
maxResol
private final boolean maxResol
Flag to determine if the maximum of the minimum resolutions of the two datasets should be used. If true use the maximum resolution of the two dataset. Throws away information some image information but is faster. If false the algorithms uses the minimum of the resolutions when resampling the images. Can be slower but does not "lose" informaton.
-
numMinima
private final int numMinima
Number of minima from level 8 to test at level 4.
-
refImage
private ModelImage refImage
The inputImage will be registered to this reference image.
-
refWeight
private ModelImage refWeight
This gives weights for the reference image - higher weights mean a greater impact in that area on the registration.
-
resampleInput
private boolean resampleInput
DOCUMENT ME!
-
resampleRef
private boolean resampleRef
DOCUMENT ME!
-
resInput
private float[] resInput
The voxel resolutions of the image to be registered to the reference image.
-
resRef
private float[] resRef
The voxel resolutions of the reference image.
-
rotateBeginX
private final float rotateBeginX
Coarse and fine sampling parameters.
-
rotateEndX
private final float rotateEndX
Coarse and fine sampling parameters.
-
coarseRateX
private final float coarseRateX
Coarse and fine sampling parameters.
-
fineRateX
private final float fineRateX
Coarse and fine sampling parameters.
-
rotateBeginY
private final float rotateBeginY
DOCUMENT ME!
-
rotateEndY
private final float rotateEndY
DOCUMENT ME!
-
coarseRateY
private final float coarseRateY
DOCUMENT ME!
-
fineRateY
private final float fineRateY
DOCUMENT ME!
-
rotateBeginZ
private final float rotateBeginZ
DOCUMENT ME!
-
rotateEndZ
private final float rotateEndZ
DOCUMENT ME!
-
coarseRateZ
private final float coarseRateZ
DOCUMENT ME!
-
fineRateZ
private final float fineRateZ
DOCUMENT ME!
-
simpleInput
private ModelSimpleImage simpleInput
Simple version of input image.
-
simpleInputSub2
private ModelSimpleImage simpleInputSub2
Simple version of input image, subsampled by 2.
-
simpleInputSub4
private ModelSimpleImage simpleInputSub4
Simple version of input image, subsampled by 4.
-
simpleInputSub8
private ModelSimpleImage simpleInputSub8
Simple version of input image, subsampled by 8.
-
simpleRef
private ModelSimpleImage simpleRef
Simple version of reference image.
-
simpleRefSub2
private ModelSimpleImage simpleRefSub2
Simple version of reference image, subsampled by 2.
-
simpleRefSub4
private ModelSimpleImage simpleRefSub4
Simple version of reference image, subsampled by 4.
-
simpleRefSub8
private ModelSimpleImage simpleRefSub8
Simple version of reference image, subsampled by 8.
-
simpleWeightInput
private ModelSimpleImage simpleWeightInput
Simple version of weighted input image.
-
simpleWeightInputSub2
private ModelSimpleImage simpleWeightInputSub2
Simple version of weighted input image, subsampled by 2.
-
simpleWeightInputSub4
private ModelSimpleImage simpleWeightInputSub4
Simple version of weighted input image, subsampled by 4.
-
simpleWeightInputSub8
private ModelSimpleImage simpleWeightInputSub8
Simple version of weighted input image, subsampled by 8.
-
simpleWeightRef
private ModelSimpleImage simpleWeightRef
Simple version of weighted reference image.
-
simpleWeightRefSub2
private ModelSimpleImage simpleWeightRefSub2
Simple version of weighted reference image, subsampled by 2.
-
simpleWeightRefSub4
private ModelSimpleImage simpleWeightRefSub4
Simple version of weighted reference image, subsampled by 4.
-
simpleWeightRefSub8
private ModelSimpleImage simpleWeightRefSub8
Simple version of weighted reference image, subsampled by 8.
-
transform
private AlgorithmTransform transform
Transformation algorithm for creating an isotropic reference image.
-
transform2
private AlgorithmTransform transform2
Transformation algorithm for creating an isotropic input image.
-
weighted
private boolean weighted
Flag to determine if there are weighted images or not.
-
weightedInputPixels
private int weightedInputPixels
DOCUMENT ME!
-
weightedInputPixelsSub2
private int weightedInputPixelsSub2
DOCUMENT ME!
-
weightedInputPixelsSub4
private int weightedInputPixelsSub4
DOCUMENT ME!
-
weightedInputPixelsSub8
private int weightedInputPixelsSub8
DOCUMENT ME!
-
weightedRefPixels
private int weightedRefPixels
DOCUMENT ME!
-
weightedRefPixelsSub2
private int weightedRefPixelsSub2
DOCUMENT ME!
-
weightedRefPixelsSub4
private int weightedRefPixelsSub4
DOCUMENT ME!
-
weightedRefPixelsSub8
private int weightedRefPixelsSub8
DOCUMENT ME!
-
m_kGPUCost
private ImageRegistrationGPU m_kGPUCost
-
doneSignal
private java.util.concurrent.CountDownLatch doneSignal
-
-
Constructor Detail
-
AlgorithmRegELSUNCOAR3D
public AlgorithmRegELSUNCOAR3D(ModelImage _imageA, ModelImage _imageB, int _costChoice, int _DOF, int _interp, float _rotateBeginX, float _rotateEndX, float _coarseRateX, float _fineRateX, float _rotateBeginY, float _rotateEndY, float _coarseRateY, float _fineRateY, float _rotateBeginZ, float _rotateEndZ, float _coarseRateZ, float _fineRateZ, boolean _maxResol, boolean _doSubsample, boolean _fastMode, int _baseNumIter, int _numMinima, int searchAlgorithm)
Creates new automatic linear registration algorithm and sets necessary variables.- Parameters:
_imageA
- Reference image (register input image to reference image)._imageB
- Input image (register input image to reference image)._costChoice
- Choice of cost functions, like correlation ratio or mutual information._DOF
- Degrees of freedom for registration_interp
- Interpolation method used in transformations._rotateBeginX
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndX
- End of coarse sampling range (i.e., 60 degrees)._coarseRateX
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateX
- Point at which fine samples should be taken (i.e., every 15 degrees)._rotateBeginY
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndY
- End of coarse sampling range (i.e., 60 degrees)._coarseRateY
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateY
- Point at which fine samples should be taken (i.e., every 15 degrees)._rotateBeginZ
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndZ
- End of coarse sampling range (i.e., 60 degrees)._coarseRateZ
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateZ
- Point at which fine samples should be taken (i.e., every 15 degrees)._maxResol
- If true is the maximum of the minimum resolution of the two datasets when resampling._doSubsample
- If true then subsample_fastMode
- If true then searching the parameter space is not conducted and the algorithm proceeds to level one immediately_baseNumIter
- Limits the number of iterations of ELSUNC algorithm. maxIter in the call to ELSUNC will be an integer multiple of baseNumIter_numMinima
- Number of minima from level 8 to test at level 4searchAlgorithm
- ESLUNC, LEVENBERG_MARQUARDT, or NL2SOL.
-
AlgorithmRegELSUNCOAR3D
public AlgorithmRegELSUNCOAR3D(ModelImage _imageA, ModelImage _imageB, int _costChoice, int _DOF, int _interp, float _rotateBeginX, float _rotateEndX, float _coarseRateX, float _fineRateX, float _rotateBeginY, float _rotateEndY, float _coarseRateY, float _fineRateY, float _rotateBeginZ, float _rotateEndZ, float _coarseRateZ, float _fineRateZ, boolean _maxResol, boolean _doSubsample, boolean _doMultiThread, boolean _fastMode, int _baseNumIter, int _numMinima, int searchAlgorithm)
Creates new automatic linear registration algorithm and sets necessary variables.- Parameters:
_imageA
- Reference image (register input image to reference image)._imageB
- Input image (register input image to reference image)._costChoice
- Choice of cost functions, like correlation ratio or mutual information._DOF
- Degrees of freedom for registration_interp
- Interpolation method used in transformations._rotateBeginX
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndX
- End of coarse sampling range (i.e., 60 degrees)._coarseRateX
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateX
- Point at which fine samples should be taken (i.e., every 15 degrees)._rotateBeginY
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndY
- End of coarse sampling range (i.e., 60 degrees)._coarseRateY
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateY
- Point at which fine samples should be taken (i.e., every 15 degrees)._rotateBeginZ
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndZ
- End of coarse sampling range (i.e., 60 degrees)._coarseRateZ
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateZ
- Point at which fine samples should be taken (i.e., every 15 degrees)._maxResol
- If true is the maximum of the minimum resolution of the two datasets when resampling._doSubsample
- If true then subsample_doMultiThread
-_fastMode
- If true then searching the parameter space is not conducted and the algorithm proceeds to level one immediately_baseNumIter
- Limits the number of iterations of ELSUNC algorithm. maxIter in the call to ELSUNC will be an integer multiple of baseNumIter_numMinima
- Number of minima from level 8 to test at level 4searchAlgorithm
- ESLUNC, LEVENBERG_MARQUARDT, or NL2SOL.
-
AlgorithmRegELSUNCOAR3D
public AlgorithmRegELSUNCOAR3D(ModelImage _imageA, ModelImage _imageB, ModelImage _refWeight, ModelImage _inputWeight, int _costChoice, int _DOF, int _interp, float _rotateBeginX, float _rotateEndX, float _coarseRateX, float _fineRateX, float _rotateBeginY, float _rotateEndY, float _coarseRateY, float _fineRateY, float _rotateBeginZ, float _rotateEndZ, float _coarseRateZ, float _fineRateZ, boolean _maxResol, boolean _doSubsample, boolean _fastMode, int _baseNumIter, int _numMinima, int searchAlgorithm)
Creates new automatic linear registration algorithm and sets necessary variables.- Parameters:
_imageA
- Reference image (register input image to reference image)._imageB
- Input image (register input image to reference image)._refWeight
- Reference weighted image, used to give certain areas of the image greater impact on the registration._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
- Degrees of freedom for registration_interp
- Interpolation method used in transformations._rotateBeginX
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndX
- End of coarse sampling range (i.e., 60 degrees)._coarseRateX
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateX
- Point at which fine samples should be taken (i.e., every 15 degrees)._rotateBeginY
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndY
- End of coarse sampling range (i.e., 60 degrees)._coarseRateY
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateY
- Point at which fine samples should be taken (i.e., every 15 degrees)._rotateBeginZ
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndZ
- End of coarse sampling range (i.e., 60 degrees)._coarseRateZ
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateZ
- Point at which fine samples should be taken (i.e., every 15 degrees)._maxResol
- If true is the maximum of the minimum resolution of the two datasets when resampling._doSubsample
- If true then subsample_fastMode
- If true then searching the parameter space is not conducted and the algorithm proceeds to level one immediately_baseNumIter
- Limits the number of iterations of ELSUNC algorithm. maxIter in the call to ELSUNC will be an integer multiple of baseNumIter_numMinima
- Number of minima from level 8 to test at level 4searchAlgorithm
- ESLUNC, LEVENBERG_MARQUARDT, or NL2SOL.
-
AlgorithmRegELSUNCOAR3D
public AlgorithmRegELSUNCOAR3D(ModelImage _imageA, ModelImage _imageB, ModelImage _refWeight, ModelImage _inputWeight, int _costChoice, int _DOF, int _interp, float _rotateBeginX, float _rotateEndX, float _coarseRateX, float _fineRateX, float _rotateBeginY, float _rotateEndY, float _coarseRateY, float _fineRateY, float _rotateBeginZ, float _rotateEndZ, float _coarseRateZ, float _fineRateZ, boolean _maxResol, boolean _doSubsample, boolean _doMultiThread, boolean _fastMode, int _baseNumIter, int _numMinima, int searchAlgorithm)
Creates new automatic linear registration algorithm and sets necessary variables.- Parameters:
_imageA
- Reference image (register input image to reference image)._imageB
- Input image (register input image to reference image)._refWeight
- Reference weighted image, used to give certain areas of the image greater impact on the registration._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
- Degrees of freedom for registration_interp
- Interpolation method used in transformations._rotateBeginX
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndX
- End of coarse sampling range (i.e., 60 degrees)._coarseRateX
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateX
- Point at which fine samples should be taken (i.e., every 15 degrees)._rotateBeginY
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndY
- End of coarse sampling range (i.e., 60 degrees)._coarseRateY
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateY
- Point at which fine samples should be taken (i.e., every 15 degrees)._rotateBeginZ
- Beginning of coarse sampling range (i.e., -60 degrees)._rotateEndZ
- End of coarse sampling range (i.e., 60 degrees)._coarseRateZ
- Point at which coarse samples should be taken (i.e., every 45 degrees)._fineRateZ
- Point at which fine samples should be taken (i.e., every 15 degrees)._maxResol
- If true is the maximum of the minimum resolution of the two datasets when resampling._doSubsample
- If true then subsample_doMultiThread
-_fastMode
- If true then searching the parameter space is not conducted and the algorithm proceeds to level one immediately_baseNumIter
- Limits the number of iterations of ELSUNC algorithm. maxIter in the call to ELSUNC will be an integer multiple of baseNumIter_numMinima
- Number of minima from level 8 to test at level 4searchAlgorithm
- ESLUNC, LEVENBERG_MARQUARDT, or NL2SOL.
-
-
Method Detail
-
calculateCenterOfMass3D
public 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 datawgtImage
- DOCUMENT ME!isColor
- DOCUMENT ME!- Returns:
- the center of mass as a 3D 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 classAlgorithmBase
-
getAnswer
public double getAnswer()
Accessor that returns the final cost function.- Returns:
- Matrix found at the end of algorithm.
-
getTransArray
public double[] getTransArray()
Access that returns an array containing the transformation parameters.- Returns:
- transformation array (0-2 rot, 3-5 trans, 6-9 scale, 9-12 skew)
-
getTransform
public TransMatrix getTransform()
Accessor that returns the matrix calculated in this algorithm.- Returns:
- Matrix found at the end of algorithm.
-
getTransformHalf
public TransMatrix getTransformHalf()
Accessor that returns the matrix calculated in this algorithm divided by 2.- Returns:
- Matrix found at the end of algorithm with the compoents halved.
-
getTransformMigsagittal
public TransMatrix getTransformMigsagittal()
Accessor that returns the z rot and x and y trans from the matrix calculated in this algorithm.- Returns:
- z rotation and x and y translations from the matrix found at the end of algorithm.
-
runAlgorithm
public void runAlgorithm()
Runs the image registration. Blurs the images based on what their minimum resolutions are. The reference image is blurred if one of the input image resolutions is 50% or more bigger than the corresponding resolution in the reference image; likewise, the input image is blurred if one of the reference resolutions is 50% or more bigger than the corresponding resolution in the input image. Thus, it is unlikely, though not impossible, that both images will be blurred. The images are then transformed into isotropic voxels. The resolutions of the two images after the isotropic transformation will be the same in all dimensions. If maxResol is true, that resolution will equal the maximum of the minimums of each image's resolutions: Max( Min (resolutions of ref image, resolutions of input image) ). If the images are weighted, the weight images are blurred and transformed into isotropic voxels in the same manner as the originals. Then the images are subsampled by 2, 4, and 8. If the images are too small they will not be subsampled down to the smallest level; if they are too big, they will be subsampled to 16. The same is done with the weight images if necessary. The function levelEight is called with the images subsampled by 8; it returns two vectors with minima. Then the function levelFour is called with images subsampled by 4 and the two vectors; it returns one vector of minima. The function levelTwo is called with images 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 will then be accessed by the dialog that called this algorithm.- Specified by:
runAlgorithm
in classAlgorithmBase
-
subsampleBy2
public static ModelSimpleImage subsampleBy2(ModelSimpleImage srcImage, boolean isColor)
Takes a simple image and subsamples it by 2, interpolating so that the new values are averages.- Parameters:
srcImage
- Image to subsample.isColor
- DOCUMENT ME!- Returns:
- Subsampled image.
-
subsampleBy2XY
public static ModelSimpleImage subsampleBy2XY(ModelSimpleImage srcImage, 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.isColor
- DOCUMENT ME!- Returns:
- Subsampled image.
-
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 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 AlgorithmELSUNC works in degrees) Scaling tolerance = n/(2R) Skewing tolerance = n/(2R)
-
interpolate
private 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 istrue
, set three translations and a scale. Otherwise just set translations.tranforms
- DOCUMENT ME!scale
-true
means set the scale in the vector.
-
levelEight
public java.util.Vector<MatrixListItem>[] levelEight(ModelSimpleImage ref, ModelSimpleImage input, float progressFrom, float progressTo)
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. Removes those items that are outside the rotation begin and end limits. 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.
-
levelFour
public java.util.Vector<MatrixListItem> levelFour(ModelSimpleImage ref, ModelSimpleImage input, java.util.Vector<MatrixListItem> minima, java.util.Vector<MatrixListItem> optMinima, float progressFrom, float progressTo)
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.
-
levelOne
public MatrixListItem levelOne(ModelSimpleImage ref, ModelSimpleImage input, MatrixListItem item, int maxIter, float progressFrom, float progressTo)
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.
-
levelTwo
public MatrixListItem levelTwo(ModelSimpleImage ref, ModelSimpleImage input, java.util.Vector<MatrixListItem> minima, float progressFrom, float progressTo)
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.
-
getLevel1FactorXY
public float getLevel1FactorXY()
-
setLevel1FactorXY
public void setLevel1FactorXY(float level1FactorXY)
-
getLevel1FactorZ
public float getLevel1FactorZ()
-
setLevel1FactorZ
public void setLevel1FactorZ(float level1FactorZ)
-
getLevel2FactorXY
public float getLevel2FactorXY()
-
setLevel2FactorXY
public void setLevel2FactorXY(float level2FactorXY)
-
getLevel2FactorZ
public float getLevel2FactorZ()
-
setLevel2FactorZ
public void setLevel2FactorZ(float level2FactorZ)
-
getLevel4FactorXY
public float getLevel4FactorXY()
-
setLevel4FactorXY
public void setLevel4FactorXY(float level4FactorXY)
-
getLevel4FactorZ
public float getLevel4FactorZ()
-
setLevel4FactorZ
public void setLevel4FactorZ(float level4FactorZ)
-
algorithmPerformed
public void algorithmPerformed(AlgorithmBase algorithm)
Description copied from interface:AlgorithmInterface
Called after an algorithm this listener is registered to exits (maybe successfully, maybe not). If the algorithm is run in a separate thread, this call will be made within that thread. If not, this call will be made from that same, shared thread.- Specified by:
algorithmPerformed
in interfaceAlgorithmInterface
- Parameters:
algorithm
- the algorithm which has just completed
-
-