A.I.M.S algorithms


discriminantanalysis.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_DISCRIMINANTANALYSIS_H
36 #define AIMS_MATH_DISCRIMINANTANALYSIS_H
37 
38 #include <aims/def/general.h>
39 #include <vector>
41 
42 namespace aims
43 {
44 
46  {
47  public:
48  DiscriminantAnalysisElement( int significantEV = -1, double PIj = 1. ) ;
50 
51  template <class T>
52  void doIt( const AimsData<T>& individuals ) ;
53 
54  template <class T>
55  void doIt( const std::list< Point3d>& selectedPoints,
56  const AimsData<T>& data ) ;
57 
58  // set a priori class probability
59  void setPIj( double PIj )
60  {
61  _PIj = PIj ;
62  if( _computed )
63  _lnAddFactor = -log( _detVarCov / ( _PIj * _PIj ) ) ;
64  }
65 
66  double posteriorProbability( const AimsData<double>& individual,
67  double pX ) const ;
68 
69  /* for comparison purposes only, because x prior probability is not taken
70  into account */
71  double lnPosteriorProbability( const AimsData<double>& individual ) const ;
72  double distance( const AimsData<double>& x ) const ;
73 
74  const AimsData<double>& mean() const ;
75  bool computed() const {return _computed ; }
76 
77  protected:
79  bool _computed ;
82  double _PIj ;
83 
85 
87 
88  double _detVarCov ;
89  double _normFactor ;
90  double _lnAddFactor ;
91 
92  // Temporary
93  std::vector<Point3d> _indivPosition ;
94 
95  /* vector<float> _projectionVector ; */
96  /* AimsData<float> _projectionMatrix ; */
97  /* AimsData<float> _errorMatrix ; */
98  /* vector<float> _eigenValues ; */
99  /* AimsData<float> _eigenVectors ; */
100  /* AimsData<float> _selectedEigenVectors ; */
101  /* AimsData<float> _selectedEigenVectorsTr ; */
102 
103  /* int _significantNumberOfVp ; */
104  /* float _minimalInertia ; */
105  };
106 
107 
108  template <class T>
110  {
111  public:
112  DiscriminantAnalysis( const AimsData<T>& data,
113  const std::vector< std::list <Point3d> >& classes,
114  int significantEV = -1,
115  const std::vector<double>& PIj
116  = std::vector<double>() ) ;
118 
119  std::vector<double> posteriorProbabilities( const AimsData<double>& x,
120  double px ) ;
121  std::vector<double> andersonScores( const AimsData<double>& x ) ;
122 
123  int affectedTo( const AimsData<double>& x ) ;
124 
125  bool classification( const AimsData<T>& dynamicImage,
126  const AimsData<byte>& mask,
127  AimsData<short>& segmented ) ;
128  bool fuzzyClassification( const AimsData<T>& dynamicImage,
129  const AimsData<byte>& mask,
130  AimsData<float>& fuzzySegmented,
131  const AimsData<double> &indivPriorProbabilities =
132  AimsData<double>() ) ;
133 
134  private:
135  int _significantEV ;
136  const std::vector< std::list< Point3d > >& _classes ;
137  const AimsData<T>& _data ;
138  std::vector<double> _PIj ;
139 
140  std::vector<DiscriminantAnalysisElement> _discrElements ;
141  } ;
142 }
143 
144 #endif
const AimsData< double > & mean() const
BucketMap< Void > * mask(const BucketMap< Void > &src, const BucketMap< Void > &m, bool intersect=true)
std::vector< double > andersonScores(const AimsData< double > &x)
void doIt(const AimsData< T > &individuals)
double posteriorProbability(const AimsData< double > &individual, double pX) const
bool fuzzyClassification(const AimsData< T > &dynamicImage, const AimsData< byte > &mask, AimsData< float > &fuzzySegmented, const AimsData< double > &indivPriorProbabilities=AimsData< double >())
std::vector< double > posteriorProbabilities(const AimsData< double > &x, double px)
int affectedTo(const AimsData< double > &x)
double lnPosteriorProbability(const AimsData< double > &individual) const
DiscriminantAnalysisElement(int significantEV=-1, double PIj=1.)
DiscriminantAnalysis(const AimsData< T > &data, const std::vector< std::list< Point3d > > &classes, int significantEV=-1, const std::vector< double > &PIj=std::vector< double >())
bool classification(const AimsData< T > &dynamicImage, const AimsData< byte > &mask, AimsData< short > &segmented)
AimsFastAllocationData< double > _invVarCov
double distance(const AimsData< double > &x) const
AimsFastAllocationData< double > _mean