aimsalgo  5.0.5
Neuroimaging image processing
pca.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 
35 #ifndef AIMS_MATH_PCA_H
36 #define AIMS_MATH_PCA_H
37 
38 #include <aims/def/general.h>
40 #include <vector>
41 
42 
43 class AimsPCA
44 {
45 public:
46  AimsPCA( int significantNumberOfVp, bool normalize = false, bool center = true ) ;
47  ~AimsPCA() {}
48 
49  template <class T>
50  void doIt( const AimsData<T>& individuals ) ;
51 
52  template <class T>
53  void doIt( const std::list< Point3d>& selectedPoints, const AimsData<T>& data ) ;
54 
55 
56  float noiseVariance( float& meanNorm ) ;
57  double totalVariance( float& meanNorm ) const ;
58 
59  float relativeUnreconstructedVariance( float& meanNorm ) ;
60  void setSignificantNumberOfVp( int significantNumberOfVp ) ;
61  void setMinimalInertia( float inertiaLimit ) ;
62 
63  float minimalInertia() const ;
64  float significantNumberOfVp() const ;
65 
66  float significantInertia() ;
67  float noiseInertia() ;
68  float unreconstructedVariance( ) ;
70  AimsData<float> projection( const AimsData<float>& individual ) ;
71  float reconstructionError2( const AimsData<float>& individual ) ;
72 
75 
76  const std::vector<float>& eigenValues() const ;
77  const AimsData<float>& eigenVectors() const ;
79 
80  const std::vector<float>& mean() const ;
81  const std::vector<float>& var() const ;
82 
83  bool valid() const { return _validPca ; }
84 
85 protected:
87  bool _validPca ;
88  bool _computed ;
90  bool _center ;
91  bool _normalize ;
92  std::vector<float> _mean ;
93  std::vector<float> _var ;
94 
95  std::vector<float> _projectionVector ;
98  std::vector<float> _eigenValues ;
102 
105 };
106 
107 #endif
float relativeUnreconstructedVariance()
const AimsData< float > & reconstructionErrorMatrix()
const AimsData< float > & eigenVectors() const
~AimsPCA()
Definition: pca.h:47
bool _validPca
Definition: pca.h:87
aims::AimsFastAllocationData< float > _errorMatrix
Definition: pca.h:97
float noiseInertia()
float minimalInertia() const
bool _normalize
Definition: pca.h:91
const std::vector< float > & eigenValues() const
aims::AimsFastAllocationData< float > _eigenVectors
Definition: pca.h:99
std::vector< float > _projectionVector
Definition: pca.h:95
std::vector< float > _eigenValues
Definition: pca.h:98
float significantInertia()
float significantNumberOfVp() const
bool _matricesComputed
Definition: pca.h:89
void computeErrorAndProjMatrices()
aims::AimsFastAllocationData< float > _selectedEigenVectorsTr
Definition: pca.h:101
const std::vector< float > & var() const
AimsPCA(int significantNumberOfVp, bool normalize=false, bool center=true)
float _minimalInertia
Definition: pca.h:104
int _significantNumberOfVp
Definition: pca.h:103
std::vector< float > _var
Definition: pca.h:93
float unreconstructedVariance()
bool valid() const
Definition: pca.h:83
AimsData< float > selectedEigenVectors() const
aims::AimsFastAllocationData< float > _selectedEigenVectors
Definition: pca.h:100
float noiseVariance(float &meanNorm)
aims::AimsFastAllocationData< float > _projectionMatrix
Definition: pca.h:96
bool _computed
Definition: pca.h:88
const std::vector< float > & mean() const
const AimsData< float > & projectionMatrix()
double totalVariance(float &meanNorm) const
AimsData< float > projection(const AimsData< float > &individual)
bool _center
Definition: pca.h:90
void doIt(const AimsData< T > &individuals)
Definition: pca_d.h:59
void setMinimalInertia(float inertiaLimit)
void setSignificantNumberOfVp(int significantNumberOfVp)
Definition: pca.h:43
float reconstructionError2(const AimsData< float > &individual)
std::vector< float > _mean
Definition: pca.h:92