MNE-CPP  0.1.9
A Framework for Electrophysiology
mne_cov_matrix.h
Go to the documentation of this file.
1 //=============================================================================================================
37 #ifndef MNECOVMATRIX_H
38 #define MNECOVMATRIX_H
39 
40 //=============================================================================================================
41 // INCLUDES
42 //=============================================================================================================
43 
44 #include "../mne_global.h"
45 
46 //=============================================================================================================
47 // EIGEN INCLUDES
48 //=============================================================================================================
49 
50 #include <Eigen/Core>
51 
52 //=============================================================================================================
53 // QT INCLUDES
54 //=============================================================================================================
55 
56 #include <QSharedPointer>
57 #include <QStringList>
58 
59 /*
60  * The class field in mneCovMatrix can have these values
61  */
62 #define MNE_COV_CH_UNKNOWN -1 /* No idea */
63 #define MNE_COV_CH_MEG_MAG 0 /* Axial gradiometer or magnetometer [T] */
64 #define MNE_COV_CH_MEG_GRAD 1 /* Planar gradiometer [T/m] */
65 #define MNE_COV_CH_EEG 2 /* EEG [V] */
66 
67 //=============================================================================================================
68 // FORWARD DECLARATIONS
69 //=============================================================================================================
70 
71 namespace FIFFLIB
72 {
73  class FiffSparseMatrix;
74 }
75 
76 //=============================================================================================================
77 // DEFINE NAMESPACE MNELIB
78 //=============================================================================================================
79 
80 namespace MNELIB
81 {
82 
83 //=============================================================================================================
84 // MNELIB FORWARD DECLARATIONS
85 //=============================================================================================================
86 
87 class MneProjOp;
88 class MneSssData;
89 
90 //=============================================================================================================
97 {
98 public:
99  typedef QSharedPointer<MneCovMatrix> SPtr;
100  typedef QSharedPointer<const MneCovMatrix> ConstSPtr;
102  //=========================================================================================================
107  MneCovMatrix(int p_kind, int p_ncov, const QStringList& p_names, double *p_cov, double *p_cov_diag, FIFFLIB::FiffSparseMatrix* p_cov_sparse);
108 
109  //=========================================================================================================
114  ~MneCovMatrix();
115 
116  static MneCovMatrix* mne_dup_cov(MneCovMatrix* c);
117 
118  static MneCovMatrix* mne_new_cov_dense(int kind,
119  int ncov,
120  const QStringList& names,
121  double *cov)
122  {
123  return new MneCovMatrix(kind,ncov,names,cov,NULL,NULL);
124  }
125 
126  static MneCovMatrix* mne_new_cov_diag(int kind,
127  int ncov,
128  const QStringList& names,
129  double *cov_diag)
130  {
131  return new MneCovMatrix(kind,ncov,names,NULL,cov_diag,NULL);
132  }
133 
134  static MneCovMatrix* mne_new_cov_sparse( int kind,
135  int ncov,
136  const QStringList& names,
137  FIFFLIB::FiffSparseMatrix* cov_sparse)
138  {
139  return new MneCovMatrix(kind,ncov,names,NULL,NULL,cov_sparse);
140  }
141 
142  static MneCovMatrix* mne_new_cov( int kind,
143  int ncov,
144  const QStringList& names,
145  double *cov,
146  double *cov_diag)
147  {
148  return new MneCovMatrix(kind,ncov,names,cov,cov_diag,NULL);
149  }
150 
151  static int mne_is_diag_cov(MneCovMatrix* c);
152 
153  static int mne_add_inv_cov(MneCovMatrix* c);
154 
155  static int condition_cov(MneCovMatrix* c, float rank_threshold, int use_rank);
156 
157  static int mne_decompose_eigen_cov_small(MneCovMatrix* c,float p_small, int use_rank);
158 
159  static int mne_decompose_eigen_cov(MneCovMatrix* c);
160 
161 private:
162 
163  static int mne_lt_packed_index(int j, int k);
164 
165 public:
166  int kind; /* Sensor or source covariance */
167  int ncov; /* Dimension */
168  int nfree; /* Number of degrees of freedom */
169  int nproj; /* Number of dimensions projected out */
170  int nzero; /* Number of zero or small eigenvalues */
171  QStringList names; /* Names of the entries (optional) */
172  double *cov; /* Covariance matrix in packed representation (lower triangle) */
173  double *cov_diag; /* Diagonal covariance matrix */
174  FIFFLIB::FiffSparseMatrix* cov_sparse; /* A sparse covariance matrix (Note: data are floats in this which is an inconsistency) */
175  double *lambda; /* Eigenvalues of cov */
176  double *inv_lambda; /* Inverses of the square roots of the eigenvalues of cov */
177  float **eigen; /* Eigenvectors of cov */
178  double *chol; /* Cholesky decomposition */
179  MneProjOp* proj; /* The projection which was active when this matrix was computed */
180  MneSssData* sss; /* The SSS data present in the associated raw data file */
181  int *ch_class; /* This will allow grouping of channels for regularization (MEG [T/m], MEG [T], EEG [V] */
182  QStringList bads; /* Which channels were designated bad when this noise covariance matrix was computed? */
183  int nbad; /* How many of them */
184 
185 // ### OLD STRUCT ###
186 //typedef struct { /* Covariance matrix storage */
187 // int kind; /* Sensor or source covariance */
188 // int ncov; /* Dimension */
189 // int nfree; /* Number of degrees of freedom */
190 // int nproj; /* Number of dimensions projected out */
191 // int nzero; /* Number of zero or small eigenvalues */
192 // char **names; /* Names of the entries (optional) */
193 // double *cov; /* Covariance matrix in packed representation (lower triangle) */
194 // double *cov_diag; /* Diagonal covariance matrix */
195 // MNELIB::FiffSparseMatrix* cov_sparse; /* A sparse covariance matrix (Note: data are floats in this which is an inconsistency) */
196 // double *lambda; /* Eigenvalues of cov */
197 // double *inv_lambda; /* Inverses of the square roots of the eigenvalues of cov */
198 // float **eigen; /* Eigenvectors of cov */
199 // double *chol; /* Cholesky decomposition */
200 // MNELIB::MneProjOp* proj; /* The projection which was active when this matrix was computed */
201 // MNELIB::MneSssData* sss; /* The SSS data present in the associated raw data file */
202 // int *ch_class; /* This will allow grouping of channels for regularization (MEG [T/m], MEG [T], EEG [V] */
203 // char **bads; /* Which channels were designated bad when this noise covariance matrix was computed? */
204 // int nbad; /* How many of them */
205 //} *mneCovMatrix,mneCovMatrixRec;
206 };
207 
208 //=============================================================================================================
209 // INLINE DEFINITIONS
210 //=============================================================================================================
211 } // NAMESPACE MNELIB
212 
213 #endif // MNECOVMATRIX_H
MNELIB::MneCovMatrix::ConstSPtr
QSharedPointer< const MneCovMatrix > ConstSPtr
Definition: mne_cov_matrix.h:100
FIFFLIB::FiffSparseMatrix
Data associated with MNE computations for each mneMeasDataSet.
Definition: fiff_sparse_matrix.h:74
MNESHARED_EXPORT
#define MNESHARED_EXPORT
Definition: mne_global.h:56
MNELIB::MneCovMatrix::SPtr
QSharedPointer< MneCovMatrix > SPtr
Definition: mne_cov_matrix.h:99
k
int k
Definition: fiff_tag.cpp:322
MNELIB::MneCovMatrix
Covariance matrix storage.
Definition: mne_cov_matrix.h:96