v2.0.0
Loading...
Searching...
No Matches
mne_cov_matrix.h
Go to the documentation of this file.
1//=============================================================================================================
36
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// STL INCLUDES
54//=============================================================================================================
55
56#include <memory>
57
58//=============================================================================================================
59// QT INCLUDES
60//=============================================================================================================
61
62#include <QSharedPointer>
63#include <QStringList>
64
68#define MNE_COV_CH_UNKNOWN -1
69#define MNE_COV_CH_MEG_MAG 0
70#define MNE_COV_CH_MEG_GRAD 1
71#define MNE_COV_CH_EEG 2
72
73//=============================================================================================================
74// FORWARD DECLARATIONS
75//=============================================================================================================
76
77namespace FIFFLIB
78{
79 class FiffSparseMatrix;
80}
81
82//=============================================================================================================
83// DEFINE NAMESPACE MNELIB
84//=============================================================================================================
85
86namespace MNELIB
87{
88
89//=============================================================================================================
90// MNELIB FORWARD DECLARATIONS
91//=============================================================================================================
92
93class MNEProjOp;
94class MNESssData;
95
96//=============================================================================================================
105{
106public:
107 typedef QSharedPointer<MNECovMatrix> SPtr;
108 typedef QSharedPointer<const MNECovMatrix> ConstSPtr;
109
110 //=========================================================================================================
121 MNECovMatrix(int p_kind, int p_ncov, const QStringList& p_names, const Eigen::VectorXd& p_cov, const Eigen::VectorXd& p_cov_diag, FIFFLIB::FiffSparseMatrix* p_cov_sparse);
122
123 //=========================================================================================================
128
129 //=========================================================================================================
136 std::unique_ptr<MNECovMatrix> dup() const;
137
138 //=========================================================================================================
149 static std::unique_ptr<MNECovMatrix> create_dense(int kind,
150 int ncov,
151 const QStringList& names,
152 const Eigen::VectorXd& cov)
153 {
154 return std::unique_ptr<MNECovMatrix>(new MNECovMatrix(kind,ncov,names,cov,Eigen::VectorXd(),nullptr));
155 }
156
157 //=========================================================================================================
168 static std::unique_ptr<MNECovMatrix> create_diag(int kind,
169 int ncov,
170 const QStringList& names,
171 const Eigen::VectorXd& cov_diag)
172 {
173 return std::unique_ptr<MNECovMatrix>(new MNECovMatrix(kind,ncov,names,Eigen::VectorXd(),cov_diag,nullptr));
174 }
175
176 //=========================================================================================================
187 static std::unique_ptr<MNECovMatrix> create_sparse( int kind,
188 int ncov,
189 const QStringList& names,
191 {
192 return std::unique_ptr<MNECovMatrix>(new MNECovMatrix(kind,ncov,names,Eigen::VectorXd(),Eigen::VectorXd(),cov_sparse));
193 }
194
195 //=========================================================================================================
207 static std::unique_ptr<MNECovMatrix> create( int kind,
208 int ncov,
209 const QStringList& names,
210 const Eigen::VectorXd& cov,
211 const Eigen::VectorXd& cov_diag)
212 {
213 return std::unique_ptr<MNECovMatrix>(new MNECovMatrix(kind,ncov,names,cov,cov_diag,nullptr));
214 }
215
216 //=========================================================================================================
222 int is_diag() const;
223
224 //=========================================================================================================
231 int add_inv();
232
233 //=========================================================================================================
243 int condition(float rank_threshold, int use_rank);
244
245 //=========================================================================================================
256 int decompose_eigen_small(float p_small, int use_rank);
257
258 //=========================================================================================================
265 int decompose_eigen();
266
267private:
268
269 //=========================================================================================================
279 static int lt_packed_index(int j, int k);
280
281public:
282 int kind;
283 int ncov;
284 int nfree;
285 int nproj;
286 int nzero;
287 QStringList names;
288 Eigen::VectorXd cov;
289 Eigen::VectorXd cov_diag;
290 std::unique_ptr<FIFFLIB::FiffSparseMatrix> cov_sparse;
291 Eigen::VectorXd lambda;
292 Eigen::VectorXd inv_lambda;
293 Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> eigen;
294 std::unique_ptr<MNEProjOp> proj;
295 std::unique_ptr<MNESssData> sss;
296 Eigen::VectorXi ch_class;
297 QStringList bads;
298 int nbad;
299};
300
301//=============================================================================================================
302// INLINE DEFINITIONS
303//=============================================================================================================
304} // NAMESPACE MNELIB
305
306#endif // MNECOVMATRIX_H
mne library export/import macros.
#define MNESHARED_EXPORT
Definition mne_global.h:52
Core MNE data structures (source spaces, source estimates, hemispheres).
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
FIFF sparse matrix storage.
Eigen::VectorXd inv_lambda
std::unique_ptr< FIFFLIB::FiffSparseMatrix > cov_sparse
Eigen::VectorXd lambda
static std::unique_ptr< MNECovMatrix > create_sparse(int kind, int ncov, const QStringList &names, FIFFLIB::FiffSparseMatrix *cov_sparse)
std::unique_ptr< MNEProjOp > proj
static std::unique_ptr< MNECovMatrix > create_diag(int kind, int ncov, const QStringList &names, const Eigen::VectorXd &cov_diag)
static std::unique_ptr< MNECovMatrix > create_dense(int kind, int ncov, const QStringList &names, const Eigen::VectorXd &cov)
QSharedPointer< const MNECovMatrix > ConstSPtr
std::unique_ptr< MNECovMatrix > dup() const
MNECovMatrix(int p_kind, int p_ncov, const QStringList &p_names, const Eigen::VectorXd &p_cov, const Eigen::VectorXd &p_cov_diag, FIFFLIB::FiffSparseMatrix *p_cov_sparse)
std::unique_ptr< MNESssData > sss
Eigen::VectorXd cov
Eigen::VectorXd cov_diag
static std::unique_ptr< MNECovMatrix > create(int kind, int ncov, const QStringList &names, const Eigen::VectorXd &cov, const Eigen::VectorXd &cov_diag)
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > eigen
Eigen::VectorXi ch_class
QSharedPointer< MNECovMatrix > SPtr
Projection operator managing a set of linear projection items and the final compiled projector matrix...
Definition mne_proj_op.h:83
Container for Signal Space Separation (SSS/Maxwell filtering) expansion coefficients and metadata.