Class AlgorithmColocalizationEM
- All Implemented Interfaces:
ActionListener,WindowListener,Runnable,EventListener
A histogram buffer is generated with bin1 counts along the x axis and bin2 counts along the y axis. bin1 and bin2 are user selectable in the dialog. leftPad, rightPad, bottomPad, and topPad spaces are left around the data area in histBuffer to allow room for axis lines and labels.
The user specifies the number of gaussian distributions. For each distribution the initial values of the means, standard deviations, and correlation are assigned using a random number generator. Each distribution is initially assigned an equal probability.
The ellipse corresponds to a contour of constant probabliity density on which the density is smaller by a factor of exp[-0.5] than it is at the mean point. The probability density function is a jointly gaussian or bivariate gaussian density function. In each iteration: 1.) Find the gaussian distribution j with the form: p(x,y/j) = (1/(2*PI*stdxj*stdyj*sqrt(1 - rhoj**2))) * exp{(-1/(2*(1 - rhoj**2)))[((x-meanxj)**2)/(stdxj**2) - (2*rhoj*(x-meanxj)*(y-meanyj))/(stdxj*stdyj) + ((y - meanyj)**2)/(stdyj**2)]} where stdxj and stdyj are the x and y standard deviations and rhoj is the correlation coefficient.
2.) p(x,y) are found from p(x,y) = sum over j of p(x,y/j)*p(j). 3.) Pold(j/(x,y) = (sum over all j of Pold(x,y/j)*Pold(j))/Pold(x,y)
The update equations for the values of the new variables for each gaussian distribution j are: 4.) meanxj = (sum over x,y of Pold(j/(x,y))*x)/(sum over x,y of Pold(j/(x,y))) 5.) meanyj = (sum over x,y of Pold(j/(x,y))*y)/(sum over x,y of Pold(j/(x,y))) 6.) stdxj**2 = (sum over x,y of Pold(j/(x,y)) * (x - meanxj)**2)/ (sum over x,y of Pold(j/(x,y))) 7.) stdyj**2 = (sum over x,y of Pold(j/(x,y)) * (y - meanyj)**2)/ (sum over x,y of Pold(j/(x,y))) 8.) rhoj = (sum over x,y of Pold(j/(x,y)) * (x - meanxj) * (y - meanyj)/(stdjx * stdjy))/ (sum over x,y of Pold(j/(x,y)))
9.) Each new p[j] is found from (sum over x,y of Pold(j/(x,y)))/number of (x,y) points These 9 basic steps are iterated the number of times specified by the user.
The calculated data is passed to ViewJFrameColocalization.
References:
1.) Expectation Maximization Algorithm by Ismet Bayraktaroglu (ismet@bayraktaroglu.org) Code for circles was originally found at http://www-cse.ucsd.edu/users/ibayrakt/java/em but this site is no longer available.
2.) Neural Networks for Pattern Recognition by Christopher M. Bishop, Oxford University Press, 1995, Section 2.6.2 The EM algorithm, pp. 65 - 72.
3.) Probability, Random Variables, and Random Signal Principles, Second Edition by Peyton Z. Peebles, Jr., McGraw-Hill Book Company, 1987, Section 5.3 Jointly Gaussian Random Variables, pp. 124 - 128.
4.) Clustering Algorithms by John A. Hartigan, Wiley, John invalid input: '&' Sons, Incorporated, 1975, Chapter 5, Mixtures, pp. 113 - 129.
5.) Principles of Data Mining by David Hand, Heikki Mannila, and Padhraic Smith, A Bradford Book The MIT Press, 2001, pp. 260 - 265, 281 - 284, 315 - 323.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescription(package private) float[]DOCUMENT ME!(package private) float[]DOCUMENT ME!private ModelImageDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!(package private) float[]DOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private booleanIf true, or thresholds.private booleanDOCUMENT ME!private intDOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!(package private) BitSetDOCUMENT ME!private intDOCUMENT ME!private intSpace padding around the histogram data area.private double[][]DOCUMENT ME!private double[][]DOCUMENT ME!private byte[]DOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private booleanDOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private intDOCUMENT ME!(package private) float[]DOCUMENT ME!private byte[]DOCUMENT ME!private ModelImageDisplays classes to which pixels belong.private double[][]DOCUMENT ME!private double[][]DOCUMENT ME!private double[]DOCUMENT ME!private floatThe minimum values that are considered as data values.private floatDOCUMENT ME!private intDOCUMENT ME!private booleanDOCUMENT ME!private booleanDOCUMENT ME!private booleanDOCUMENT ME!(package private) intDOCUMENT ME!(package private) intDOCUMENT ME!(package private) intDOCUMENT 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, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmColocalizationEM(ModelImage destImg, ModelImage segImage, ModelImage srcImg, int bin1, int bin2, float threshold1, float threshold2, boolean doOr, int leftPad, int rightPad, int bottomPad, int topPad, boolean useRed, boolean useGreen, boolean useBlue, boolean entireImage, boolean register, int cost, int gaussians, int iterations) Constructor for images in which 2D histogram is placed in a predetermined destination image.AlgorithmColocalizationEM(ModelImage destImg, ModelImage segImage, ModelImage srcImg, ModelImage baseImage, int bin1, int bin2, float threshold1, float threshold2, boolean doOr, int leftPad, int rightPad, int bottomPad, int topPad, boolean entireImage, boolean register, int cost, int gaussians, int iterations) Constructor for images in which 2D histogram is placed in a predetermined destination image. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcalc2D()This function produces a 2D histogram image with srcImage values represented across the x axis and baseImage values represented across the y axis.private voidcalc3D()This function produces a 2D histogram image with srcImage values represented across the x axis and baseImage values represented across the y axis.private voidThis function produces a 2D histogram image with first color values represented across the x axis and second color values represented across the y axis.private voidThis function produces a 2D histogram image with first color values represented across the x axis and second color values represented across the y axis.private voidDOCUMENT ME!voidfinalize()Prepares this class for destruction.private voidgetProbX()DOCUMENT ME!private voidDOCUMENT ME!private voidnewToOld()DOCUMENT ME!private doubleprobjxOld(int i, int j) DOCUMENT ME!private doubleprobXj(int i, int j) DOCUMENT ME!private doubleprobXjOld(int i, int j) DOCUMENT ME!voidstarts the algorithm.voidupdateFileInfo(ModelImage image, ModelImage resultImage) Copy important file information to resultant image structure.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, windowOpenedMethods 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
b1
float[] b1DOCUMENT ME! -
b2
float[] b2DOCUMENT ME! -
buffer
float[] bufferDOCUMENT ME! -
inputMask
BitSet inputMaskDOCUMENT ME! -
secondBuffer
float[] secondBufferDOCUMENT ME! -
xDim
int xDimDOCUMENT ME! -
yDim
int yDimDOCUMENT ME! -
zDim
int zDimDOCUMENT ME! -
baseImage
DOCUMENT ME! -
bin1
private int bin1DOCUMENT ME! -
bin2
private int bin2DOCUMENT ME! -
bottomPad
private int bottomPadDOCUMENT ME! -
cost
private int costDOCUMENT ME! -
count
private int countDOCUMENT ME! -
dMax
private double[] dMaxDOCUMENT ME! -
dMin
private double[] dMinDOCUMENT ME! -
doOr
private boolean doOrIf true, or thresholds. If false, and thresholds -
entireImage
private boolean entireImageDOCUMENT ME! -
gaussians
private int gaussiansDOCUMENT ME! -
halfMajor
private double[] halfMajorDOCUMENT ME! -
halfMinor
private double[] halfMinorDOCUMENT ME! -
iterations
private int iterationsDOCUMENT ME! -
leftPad
private int leftPadSpace padding around the histogram data area. -
mean
private double[][] meanDOCUMENT ME! -
meanOld
private double[][] meanOldDOCUMENT ME! -
mostProbableClass
private byte[] mostProbableClassDOCUMENT ME! -
prob
private double[] probDOCUMENT ME! -
probOld
private double[] probOldDOCUMENT ME! -
probX
private double[] probXDOCUMENT ME! -
probXOld
private double[] probXOldDOCUMENT ME! -
register
private boolean registerDOCUMENT ME! -
rho
private double[] rhoDOCUMENT ME! -
rhoOld
private double[] rhoOldDOCUMENT ME! -
rightPad
private int rightPadDOCUMENT ME! -
segBuffer
private byte[] segBufferDOCUMENT ME! -
segImage
Displays classes to which pixels belong. -
std
private double[][] stdDOCUMENT ME! -
stdOld
private double[][] stdOldDOCUMENT ME! -
theta
private double[] thetaDOCUMENT ME! -
threshold1
private float threshold1The minimum values that are considered as data values. -
threshold2
private float threshold2DOCUMENT ME! -
topPad
private int topPadDOCUMENT ME! -
useBlue
private boolean useBlueDOCUMENT ME! -
useGreen
private boolean useGreenDOCUMENT ME! -
useRed
private boolean useRedDOCUMENT ME!
-
-
Constructor Details
-
AlgorithmColocalizationEM
public AlgorithmColocalizationEM(ModelImage destImg, ModelImage segImage, ModelImage srcImg, ModelImage baseImage, int bin1, int bin2, float threshold1, float threshold2, boolean doOr, int leftPad, int rightPad, int bottomPad, int topPad, boolean entireImage, boolean register, int cost, int gaussians, int iterations) Constructor for images in which 2D histogram is placed in a predetermined destination image. Used for 2 black and white images- Parameters:
destImg- image model where result image is to storedsegImage- image to display classes to which pixels belongsrcImg- image for x axis of histogrambaseImage- image for y axis of histogrambin1- histogram x axis bin numberbin2- histogram y axis bin numberthreshold1- minimum value for data in sourceImagethreshold2- minimum value for data in baseImagedoOr- If true, or thresholds. If false, and thresholds.leftPad- space to the left of the histogram bin arearightPad- space to the right of the histogram bin areabottomPad- space to the bottom of the histogram bin areatopPad- space to the top of the histogram bin areaentireImage- If false, only use data from VOI regionregister- If true register 2 black and white images before colocalizationcost- Cost function used in registrationgaussians- Number of gaussiansiterations- Number of iterations
-
AlgorithmColocalizationEM
public AlgorithmColocalizationEM(ModelImage destImg, ModelImage segImage, ModelImage srcImg, int bin1, int bin2, float threshold1, float threshold2, boolean doOr, int leftPad, int rightPad, int bottomPad, int topPad, boolean useRed, boolean useGreen, boolean useBlue, boolean entireImage, boolean register, int cost, int gaussians, int iterations) Constructor for images in which 2D histogram is placed in a predetermined destination image. Used for 1 color image.- Parameters:
destImg- image model where result image is to storedsegImage- image to display classes to which pixels belongsrcImg- source image modelbin1- histogram x axis bin numberbin2- histogram y axis bin numberthreshold1- minimum data value for first colorthreshold2- minimum data value for second colordoOr- If true, or thresholds. If false, and thresholds.leftPad- space to the left of the histogram bin arearightPad- space to the right of the histogram bin areabottomPad- space to the bottom of the histogram bin areatopPad- space to the top of the histogram bin areauseRed- DOCUMENT ME!useGreen- DOCUMENT ME!useBlue- DOCUMENT ME!entireImage- If false, use only data from VOI regionregister- If true, register 2 colors before colocalizationcost- Cost function used in registrationgaussians- Number of gaussiansiterations- Number of iterations
-
-
Method Details
-
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()starts the algorithm.- Specified by:
runAlgorithmin classAlgorithmBase
-
updateFileInfo
Copy important file information to resultant image structure.- Parameters:
image- Source image.resultImage- Resultant image.
-
calc2D
private void calc2D()This function produces a 2D histogram image with srcImage values represented across the x axis and baseImage values represented across the y axis. -
calc3D
private void calc3D()This function produces a 2D histogram image with srcImage values represented across the x axis and baseImage values represented across the y axis. -
calcColor2D
private void calcColor2D()This function produces a 2D histogram image with first color values represented across the x axis and second color values represented across the y axis. -
calcColor3D
private void calcColor3D()This function produces a 2D histogram image with first color values represented across the x axis and second color values represented across the y axis. -
emfunction
private void emfunction()DOCUMENT ME! -
getProbX
private void getProbX()DOCUMENT ME! -
getProbXOld
private void getProbXOld()DOCUMENT ME! -
newToOld
private void newToOld()DOCUMENT ME! -
probjxOld
private double probjxOld(int i, int j) DOCUMENT ME!- Parameters:
i- DOCUMENT ME!j- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
probXj
private double probXj(int i, int j) DOCUMENT ME!- Parameters:
i- DOCUMENT ME!j- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
probXjOld
private double probXjOld(int i, int j) DOCUMENT ME!- Parameters:
i- DOCUMENT ME!j- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-