Package gov.nih.mipav.model.algorithms
Class GaussianMixtureModelsIncompleteSamples
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.GaussianMixtureModelsIncompleteSamples
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class GaussianMixtureModelsIncompleteSamples extends AlgorithmBase
dirichletRnd ported from mixGaussRnd.m by Mo Chen Copyright (c) 2016, Mo Chen All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution Neither the name of nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
GaussianMixtureModelsIncompleteSamples.Background
(package private) class
GaussianMixtureModelsIncompleteSamples.GMM
-
Field Summary
Fields Modifier and Type Field Description private double[][][]
covar_callback_default_arr
private int
D
private int
K
-
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 GaussianMixtureModelsIncompleteSamples()
GaussianMixtureModelsIncompleteSamples(int K, int D)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
_drawGMM_BG(java.util.Vector<double[][]> data2Vec, java.util.Vector<double[][][]> covar2Vec, GaussianMixtureModelsIncompleteSamples.GMM gmm, double size, java.lang.String covar_callback, GaussianMixtureModelsIncompleteSamples.Background background, java.util.Random rng)
void
_EM(double[] log_L, int[] N, double[] N2, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] log_p, int[][] U, double[][][][] T_inv, double[] log_S, double[][] data, double[][][] covar, double[][][] R, java.lang.String sel_callback, int oversampling, java.lang.String covar_callback, GaussianMixtureModelsIncompleteSamples.Background background, double[][] p_bg, double w, double cutoff, int miniter, int maxiter, double tol, java.lang.String prefix, boolean[] changeable_amp, boolean[] changeable_mean, boolean[] changeable_covar, java.util.Random rng)
void
_EMstep(double[] log_L, int[] N, double[] N2, double[] N0update, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] log_p, int[][] U, double[][][][] T_inv, double[] log_S, double N0, double[][] data, double[][][] covar, double[][][] R, java.lang.String sel_callback, double[] omega, int oversampling, java.lang.String covar_callback, GaussianMixtureModelsIncompleteSamples.Background background, double[][] p_bg, double w, double cutoff, double tol, boolean[] changeable_amp, boolean[] changeable_mean, boolean[] changeable_covar, int it, java.util.Random rng)
double
_Estep(GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] log_p, int[][] U, double[][][][] T_inv, double[] log_S, double[][] data, double[][][] covar, double[][][] R, double[] omega, GaussianMixtureModelsIncompleteSamples.Background background, double[][] p_bg, double cutoff, int it, java.util.Random rng)
void
_Esum(double[][] log_p, double[][][][] T_inv, int k, int[][] U, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, double[][][] covar, double[][][] R, double cutoff)
void
_findSNMComponents(int[] changing, boolean[] cleanup, GaussianMixtureModelsIncompleteSamples.GMM gmm, int[][] U, double[][] log_p, double[] log_S, double N)
double
_JS(int k, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] log_p, double[] log_S, int[][] U, double[] A)
void
_Mstep(double[] A, double[][] M, double[][][] C, double[] B, GaussianMixtureModelsIncompleteSamples.GMM gmm, int[][] U, double[][] log_p, double[][][][] T_inv, double[] log_S, double[][] data, double[][][] covar, double[][][] R, double[][] p_bg)
void
_Msums(double[] A, double[][] M, double[][][] C, int k, int[][] U, double[][] log_p, double[][][][] T_inv, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, double[][][] R, double[] log_S)
void
_update(GaussianMixtureModelsIncompleteSamples.GMM gmm, double[] A, double[][] M, double[][][] C, int[] N, double[] B, double[] A2, double[][] M2, double[][][] C2, double[] N2, double[] B2, double w, boolean[] changeable_amp, boolean[] changeable_mean, boolean[] changeable_covar, GaussianMixtureModelsIncompleteSamples.Background background)
void
_update_snm(GaussianMixtureModelsIncompleteSamples.GMM gmm, int[] changeable, int[][] U, double N, boolean cleanup)
(package private) double
asinh(double x)
int[]
bincount(int[] indices, int minlength)
int[][][]
binSample(double[][] coords, int C)
double
chi2_cutoff(int D, double cutoff)
double[][][]
covar_callback_default(double[][] coords)
double[]
dirichletRnd(double[] ain, double[] m)
void
draw(java.util.Vector<double[][]> dataVec, java.util.Vector<double[][][]> covarVec, double[] updated_orig_size, java.util.Vector<double[]> omegaVec, GaussianMixtureModelsIncompleteSamples.GMM gmm, int obs_size, java.lang.String sel_callback, boolean invert_sel, int orig_size, java.lang.String covar_callback, GaussianMixtureModelsIncompleteSamples.Background background, java.util.Random rng)
void
drawWithNbh(double[][] samples, int[][] nbh, GaussianMixtureModelsIncompleteSamples.GMM gmm, int size, java.util.Random rng)
private double
erf(double x)
double
fit(int[][] U, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, double[][][] covar, double[][][] R, java.lang.String init_method, double w, double cutoff, java.lang.String sel_callback, int oversampling, java.lang.String covar_callback, GaussianMixtureModelsIncompleteSamples.Background background, double tol, int miniter, int maxiter, int[] frozen_amp, int[] frozen_mean, int[] frozen_covar, int split_n_merge, java.util.Random rng)
double
gamrnd(double a, double b)
double[]
getAll(double[][] coords)
double[]
getBox(double[][] coords)
double[]
getBoxWithHole(double[][] coords)
double[]
getCut(double[][] coords)
double[]
getHalf(double[][] coords)
double[]
getHole(double[][] coords)
double[]
getNoSel(double[][] coords)
double[]
getSelection(java.lang.String sel_type, double[][] noisy, java.util.Random rng)
double[]
getSlopeSel(double[][] coords, java.util.Random rng)
boolean[]
GMMSel(double[][] coords, double[][][] covar, GaussianMixtureModelsIncompleteSamples.GMM sel_gmm, double cutoff_nd, java.util.Random rng)
void
initCube(GaussianMixtureModelsIncompleteSamples.GMM gmm, double w, java.util.Random rng)
void
initFromDataAtRandom(GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, double[][][] covar, double s, int[] k, java.util.Random rng)
void
initFromDataMinMax(GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, double[][][] covar, double s, int[] k, java.util.Random rng)
void
initFromKMeans(GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, java.util.Random rng)
boolean[]
insideComponent(int k, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] coords, double[][][] covar, double cutoff)
double
logsum(double[] input)
double[]
logsum(double[][] input)
void
match1d(java.util.Vector<java.lang.Integer> sub1Vec, java.util.Vector<java.lang.Integer> sub2Vec, int[] arr1Input, int[] arr2, boolean presorted)
void
plotDifferences(double[][] orig, double[][] data, GaussianMixtureModelsIncompleteSamples.GMM[] gmms, GaussianMixtureModelsIncompleteSamples.GMM avg, double[] l)
void
plotResults(double[][] orig, double[][] data, GaussianMixtureModelsIncompleteSamples.GMM gmm, java.lang.String description, double disp)
void
printResults(GaussianMixtureModelsIncompleteSamples.GMM gmm, java.lang.String description)
void
runAlgorithm()
Actually runs the algorithm.GaussianMixtureModelsIncompleteSamples.GMM
stack(GaussianMixtureModelsIncompleteSamples.GMM[] gmms, double[] weights)
GaussianMixtureModelsIncompleteSamples.GMM
stack_fit(GaussianMixtureModelsIncompleteSamples.GMM[] gmms, double[][] data, double[][][] covar, java.lang.String init_callback, double w, double cutoff, java.lang.String sel_callback, java.lang.String covar_callack, GaussianMixtureModelsIncompleteSamples.Background bg, int L, double tol, java.util.Random rng)
void
test()
void
test_3D()
-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, finalize, 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
-
-
-
-
Method Detail
-
test
public void test()
-
test_3D
public void test_3D()
-
GMMSel
public boolean[] GMMSel(double[][] coords, double[][][] covar, GaussianMixtureModelsIncompleteSamples.GMM sel_gmm, double cutoff_nd, java.util.Random rng)
-
insideComponent
public boolean[] insideComponent(int k, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] coords, double[][][] covar, double cutoff)
-
binSample
public int[][][] binSample(double[][] coords, int C)
-
drawWithNbh
public void drawWithNbh(double[][] samples, int[][] nbh, GaussianMixtureModelsIncompleteSamples.GMM gmm, int size, java.util.Random rng)
-
bincount
public int[] bincount(int[] indices, int minlength)
-
initCube
public void initCube(GaussianMixtureModelsIncompleteSamples.GMM gmm, double w, java.util.Random rng)
-
dirichletRnd
public double[] dirichletRnd(double[] ain, double[] m)
-
gamrnd
public double gamrnd(double a, double b)
-
getSlopeSel
public double[] getSlopeSel(double[][] coords, java.util.Random rng)
-
getNoSel
public double[] getNoSel(double[][] coords)
-
printResults
public void printResults(GaussianMixtureModelsIncompleteSamples.GMM gmm, java.lang.String description)
-
stack_fit
public GaussianMixtureModelsIncompleteSamples.GMM stack_fit(GaussianMixtureModelsIncompleteSamples.GMM[] gmms, double[][] data, double[][][] covar, java.lang.String init_callback, double w, double cutoff, java.lang.String sel_callback, java.lang.String covar_callack, GaussianMixtureModelsIncompleteSamples.Background bg, int L, double tol, java.util.Random rng)
-
stack
public GaussianMixtureModelsIncompleteSamples.GMM stack(GaussianMixtureModelsIncompleteSamples.GMM[] gmms, double[] weights)
-
getSelection
public double[] getSelection(java.lang.String sel_type, double[][] noisy, java.util.Random rng)
-
runAlgorithm
public void runAlgorithm()
Description copied from class:AlgorithmBase
Actually runs the algorithm. Implemented by inheriting algorithms.- Specified by:
runAlgorithm
in classAlgorithmBase
-
logsum
public double logsum(double[] input)
-
logsum
public double[] logsum(double[][] input)
-
getBox
public double[] getBox(double[][] coords)
-
getHole
public double[] getHole(double[][] coords)
-
getBoxWithHole
public double[] getBoxWithHole(double[][] coords)
-
getCut
public double[] getCut(double[][] coords)
-
getAll
public double[] getAll(double[][] coords)
-
getHalf
public double[] getHalf(double[][] coords)
-
plotDifferences
public void plotDifferences(double[][] orig, double[][] data, GaussianMixtureModelsIncompleteSamples.GMM[] gmms, GaussianMixtureModelsIncompleteSamples.GMM avg, double[] l)
-
plotResults
public void plotResults(double[][] orig, double[][] data, GaussianMixtureModelsIncompleteSamples.GMM gmm, java.lang.String description, double disp)
-
asinh
double asinh(double x)
-
fit
public double fit(int[][] U, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, double[][][] covar, double[][][] R, java.lang.String init_method, double w, double cutoff, java.lang.String sel_callback, int oversampling, java.lang.String covar_callback, GaussianMixtureModelsIncompleteSamples.Background background, double tol, int miniter, int maxiter, int[] frozen_amp, int[] frozen_mean, int[] frozen_covar, int split_n_merge, java.util.Random rng)
-
_update_snm
public void _update_snm(GaussianMixtureModelsIncompleteSamples.GMM gmm, int[] changeable, int[][] U, double N, boolean cleanup)
-
_findSNMComponents
public void _findSNMComponents(int[] changing, boolean[] cleanup, GaussianMixtureModelsIncompleteSamples.GMM gmm, int[][] U, double[][] log_p, double[] log_S, double N)
-
_JS
public double _JS(int k, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] log_p, double[] log_S, int[][] U, double[] A)
-
match1d
public void match1d(java.util.Vector<java.lang.Integer> sub1Vec, java.util.Vector<java.lang.Integer> sub2Vec, int[] arr1Input, int[] arr2, boolean presorted)
-
_EM
public void _EM(double[] log_L, int[] N, double[] N2, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] log_p, int[][] U, double[][][][] T_inv, double[] log_S, double[][] data, double[][][] covar, double[][][] R, java.lang.String sel_callback, int oversampling, java.lang.String covar_callback, GaussianMixtureModelsIncompleteSamples.Background background, double[][] p_bg, double w, double cutoff, int miniter, int maxiter, double tol, java.lang.String prefix, boolean[] changeable_amp, boolean[] changeable_mean, boolean[] changeable_covar, java.util.Random rng)
-
_EMstep
public void _EMstep(double[] log_L, int[] N, double[] N2, double[] N0update, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] log_p, int[][] U, double[][][][] T_inv, double[] log_S, double N0, double[][] data, double[][][] covar, double[][][] R, java.lang.String sel_callback, double[] omega, int oversampling, java.lang.String covar_callback, GaussianMixtureModelsIncompleteSamples.Background background, double[][] p_bg, double w, double cutoff, double tol, boolean[] changeable_amp, boolean[] changeable_mean, boolean[] changeable_covar, int it, java.util.Random rng)
-
_update
public void _update(GaussianMixtureModelsIncompleteSamples.GMM gmm, double[] A, double[][] M, double[][][] C, int[] N, double[] B, double[] A2, double[][] M2, double[][][] C2, double[] N2, double[] B2, double w, boolean[] changeable_amp, boolean[] changeable_mean, boolean[] changeable_covar, GaussianMixtureModelsIncompleteSamples.Background background)
-
draw
public void draw(java.util.Vector<double[][]> dataVec, java.util.Vector<double[][][]> covarVec, double[] updated_orig_size, java.util.Vector<double[]> omegaVec, GaussianMixtureModelsIncompleteSamples.GMM gmm, int obs_size, java.lang.String sel_callback, boolean invert_sel, int orig_size, java.lang.String covar_callback, GaussianMixtureModelsIncompleteSamples.Background background, java.util.Random rng)
-
_drawGMM_BG
public void _drawGMM_BG(java.util.Vector<double[][]> data2Vec, java.util.Vector<double[][][]> covar2Vec, GaussianMixtureModelsIncompleteSamples.GMM gmm, double size, java.lang.String covar_callback, GaussianMixtureModelsIncompleteSamples.Background background, java.util.Random rng)
-
_Mstep
public void _Mstep(double[] A, double[][] M, double[][][] C, double[] B, GaussianMixtureModelsIncompleteSamples.GMM gmm, int[][] U, double[][] log_p, double[][][][] T_inv, double[] log_S, double[][] data, double[][][] covar, double[][][] R, double[][] p_bg)
-
_Msums
public void _Msums(double[] A, double[][] M, double[][][] C, int k, int[][] U, double[][] log_p, double[][][][] T_inv, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, double[][][] R, double[] log_S)
-
_Estep
public double _Estep(GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] log_p, int[][] U, double[][][][] T_inv, double[] log_S, double[][] data, double[][][] covar, double[][][] R, double[] omega, GaussianMixtureModelsIncompleteSamples.Background background, double[][] p_bg, double cutoff, int it, java.util.Random rng)
-
erf
private double erf(double x)
-
_Esum
public void _Esum(double[][] log_p, double[][][][] T_inv, int k, int[][] U, GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, double[][][] covar, double[][][] R, double cutoff)
-
chi2_cutoff
public double chi2_cutoff(int D, double cutoff)
-
covar_callback_default
public double[][][] covar_callback_default(double[][] coords)
-
initFromDataAtRandom
public void initFromDataAtRandom(GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, double[][][] covar, double s, int[] k, java.util.Random rng)
-
initFromKMeans
public void initFromKMeans(GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, java.util.Random rng)
-
initFromDataMinMax
public void initFromDataMinMax(GaussianMixtureModelsIncompleteSamples.GMM gmm, double[][] data, double[][][] covar, double s, int[] k, java.util.Random rng)
-
-