aimsalgo  5.1.2
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 
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 carto::rc_ptr<carto::Volume<T> >& individuals,
60  double noiseRef = 1. ) ;
61  template <class T>
62  bool newStep1( const carto::rc_ptr<carto::Volume<T> >& indivMatrix,
63  bool useOnlyCorrIndiv ) ;
64  template <class T>
66  const carto::rc_ptr<carto::Volume<T> >& indivMatrix,
67  double noiseRef = 1. ) ;
68 
69  const std::vector<double>& mean() const ;
70 
71  double getPi() { return _Pi ; }
72  double getSigma2() const { return _sigma2 ; }
73  double getEnergy() const { return _energy ; }
74  double getSumDiff2Rni() const { return _sumDiff2Rni ; }
75  const carto::VolumeRef<double>& getRn() { return _Rn ; }
76  const carto::VolumeRef<double>& getDist() { return _dist ; }
77  const carto::VolumeRef<double>& getPtni() { return _pTni ; }
78  const carto::VolumeRef<double>& getMean() { return _mean ; }
79  const carto::VolumeRef<double>& getInvCi() { return _invCi ; }
80  int getExplosionIndex() { return _explosionIndex ; }
81  bool isValid( ) const { return _valid ; }
82 
83  private:
84  // tabulation exponentielle
85  static double * _exp ;
86 
87  template <class T>
88  void doIt( const carto::rc_ptr<carto::Volume<T> >& individuals,
89  int totalNbOfIndividuals, double noiseRef = 1. ) ;
90 
91  bool _useOnlyCorrIndiv ; // mis � true par doIt
92  int _significantNumberOfVp ; // nb de valeurs propres significatives
93  bool _computed ; // mis � true par doIt
94  double _Pi ;
98  carto::VolumeRef<double> _mean ; // meme dim que tn
99  carto::VolumeRef<double> _Wi ; // dim dxq
100  carto::VolumeRef<double> _invMi ; // dim qxq
101  carto::VolumeRef<double> _invCi ; // idem
102  double _sigma2 ;
103  double _normFactor ;
104  int _explosionIndex ;
105  double _sumDiff2Rni ; // somme des (Rni - previousRni) au carr� pour un i donn�
106 
107  double _energy ;
108  bool _valid ;
109 } ;
110 
111 
112 
113 template <class T>
115 {
116  public:
117  MixtureOfPPCA( int nbOfClasses, int significantNumberOfVp, int maxNbOfIterations,
118  const carto::rc_ptr<carto::Volume<T> >& individuals, const std::vector< Point3d > indPosVector,
119  const std::vector< std::list <int> >& initialClasses,
120  const std::string & fileOut, int runNb, int iterationToUseOnlyCorrelatedIndiv = false ) ;
122 
123  bool doIt() ;
124 // const std::vector< std::vector< std::list< int > > >& doIt() ;
125 
126  double pTnComputation() ;
127  bool distMatrixComputation() ;
129  double distComputation() ;
130  bool classesVisualisation( int nbOfIterations, const std::string & fileOut, bool theEnd ) ;
131 
132  private:
133  int _nbOfClasses ;
134  bool _valid ;
135  int _significantNumberOfEigenValues ;
136  int _maxNbOfIterations ;
137  const carto::VolumeRef<T> _individuals ;
138  const std::vector<Point3d> _indPosVector ;
139  const std::string _fileOut ;
140  int _runNb ;
141  double _noiseRef ;
142  std::vector< PpcaAnalyserElement > _elements ;
144  std::vector<double> _sigma2init ;
145  std::vector< std::list< int > > _finalClasses ;
146  carto::VolumeRef<double> _distToClasses ;
147  carto::VolumeRef<double> _sigma2Matrix ;
148  std::list< int > _nullPtnIndiv ;
149  double _logLikelihood ;
150  int _nbOfRejected ;
151 
152  int _itToUseOnlyCorrelatedIndiv ;
153 } ;
154 
155 }
156 
157 #endif
carto::VolumeRef< double > getRni()
bool classesVisualisation(int nbOfIterations, const std::string &fileOut, bool theEnd)
MixtureOfPPCA(int nbOfClasses, int significantNumberOfVp, int maxNbOfIterations, const carto::rc_ptr< carto::Volume< T > > &individuals, const std::vector< Point3d > indPosVector, const std::vector< std::list< int > > &initialClasses, const std::string &fileOut, int runNb, int iterationToUseOnlyCorrelatedIndiv=false)
const carto::VolumeRef< double > & getMean()
Definition: mixtureOfPpca.h:78
const carto::VolumeRef< double > & getDist()
Definition: mixtureOfPpca.h:76
double getSigma2() const
Definition: mixtureOfPpca.h:72
const carto::VolumeRef< double > & getRn()
Definition: mixtureOfPpca.h:75
const carto::VolumeRef< double > & getInvCi()
Definition: mixtureOfPpca.h:79
void init(const std::list< int > &selectedIndividuals, double initialPi, const carto::rc_ptr< carto::Volume< T > > &individuals, double noiseRef=1.)
double getSumDiff2Rni() const
Definition: mixtureOfPpca.h:74
bool newStep1(const carto::rc_ptr< carto::Volume< T > > &indivMatrix, bool useOnlyCorrIndiv)
const carto::VolumeRef< double > & getPtni()
Definition: mixtureOfPpca.h:77
double getEnergy() const
Definition: mixtureOfPpca.h:73
double newStep2(carto::rc_ptr< carto::Volume< double > > pTn, const carto::rc_ptr< carto::Volume< T > > &indivMatrix, double noiseRef=1.)
PpcaAnalyserElement(int significantNumberOfVp, bool useOnlyCorrIndiv=false)
const std::vector< double > & mean() const