edu.jhu.bme.smile.commons.optimize.tensor
Class MLTensor

java.lang.Object
  extended by edu.jhu.bme.smile.commons.optimize.tensor.MLTensor

public class MLTensor
extends java.lang.Object

This class is used to minimize the least likelihood estimator from data from diffusion weighted imaging. It appears that all the algorithms but Line Search using Newton's method are very stable. The Line Searches are fairly slow since they have to iterate through the optimizer so many times. Both Downhill Simplex and LM are very fast, with Downhill Simplex only slightly faster with this function. With nicer functions LM can be significantly faster than Downhill Simplex as demonstrated by the optimization of simpler functions in TestNDOptimizations.

Author:
Hanlin Wan

Field Summary
static double PLUS_EPSILON
           
 
Constructor Summary
MLTensor()
           
 
Method Summary
 double getB0()
          Gets the value of b0
 Matrix getD()
          Gets the D matrix
 int getIterations()
          Gets the number of iterations required to calculate the result.
 double getSigma()
          Gets the value of sigma.
 void init(Matrix imgMatrix, double b0, double sigma, double obsB0, double[] obsDW, double[] dInit)
          Initializes MLTensor with these parameters
 double LLvalue()
          Calculates the least likelihood value
 boolean optimize6D2D(int method, int maxIter)
          Lets you specify which algorithm to use and the maximum number of iterations.
 boolean optimize8D(int method)
          Lets you specify which algorithm to use to optimize all 8 parameters at once.
 void setDFactor(double d)
          Sets the scaling factor for D.
 void setDomain(double[] min, double[] max)
          Sets the domain minimum and maximum values.
 void setMethod(int m)
          Sets the method used to calculate the derivatives.
 void setSigmaFactor(double s)
          Sets the scaling factor for sigma.
 void setStepSize(double s)
          Sets the step size used in calculating derivatives.
 void setTolerance(double t)
          Sets the tolerance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLUS_EPSILON

public static double PLUS_EPSILON
Constructor Detail

MLTensor

public MLTensor()
Method Detail

init

public void init(Matrix imgMatrix,
                 double b0,
                 double sigma,
                 double obsB0,
                 double[] obsDW,
                 double[] dInit)
Initializes MLTensor with these parameters

Parameters:
imgMatrix - image matrix
b0 - b0
sigma - standard deviation
obsB0 - observed b0
obsDW - observed diffusion weighted data
dInit - initial tensor

optimize8D

public boolean optimize8D(int method)
Lets you specify which algorithm to use to optimize all 8 parameters at once.

Parameters:
method - 0 - Downhill Simplex; 1 - LM; 2 - Line Search using Golden Section Search 3 - Line Search using Brent's Method; 4 - Line Search using Newton
Returns:
whether the optimization was successful

optimize6D2D

public boolean optimize6D2D(int method,
                            int maxIter)
Lets you specify which algorithm to use and the maximum number of iterations. It will optimize alternate between optimizing D and optimizing b0 and sigma.

Parameters:
method - 0 - Downhill Simplex; 1 - LM; 2 - Line Search using Golden Section Search 3 - Line Search using Brent's; 4 - Line Search using Newton
maxIter - maximum number of iterations
Returns:
whether the optimization was successful

LLvalue

public double LLvalue()
Calculates the least likelihood value

Returns:
LLvalue

getB0

public double getB0()
Gets the value of b0

Returns:
b0

getSigma

public double getSigma()
Gets the value of sigma. If sigma is less than 1e-6, 1e-6 is returned.

Returns:
sigma

getD

public Matrix getD()
Gets the D matrix

Returns:
D

setSigmaFactor

public void setSigmaFactor(double s)
Sets the scaling factor for sigma. You want a value that when multiplied by sigma, you get a number in the same order of magnitude as b0. This is to ensure that when optimizing, the parameters are not too far apart. The default sigmaFactor is set to be b0/(10*sigma).

Parameters:
s - number to scale sigma by

setDFactor

public void setDFactor(double d)
Sets the scaling factor for D. The default is set to 1e6.

Parameters:
d - number to scale D by

setTolerance

public void setTolerance(double t)
Sets the tolerance. Default value is 0.001.

Parameters:
t - tolerance

setStepSize

public void setStepSize(double s)
Sets the step size used in calculating derivatives. The default is set to 0.1.

Parameters:
s - step size

setMethod

public void setMethod(int m)
Sets the method used to calculate the derivatives. The default is set to 3-point.

Parameters:
m - method

setDomain

public void setDomain(double[] min,
                      double[] max)
Sets the domain minimum and maximum values. The default values are as follows: b0 and sigma - 0.5 to 2 times the initial value D - minimum is 0. Maximum is 2 times the initial value but is at least 1e-3.

Parameters:
min - domain minimum array of size 8
max - domain maximum array of size 8

getIterations

public int getIterations()
Gets the number of iterations required to calculate the result.

Returns:
number of iterations