aimsalgo  5.0.5
Neuroimaging image processing
mixtureOfPpca.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 
36 #ifndef MIXTURE_OF_PPCA_H
37 #define MIXTURE_OF_PPCA_H
38 
39 #include <aims/data/data.h>
40 #include <vector>
41 #include <string.h>
42 
43 /* This code seems to be used... nowhere...
44  Anyway it is not currently working: namespace problems will prevent
45  compiling.
46 */
47 
48 namespace aims
49 {
50 
52 {
53  public:
54  PpcaAnalyserElement( int significantNumberOfVp, bool useOnlyCorrIndiv = false ) ;
56 
57  template <class T>
58  void init( const std::list<int>& selectedIndividuals, double initialPi,
59  const AimsData<T>& individuals, double noiseRef = 1. ) ;
60  template <class T>
61  bool newStep1( const AimsData<T>& indivMatrix, bool useOnlyCorrIndiv ) ;
62  template <class T>
63  double newStep2( AimsData<double> pTn, const AimsData<T>& indivMatrix, double noiseRef = 1. ) ;
64 
65  const std::vector<double>& mean() const ;
66 
67  double getPi() { return _Pi ; }
68  double getSigma2() const { return _sigma2 ; }
69  double getEnergy() const { return _energy ; }
70  double getSumDiff2Rni() const { return _sumDiff2Rni ; }
71  const AimsData<double>& getRn() { return _Rn ; }
72  const AimsData<double>& getDist() { return _dist ; }
73  const AimsData<double>& getPtni() { return _pTni ; }
74  const AimsData<double>& getMean() { return _mean ; }
75  const AimsData<double>& getInvCi() { return _invCi ; }
76  int getExplosionIndex() { return _explosionIndex ; }
77  bool isValid( ) const { return _valid ; }
78 
79  private:
80  // tabulation exponentielle
81  static double * _exp ;
82 
83  template <class T>
84  void doIt( const AimsData<T>& individuals, int totalNbOfIndividuals, double noiseRef = 1. ) ;
85 
86  bool _useOnlyCorrIndiv ; // mis � true par doIt
87  int _significantNumberOfVp ; // nb de valeurs propres significatives
88  bool _computed ; // mis � true par doIt
89  double _Pi ;
90  AimsData<double> _dist ;
91  AimsData<double> _pTni ;
92  AimsData<double> _Rn ;
93  AimsData<double> _mean ; // meme dim que tn
94  AimsData<double> _Wi ; // dim dxq
95  AimsData<double> _invMi ; // dim qxq
96  AimsData<double> _invCi ; // idem
97  double _sigma2 ;
98  double _normFactor ;
99  int _explosionIndex ;
100  double _sumDiff2Rni ; // somme des (Rni - previousRni) au carr� pour un i donn�
101 
102  double _energy ;
103  bool _valid ;
104 } ;
105 
106 
107 
108 template <class T>
110 {
111  public:
112  MixtureOfPPCA( int nbOfClasses, int significantNumberOfVp, int maxNbOfIterations,
113  const AimsData<T>& individuals, const std::vector< Point3d > indPosVector,
114  const std::vector< std::list <int> >& initialClasses,
115  const std::string & fileOut, int runNb, int iterationToUseOnlyCorrelatedIndiv = false ) ;
117 
118  bool doIt() ;
119 // const std::vector< std::vector< std::list< int > > >& doIt() ;
120 
121  double pTnComputation() ;
122  bool distMatrixComputation() ;
123  AimsData<double> getRni() ;
124  double distComputation() ;
125  bool classesVisualisation( int nbOfIterations, const std::string & fileOut, bool theEnd ) ;
126 
127  private:
128  int _nbOfClasses ;
129  bool _valid ;
130  int _significantNumberOfEigenValues ;
131  int _maxNbOfIterations ;
132  const AimsData<T>& _individuals ;
133  const std::vector<Point3d> _indPosVector ;
134  const std::string _fileOut ;
135  int _runNb ;
136  double _noiseRef ;
137  std::vector< PpcaAnalyserElement > _elements ;
138  AimsData<double> _pTn ;
139  std::vector<double> _sigma2init ;
140  std::vector< std::list< int > > _finalClasses ;
141  AimsData<double> _distToClasses ;
142  AimsData<double> _sigma2Matrix ;
143  std::list< int > _nullPtnIndiv ;
144  double _logLikelihood ;
145  int _nbOfRejected ;
146 
147  int _itToUseOnlyCorrelatedIndiv ;
148 } ;
149 
150 }
151 
152 #endif
const AimsData< double > & getMean()
Definition: mixtureOfPpca.h:74
double getSumDiff2Rni() const
Definition: mixtureOfPpca.h:70
double newStep2(AimsData< double > pTn, const AimsData< T > &indivMatrix, double noiseRef=1.)
void init(const std::list< int > &selectedIndividuals, double initialPi, const AimsData< T > &individuals, double noiseRef=1.)
bool newStep1(const AimsData< T > &indivMatrix, bool useOnlyCorrIndiv)
const AimsData< double > & getInvCi()
Definition: mixtureOfPpca.h:75
double getEnergy() const
Definition: mixtureOfPpca.h:69
const std::vector< double > & mean() const
PpcaAnalyserElement(int significantNumberOfVp, bool useOnlyCorrIndiv=false)
double getSigma2() const
Definition: mixtureOfPpca.h:68
const AimsData< double > & getRn()
Definition: mixtureOfPpca.h:71
const AimsData< double > & getPtni()
Definition: mixtureOfPpca.h:73
const AimsData< double > & getDist()
Definition: mixtureOfPpca.h:72