aimsalgo 6.0.0
Neuroimaging image processing
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>
40#include <cartodata/volume/volume.h>
41
42namespace aims
43{
44
46 {
47 public:
48 DiscriminantAnalysisElement( int significantEV = -1, double PIj = 1. ) ;
50
51 template <class T>
52 void doIt( const carto::rc_ptr<carto::Volume<T> > & individuals ) ;
53
54 template <class T>
55 void doIt( const std::list< Point3d>& selectedPoints,
56 const carto::rc_ptr<carto::Volume<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
67 double pX ) const ;
68
69 /* for comparison purposes only, because x prior probability is not taken
70 into account */
71 double lnPosteriorProbability( const carto::rc_ptr<carto::Volume<double> >& individual ) const ;
72 double distance( const carto::rc_ptr<carto::Volume<double> >& x ) const ;
73
74 const carto::VolumeRef<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 };
96
97
98 template <class T>
100 {
101 public:
103 const std::vector< std::list <Point3d> >& classes,
104 int significantEV = -1,
105 const std::vector<double>& PIj
106 = std::vector<double>() ) ;
108
109 std::vector<double> posteriorProbabilities( const carto::rc_ptr<carto::Volume<double> >& x,
110 double px ) ;
111 std::vector<double> andersonScores(
113
115
116 bool classification( const carto::rc_ptr<carto::Volume<T> >& dynamicImage,
118 carto::rc_ptr<carto::Volume<short> >& segmented ) ;
119 bool fuzzyClassification( const carto::rc_ptr<carto::Volume<T> >& dynamicImage,
121 carto::rc_ptr<carto::Volume<float> >& fuzzySegmented,
122 const carto::rc_ptr<carto::Volume<double> > &indivPriorProbabilities =
124
125 private:
126 int _significantEV ;
127 const std::vector< std::list< Point3d > >& _classes ;
128 const carto::VolumeRef<T> _data ;
129 std::vector<double> _PIj ;
130
131 std::vector<DiscriminantAnalysisElement> _discrElements ;
132 } ;
133}
134
135#endif
const carto::VolumeRef< double > & mean() const
double posteriorProbability(const carto::rc_ptr< carto::Volume< double > > &individual, double pX) const
double lnPosteriorProbability(const carto::rc_ptr< carto::Volume< double > > &individual) const
void doIt(const carto::rc_ptr< carto::Volume< T > > &individuals)
DiscriminantAnalysisElement(int significantEV=-1, double PIj=1.)
double distance(const carto::rc_ptr< carto::Volume< double > > &x) const
carto::VolumeRef< double > _invVarCov
bool classification(const carto::rc_ptr< carto::Volume< T > > &dynamicImage, const carto::rc_ptr< carto::Volume< byte > > &mask, carto::rc_ptr< carto::Volume< short > > &segmented)
DiscriminantAnalysis(const carto::rc_ptr< carto::Volume< T > > &data, const std::vector< std::list< Point3d > > &classes, int significantEV=-1, const std::vector< double > &PIj=std::vector< double >())
int affectedTo(const carto::rc_ptr< carto::Volume< double > > &x)
std::vector< double > andersonScores(const carto::rc_ptr< carto::Volume< double > > &x)
std::vector< double > posteriorProbabilities(const carto::rc_ptr< carto::Volume< double > > &x, double px)
bool fuzzyClassification(const carto::rc_ptr< carto::Volume< T > > &dynamicImage, const carto::rc_ptr< carto::Volume< byte > > &mask, carto::rc_ptr< carto::Volume< float > > &fuzzySegmented, const carto::rc_ptr< carto::Volume< double > > &indivPriorProbabilities=carto::rc_ptr< carto::Volume< double > >())
BucketMap< Void > * mask(const BucketMap< Void > &src, const BucketMap< Void > &m, bool intersect=true)