Class CAAMDeformPCA


public class CAAMDeformPCA extends CAAMDeform
This is the Java modified version of C++ active appearance model API (AAM_API). It is modified with a subset of required functions for automatic MRI prostate segmentation. AAM-API LICENSE - file: license.txt This software is freely available for non-commercial use such as research and education. Please see the full disclaimer below. All publications describing work using this software should cite the reference given below. Copyright (c) 2000-2003 Mikkel B. Stegmann, mbs@imm.dtu.dk IMM, Informatics invalid input: '&' Mathematical Modelling DTU, Technical University of Denmark Richard Petersens Plads, Building 321 DK-2800 Lyngby, Denmark http://www.imm.dtu.dk/~aam/ REFERENCES Please use the reference below, when writing articles, reports etc. where the AAM-API has been used. A draft version the article is available from the homepage. I will be happy to receive pre- or reprints of such articles. /Mikkel ------------- M. B. Stegmann, B. K. Ersboll, R. Larsen, "FAME -- A Flexible Appearance Modelling Environment", IEEE Transactions on Medical Imaging, IEEE, 2003 (to appear) ------------- 3RD PART SOFTWARE The software is partly based on the following libraries: - The Microsoft(tm) Vision Software Developers Kit, VisSDK - LAPACK DISCLAIMER This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any non-commercial purpose, and to alter it, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -- No guarantees of performance accompany this software, nor is any responsibility assumed on the part of the author or IMM. This software is provided by Mikkel B. Stegmann and IMM ``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 IMM or Mikkel B. Stegmann 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. $Revision: 1.4 $ $Date: 2003/04/23 14:49:15 $ Performs Principal Component Analysis on a set of data vectors. The PCA basis can then be used for shape deformation.
Author:
Ruida Cheng
  • Field Details

    • m_mEigenVectors

      private CDMatrix m_mEigenVectors
    • m_vEigenValues

      private CDVector m_vEigenValues
    • m_vEigenValuesOrg

      private CDVector m_vEigenValuesOrg
    • m_vvData

      private Vector<CDVector> m_vvData
    • m_vDataMean

      private CDVector m_vDataMean
  • Constructor Details

    • CAAMDeformPCA

      public CAAMDeformPCA()
  • Method Details

    • EigenValues

      public CDVector EigenValues()
      Returns the eigen values in vector form.
      Returns:
      eigen values
    • EigenValuesOrg

      public final CDVector EigenValuesOrg()
      Returns the orignal eigen values in vector form.
      Returns:
      eigen values original
    • EigenVectors

      public CDMatrix EigenVectors()
      Returns the eigen vectors in matrix form.
      Returns:
      eigen vectors
    • NParameters

      public int NParameters()
      Returns the number of principal parameters.
      Specified by:
      NParameters in class CAAMDeform
      Returns:
      length of eigen values
    • NParametersOrg

      public int NParametersOrg()
      Returns the number of princal parameters before any truncation.
      Specified by:
      NParametersOrg in class CAAMDeform
      Returns:
      eigen values original length
    • ClearDataItems

      public void ClearDataItems()
      Deletes the data matrix.
      Specified by:
      ClearDataItems in class CAAMDeform
    • NDataItems

      public final int NDataItems()
      Returns the number of data items this basis is based on.
      Returns:
      data matrix size
    • ParameterWeight

      public double ParameterWeight(int i, boolean asPercentage)
      Returns the eigenvalue of the i-th parameter in absolute numbers or as percentage.
      Specified by:
      ParameterWeight in class CAAMDeform
      Parameters:
      i - index
      asPercentage - boolean flag to indicate % return or abs number
      Returns:
      ret the eigenvalue.
    • ParameterWeightOrg

      public double ParameterWeightOrg(int i, boolean asPercentage)
      Returns the eigenvalue of the i-th parameter in absolute numbers or as percentage.
      Specified by:
      ParameterWeightOrg in class CAAMDeform
      Parameters:
      i - index
      asPercentage - boolean flag to indicate % return or abs number
      Returns:
      ret the eigenvalue.
    • InsertDataItem

      public void InsertDataItem(CDVector v)
      Inserts a data vector
      Parameters:
      v - a data vector
    • UseIdentityTransformation

      public void UseIdentityTransformation()
      Makes the object use an identity basis instead of PCA basis, i.e. essentially a by-pass of this object.
    • DoPCA

      public boolean DoPCA()
      Apply PCA analysis
      Returns:
      success or not.
    • DoPCA

      public boolean DoPCA(boolean bWriteCoVarMatrix)
      Performs the principal component analysis on the data items. Uses the Eckhart-Young theorem if necessary for reduced memory and computational requirements.
      Parameters:
      bWriteCoVarMatrix - If true the covariance matrix is written to the current dir. NOTE: Only in the case of more data items than dimensions (samples).
      Returns:
      success or not
    • VisDMatrixSymmetricEigen

      public boolean VisDMatrixSymmetricEigen(CVisDMatrix A, CVisDVector vals, CVisDMatrix vects)
      Perform symmetric eigen analysis.
      Parameters:
      A -
      vals -
      vects -
      Returns:
    • Dsyev

      public int Dsyev(int m, double[][] a, double[] vals, double[][] vects)
      Call the lapack routine
      Parameters:
      m -
      a -
      vals -
      vects -
      Returns:
    • MeanDataItem

      public final CDVector MeanDataItem()
      Returns the mean of all sample vectors.
      Returns:
      A mean vector.
    • ToFile

      public void ToFile(DataOutputStream fh)
      Writes a PCA object to a binary file.
      Parameters:
      fh - file handler to output stream
    • FromFile

      public void FromFile(DataInputStream fh)
      Reads a PCA object from a binary file.
      Parameters:
      fh - file handler to open binary file for reading
    • Dump

      public void Dump(String szPath)
      Debug method that provides a human readable file dump of the object data. Writes eigen vectors and eigen values to matlab text files: pca_eigenvectors.m pca_eigenvalues.m pca_eigenvalues_org.m
      Parameters:
      szPath - Path including terminating backslash where the data is dumped.
    • Deform

      public void Deform(CDVector params, CDVector object)
      Projects a set of PC scores to the original space.
      Specified by:
      Deform in class CAAMDeform
      Parameters:
      params - PC scores, i.e. the model paramerisation.
      object - Resulting projection into the original space, e.g. a shape.
    • MahalanobisDistance

      public double MahalanobisDistance(CDVector params)
      Returns the Mahalanobis distance of a set of PCA parameters.
      Parameters:
      params - A set of PCA parameters.
      Returns:
      The Mahalanobis distance.
    • ShuffleData

      public void ShuffleData()
      Shuffle each dimension in all data items over all observations.
    • TruncateParallel

      public int TruncateParallel()
      Truncate eigenvectors and eigenvalues using parallel analysis. Also known as Horn's parallel analysis or Humphrey-Ilgen parallel analysis. Assumes the data items have not been cleared.
      Specified by:
      TruncateParallel in class CAAMDeform
      Returns:
      The number of parameters in the truncated basis.
    • TruncateVar

      public int TruncateVar(double retained_variance)
      Truncate eigenvectors and eigenvalues to retain 'retained_variance'. I.e. if retained_variance = .95 this function calculates how many eigenvectors we need to explain 95% of the total variation in the PCA training set.
      Specified by:
      TruncateVar in class CAAMDeform
      Parameters:
      retained_variance - Amount of variance to retain [0invalid input: '<'xinvalid input: '<'1].
      Returns:
      The number of parameters in the truncated basis.
    • Truncate

      public void Truncate(int n)
      Truncate eigenvectors and eigenvalues to retain the 'n' largest.
      Specified by:
      Truncate in class CAAMDeform
      Parameters:
      n - Amount of eigenvectors/values to retain.
    • CalcNParam

      public int CalcNParam(double retained_variance)
      Calulates the needed number of parameters to retain 'retained_variance'. I.e. if retained_variance = .95 then this function calculates how many eigenvectors we need to explain 95% of the total variation in the PCA training set. Assumes that no eigenvalue cutoff has been done prior to the call.
      Parameters:
      retained_variance - Amount of variance to retain [0invalid input: '<'xinvalid input: '<'1].
      Returns:
      The number of model parameters.
    • Project

      public void Project(CDVector obs, CDVector param)
      Projects an observation into the PCA space. Notice: Costly, due to the non-cached transpose of the eigenvectors.
      Parameters:
      obs - Input observation.
      param - Output model parameters of the (possibly truncated) basis.
    • BackProject

      public void BackProject(CDVector param, CDVector synth_obs)
      Back projects a set of PCA model parameters into the original space.
      Parameters:
      param - Input PCA model parameters.
      synth_obs - Synthesized output observation.
    • Filter

      public void Filter(CDVector obs)
      Projects an observation into the PCA space and back. Notice: Costly, due to the non-cached transpose of the eigenvectors in the project call.
      Parameters:
      obs - Input observation.