Class AlgorithmColocalizationEM

java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.AlgorithmColocalizationEM
All Implemented Interfaces:
ActionListener, WindowListener, Runnable, EventListener

public class AlgorithmColocalizationEM extends AlgorithmBase
An optional registration may be performed before colocalization. In this registration both images or colors are moved halfway to a common center point. AlgorithmRegOAR2D is used with the cost function being the only registration parameter the user can vary in the dialog box. Correlation ratio is the default, but the user can also select least squares, normalized cross correlation, or normalized mutual information. The colocalization will be performed on the registered image or images rather than on the original image. If the maximum data range is decreased, the bin1 or bin2 will be decreased if necessary to keep them from exceeding the actual number of channels in the data range.

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.

  • Field Details

    • b1

      float[] b1
      DOCUMENT ME!
    • b2

      float[] b2
      DOCUMENT ME!
    • buffer

      float[] buffer
      DOCUMENT ME!
    • inputMask

      BitSet inputMask
      DOCUMENT ME!
    • secondBuffer

      float[] secondBuffer
      DOCUMENT ME!
    • xDim

      int xDim
      DOCUMENT ME!
    • yDim

      int yDim
      DOCUMENT ME!
    • zDim

      int zDim
      DOCUMENT ME!
    • baseImage

      private ModelImage baseImage
      DOCUMENT ME!
    • bin1

      private int bin1
      DOCUMENT ME!
    • bin2

      private int bin2
      DOCUMENT ME!
    • bottomPad

      private int bottomPad
      DOCUMENT ME!
    • cost

      private int cost
      DOCUMENT ME!
    • count

      private int count
      DOCUMENT ME!
    • dMax

      private double[] dMax
      DOCUMENT ME!
    • dMin

      private double[] dMin
      DOCUMENT ME!
    • doOr

      private boolean doOr
      If true, or thresholds. If false, and thresholds
    • entireImage

      private boolean entireImage
      DOCUMENT ME!
    • gaussians

      private int gaussians
      DOCUMENT ME!
    • halfMajor

      private double[] halfMajor
      DOCUMENT ME!
    • halfMinor

      private double[] halfMinor
      DOCUMENT ME!
    • iterations

      private int iterations
      DOCUMENT ME!
    • leftPad

      private int leftPad
      Space padding around the histogram data area.
    • mean

      private double[][] mean
      DOCUMENT ME!
    • meanOld

      private double[][] meanOld
      DOCUMENT ME!
    • mostProbableClass

      private byte[] mostProbableClass
      DOCUMENT ME!
    • prob

      private double[] prob
      DOCUMENT ME!
    • probOld

      private double[] probOld
      DOCUMENT ME!
    • probX

      private double[] probX
      DOCUMENT ME!
    • probXOld

      private double[] probXOld
      DOCUMENT ME!
    • register

      private boolean register
      DOCUMENT ME!
    • rho

      private double[] rho
      DOCUMENT ME!
    • rhoOld

      private double[] rhoOld
      DOCUMENT ME!
    • rightPad

      private int rightPad
      DOCUMENT ME!
    • segBuffer

      private byte[] segBuffer
      DOCUMENT ME!
    • segImage

      private ModelImage segImage
      Displays classes to which pixels belong.
    • std

      private double[][] std
      DOCUMENT ME!
    • stdOld

      private double[][] stdOld
      DOCUMENT ME!
    • theta

      private double[] theta
      DOCUMENT ME!
    • threshold1

      private float threshold1
      The minimum values that are considered as data values.
    • threshold2

      private float threshold2
      DOCUMENT ME!
    • topPad

      private int topPad
      DOCUMENT ME!
    • useBlue

      private boolean useBlue
      DOCUMENT ME!
    • useGreen

      private boolean useGreen
      DOCUMENT ME!
    • useRed

      private boolean useRed
      DOCUMENT 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 stored
      segImage - image to display classes to which pixels belong
      srcImg - image for x axis of histogram
      baseImage - image for y axis of histogram
      bin1 - histogram x axis bin number
      bin2 - histogram y axis bin number
      threshold1 - minimum value for data in sourceImage
      threshold2 - minimum value for data in baseImage
      doOr - If true, or thresholds. If false, and thresholds.
      leftPad - space to the left of the histogram bin area
      rightPad - space to the right of the histogram bin area
      bottomPad - space to the bottom of the histogram bin area
      topPad - space to the top of the histogram bin area
      entireImage - If false, only use data from VOI region
      register - If true register 2 black and white images before colocalization
      cost - Cost function used in registration
      gaussians - Number of gaussians
      iterations - 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 stored
      segImage - image to display classes to which pixels belong
      srcImg - source image model
      bin1 - histogram x axis bin number
      bin2 - histogram y axis bin number
      threshold1 - minimum data value for first color
      threshold2 - minimum data value for second color
      doOr - If true, or thresholds. If false, and thresholds.
      leftPad - space to the left of the histogram bin area
      rightPad - space to the right of the histogram bin area
      bottomPad - space to the bottom of the histogram bin area
      topPad - space to the top of the histogram bin area
      useRed - DOCUMENT ME!
      useGreen - DOCUMENT ME!
      useBlue - DOCUMENT ME!
      entireImage - If false, use only data from VOI region
      register - If true, register 2 colors before colocalization
      cost - Cost function used in registration
      gaussians - Number of gaussians
      iterations - Number of iterations
  • Method Details

    • finalize

      public void finalize()
      Prepares this class for destruction.
      Overrides:
      finalize in class AlgorithmBase
    • runAlgorithm

      public void runAlgorithm()
      starts the algorithm.
      Specified by:
      runAlgorithm in class AlgorithmBase
    • updateFileInfo

      public void updateFileInfo(ModelImage image, ModelImage resultImage)
      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!