Class CAAMDeformPCA
java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.AAM.CAAMObject
gov.nih.mipav.view.renderer.WildMagic.AAM.CAAMDeform
gov.nih.mipav.view.renderer.WildMagic.AAM.CAAMDeformPCA
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 Summary
FieldsModifier and TypeFieldDescriptionprivate CDMatrixprivate CDVectorprivate CDVectorprivate CDVectorFields inherited from class gov.nih.mipav.view.renderer.WildMagic.AAM.CAAMDeform
m_bValid -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidBackProject(CDVector param, CDVector synth_obs) Back projects a set of PCA model parameters into the original space.intCalcNParam(double retained_variance) Calulates the needed number of parameters to retain 'retained_variance'.voidDeletes the data matrix.voidProjects a set of PC scores to the original space.booleanDoPCA()Apply PCA analysisbooleanDoPCA(boolean bWriteCoVarMatrix) Performs the principal component analysis on the data items.intDsyev(int m, double[][] a, double[] vals, double[][] vects) Call the lapack routinevoidDebug method that provides a human readable file dump of the object data.Returns the eigen values in vector form.final CDVectorReturns the orignal eigen values in vector form.Returns the eigen vectors in matrix form.voidProjects an observation into the PCA space and back.voidReads a PCA object from a binary file.voidInserts a data vectordoubleMahalanobisDistance(CDVector params) Returns the Mahalanobis distance of a set of PCA parameters.final CDVectorReturns the mean of all sample vectors.final intReturns the number of data items this basis is based on.intReturns the number of principal parameters.intReturns the number of princal parameters before any truncation.doubleParameterWeight(int i, boolean asPercentage) Returns the eigenvalue of the i-th parameter in absolute numbers or as percentage.doubleParameterWeightOrg(int i, boolean asPercentage) Returns the eigenvalue of the i-th parameter in absolute numbers or as percentage.voidProjects an observation into the PCA space.voidShuffle each dimension in all data items over all observations.voidWrites a PCA object to a binary file.voidTruncate(int n) Truncate eigenvectors and eigenvalues to retain the 'n' largest.intTruncate eigenvectors and eigenvalues using parallel analysis.intTruncateVar(double retained_variance) Truncate eigenvectors and eigenvalues to retain 'retained_variance'.voidMakes the object use an identity basis instead of PCA basis, i.e.booleanVisDMatrixSymmetricEigen(CVisDMatrix A, CVisDVector vals, CVisDMatrix vects) Perform symmetric eigen analysis.Methods inherited from class gov.nih.mipav.view.renderer.WildMagic.AAM.CAAMDeform
IsTruncated, IsValidMethods inherited from class gov.nih.mipav.view.renderer.WildMagic.AAM.CAAMObject
FromFile, ToFile
-
Field Details
-
m_mEigenVectors
-
m_vEigenValues
-
m_vEigenValuesOrg
-
m_vvData
-
m_vDataMean
-
-
Constructor Details
-
CAAMDeformPCA
public CAAMDeformPCA()
-
-
Method Details
-
EigenValues
Returns the eigen values in vector form.- Returns:
- eigen values
-
EigenValuesOrg
Returns the orignal eigen values in vector form.- Returns:
- eigen values original
-
EigenVectors
Returns the eigen vectors in matrix form.- Returns:
- eigen vectors
-
NParameters
public int NParameters()Returns the number of principal parameters.- Specified by:
NParametersin classCAAMDeform- Returns:
- length of eigen values
-
NParametersOrg
public int NParametersOrg()Returns the number of princal parameters before any truncation.- Specified by:
NParametersOrgin classCAAMDeform- Returns:
- eigen values original length
-
ClearDataItems
public void ClearDataItems()Deletes the data matrix.- Specified by:
ClearDataItemsin classCAAMDeform
-
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:
ParameterWeightin classCAAMDeform- Parameters:
i- indexasPercentage- 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:
ParameterWeightOrgin classCAAMDeform- Parameters:
i- indexasPercentage- boolean flag to indicate % return or abs number- Returns:
- ret the eigenvalue.
-
InsertDataItem
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
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
Returns the mean of all sample vectors.- Returns:
- A mean vector.
-
ToFile
Writes a PCA object to a binary file.- Parameters:
fh- file handler to output stream
-
FromFile
Reads a PCA object from a binary file.- Parameters:
fh- file handler to open binary file for reading
-
Dump
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
Projects a set of PC scores to the original space.- Specified by:
Deformin classCAAMDeform- Parameters:
params- PC scores, i.e. the model paramerisation.object- Resulting projection into the original space, e.g. a shape.
-
MahalanobisDistance
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:
TruncateParallelin classCAAMDeform- 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:
TruncateVarin classCAAMDeform- 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:
Truncatein classCAAMDeform- 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
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
Back projects a set of PCA model parameters into the original space.- Parameters:
param- Input PCA model parameters.synth_obs- Synthesized output observation.
-
Filter
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.
-