v2.0.0
Loading...
Searching...
No Matches
mne.h
Go to the documentation of this file.
1//=============================================================================================================
27
28#ifndef MNE_H
29#define MNE_H
30
31//=============================================================================================================
32// INCLUDES
33//=============================================================================================================
34
35#include "mne_global.h"
36
37#include "mne_hemisphere.h"
38#include "mne_source_spaces.h"
39#include "mne_bem.h"
40#include "mne_bem_surface.h"
41#include "mne_epoch_data_list.h"
42
43#include <fiff/fiff_constants.h>
44#include <fiff/fiff_cov.h>
45#include <fiff/fiff_proj.h>
46#include <fiff/fiff_events.h>
48#include <fiff/fiff_raw_data.h>
49
50#include <math/linalg.h>
51
52//=============================================================================================================
53// QT INCLUDES
54//=============================================================================================================
55
56#include <QMap>
57#include <QList>
58
59//=============================================================================================================
60// DEFINE NAMESPACE MNELIB
61//=============================================================================================================
62
63namespace MNELIB
64{
65
66//=============================================================================================================
67// FORWARD DECLARATIONS
68//=============================================================================================================
69
70//=============================================================================================================
75
77{
78
79public:
80
81 //=========================================================================================================
85 virtual ~MNE()
86 { }
87
88 //=========================================================================================================
102 inline static Eigen::VectorXd combine_xyz(const Eigen::VectorXd& vec)
103 {
105 }
106
107 //=========================================================================================================
121 inline static qint32 find_source_space_hemi(MNEHemisphere& p_Hemisphere)
122 {
123 return p_Hemisphere.find_source_space_hemi();
124 }
125
126 //=========================================================================================================
140 static inline qint32 get_current_comp(FIFFLIB::FiffInfo* info)
141 {
142 return info->get_current_comp();
143 }
144
145 //=========================================================================================================
164 static inline Eigen::SparseMatrix<double> make_block_diag(const Eigen::MatrixXd &A, qint32 n)
165 {
167 }
168
169 //=========================================================================================================
187 inline static bool make_compensator(const FIFFLIB::FiffInfo& info,
188 FIFFLIB::fiff_int_t from,
189 FIFFLIB::fiff_int_t to,
191 bool exclude_comp_chs = false)
192 {
193 return info.make_compensator(from, to, ctf_comp, exclude_comp_chs);
194 }
195
196 //=========================================================================================================
216 inline static FIFFLIB::fiff_int_t make_projector(const QList<FIFFLIB::FiffProj>& projs,
217 const QStringList& ch_names,
218 Eigen::MatrixXd& proj,
219 const QStringList& bads = FIFFLIB::defaultQStringList,
220 Eigen::MatrixXd& U = FIFFLIB::defaultMatrixXd)
221 {
223 ch_names,
224 proj,
225 bads,
226 U);
227 }
228
229 //=========================================================================================================
244 static inline qint32 make_projector(FIFFLIB::FiffInfo& info,
245 Eigen::MatrixXd& proj)
246 {
247 return info.make_projector(proj);
248 }
249
250 //=========================================================================================================
262 static bool patch_info(MNEHemisphere &p_Hemisphere)
263 {
264 return p_Hemisphere.compute_patch_info();
265 }
266
267 inline static bool read_events(const QString &t_sEventName,
268 const QString &t_fileRawName,
269 Eigen::MatrixXi& events)
270 {
271 FIFFLIB::FiffEvents fiffEvents;
272 if (!FIFFLIB::FiffEvents::read(t_sEventName, t_fileRawName, fiffEvents))
273 return false;
274 events = fiffEvents.events;
275 return true;
276 }
277
278 //=========================================================================================================
289 inline static bool read_events_from_fif(QIODevice &p_IODevice,
290 Eigen::MatrixXi& eventlist)
291 {
292 FIFFLIB::FiffEvents fiffEvents;
293 if (!FIFFLIB::FiffEvents::read_from_fif(p_IODevice, fiffEvents))
294 return false;
295 eventlist = fiffEvents.events;
296 return true;
297 }
298
299 //=========================================================================================================
310 inline static bool read_events_from_ascii(QIODevice &p_IODevice,
311 Eigen::MatrixXi& eventlist)
312 {
313 FIFFLIB::FiffEvents fiffEvents;
314 if (!FIFFLIB::FiffEvents::read_from_ascii(p_IODevice, fiffEvents))
315 return false;
316 eventlist = fiffEvents.events;
317 return true;
318 }
319
320 //=========================================================================================================
331 inline static bool write_events_to_fif(QIODevice &p_IODevice,
332 const Eigen::MatrixXi& eventlist)
333 {
334 FIFFLIB::FiffEvents fiffEvents;
335 fiffEvents.events = eventlist;
336 return fiffEvents.write_to_fif(p_IODevice);
337 }
338
339 //=========================================================================================================
351 inline static bool write_events_to_ascii(QIODevice &p_IODevice,
352 const Eigen::MatrixXi& eventlist,
353 float sfreq = 0.0f)
354 {
355 FIFFLIB::FiffEvents fiffEvents;
356 fiffEvents.events = eventlist;
357 return fiffEvents.write_to_ascii(p_IODevice, sfreq);
358 }
359
360 //=========================================================================================================
383 inline static FIFFLIB::FiffCov compute_epoch_covariance(const FIFFLIB::FiffRawData &raw,
384 const Eigen::MatrixXi &events,
385 const QList<int> &eventCodes,
386 float tmin,
387 float tmax,
388 float bmin = 0.0f,
389 float bmax = 0.0f,
390 bool doBaseline = false,
391 bool removeMean = true)
392 {
393 return FIFFLIB::FiffCov::compute_from_epochs(raw, events, eventCodes, tmin, tmax, bmin, bmax, doBaseline, removeMean);
394 }
395
396 //=========================================================================================================
417 inline static QList<FIFFLIB::FiffProj> compute_proj(const FIFFLIB::FiffRawData &raw,
418 const Eigen::MatrixXi &events,
419 int eventCode,
420 float tmin,
421 float tmax,
422 int nGrad,
423 int nMag,
424 int nEeg,
425 const QMap<QString,double> &mapReject = QMap<QString,double>())
426 {
427 return FIFFLIB::FiffProj::compute_from_raw(raw, events, eventCode, tmin, tmax, nGrad, nMag, nEeg, mapReject);
428 }
429
430 //=========================================================================================================
450 inline static bool save_raw(const FIFFLIB::FiffRawData &raw,
451 QIODevice &p_IODevice,
452 const Eigen::RowVectorXi &picks = Eigen::RowVectorXi(),
453 int decim = 1,
454 int from = -1,
455 int to = -1)
456 {
457 return raw.save(p_IODevice, picks, decim, from, to);
458 }
459
460 static void setup_compensators(FIFFLIB::FiffRawData& raw,
461 FIFFLIB::fiff_int_t dest_comp,
462 bool keep_comp);
463
464 //=========================================================================================================
481 inline static bool read_cov(FIFFLIB::FiffStream::SPtr& p_pStream,
482 const FIFFLIB::FiffDirNode::SPtr& p_Node,
483 FIFFLIB::fiff_int_t cov_kind,
484 FIFFLIB::FiffCov& p_covData)
485 {
486 return p_pStream->read_cov(p_Node,
487 cov_kind,
488 p_covData);
489 }
490
491 //=========================================================================================================
508 bool add_geom,
509 MNESourceSpaces& p_SourceSpace)
510 {
511 return MNESourceSpaces::readFromStream(p_pStream,
512 add_geom,
513 p_SourceSpace);
514 }
515
516 //ToDo FiffChInfoList Class
517 //=========================================================================================================
534 static QList<FIFFLIB::FiffChInfo> set_current_comp(QList<FIFFLIB::FiffChInfo>& chs,
535 FIFFLIB::fiff_int_t value)
536 {
538 value);
539 }
540
541 //=========================================================================================================
557 static inline bool transform_source_space_to(MNESourceSpaces& p_pMNESourceSpaces,
558 FIFFLIB::fiff_int_t dest,
560 {
561 return p_pMNESourceSpaces.transform_source_space_to(dest,
562 trans);
563 }
564
565 //=========================================================================================================
579 {
581 }
582};
583} // NAMESPACE
584
585#endif // MNE_H
Boundary element model bundle (inner skull, outer skull, outer skin) loaded from -bem....
Single closed BEM surface (triangulation, normals, conductivity).
MNELIB shared-library export/import macros and library build metadata.
#define MNESHARED_EXPORT
Definition mne_global.h:40
Ordered list of MNELIB::MNEEpochData objects sharing a common FIFFLIB::FiffInfo.
Per-hemisphere cortical surface bundle with decimation, patch info and rendering buffers.
Container pairing the left and right cortical source spaces of a subject.
FIFF continuous raw recording: FiffInfo plus a directory of FIFF_DATA_BUFFER tags for random-access s...
Symbolic FIFF tag, block, value, unit and channel-type constants shared across FIFFLIB.
Stim-channel event list (sample, previous value, new value triples) with FIFF read/write helpers.
SSP projection item: a named projection vector set with active/desired flags, parsed from FIFFB_PROJ_...
Set of averaged evoked responses sharing a FiffInfo, plus the ave-style category / rejection descript...
Noise / data covariance matrix as stored under FIFFB_MNE_COV, with channel names, kind,...
Static linear-algebra helpers: SVD-based conditioning, block-diagonal assembly, sorted index pairs.
Core MNE data structures (source spaces, source estimates, hemispheres).
Labelled 4x4 FIFF affine: source frame, destination frame, rotation, translation and cached inverse.
FIFF noise / data covariance: matrix, channel names, kind, applied projectors, bads,...
Definition fiff_cov.h:79
static FiffCov compute_from_epochs(const FiffRawData &raw, const Eigen::MatrixXi &events, const QList< int > &eventCodes, float tmin, float tmax, float bmin=0.0f, float bmax=0.0f, bool doBaseline=false, bool removeMean=true, unsigned int ignoreMask=0, float delay=0.0f)
Definition fiff_cov.cpp:472
One CTF software-gradient compensation matrix: grade kind, calibration flag and the gradiometer × ref...
QSharedPointer< FiffDirNode > SPtr
FIFF event list: (sample, prev, new) integer triples with read / write / detect / filter helpers.
Definition fiff_events.h:69
Eigen::MatrixXi events
bool write_to_ascii(QIODevice &p_IODevice, float sfreq=0.0f) const
static bool read(const QString &t_sEventName, const QString &t_fileRawName, FiffEvents &p_Events)
static bool read_from_fif(QIODevice &p_IODevice, FiffEvents &p_Events)
bool write_to_fif(QIODevice &p_IODevice) const
static bool read_from_ascii(QIODevice &p_IODevice, FiffEvents &p_Events)
Full FIFF measurement info: per-channel descriptors, sampling and filter setup, projectors,...
Definition fiff_info.h:88
void set_current_comp(fiff_int_t value)
Definition fiff_info.h:301
qint32 make_projector(Eigen::MatrixXd &proj) const
Definition fiff_info.h:287
qint32 get_current_comp()
bool make_compensator(fiff_int_t from, fiff_int_t to, FiffCtfComp &ctf_comp, bool exclude_comp_chs=false) const
FIFF named matrix: dense / sparse Eigen matrix plus row-name and column-name string lists.
static QList< FiffProj > compute_from_raw(const FiffRawData &raw, const Eigen::MatrixXi &events, int eventCode, float tmin, float tmax, int nGrad, int nMag, int nEeg, const QMap< QString, double > &mapReject=QMap< QString, double >())
static fiff_int_t make_projector(const QList< FiffProj > &projs, const QStringList &ch_names, Eigen::MatrixXd &proj, const QStringList &bads=defaultQStringList, Eigen::MatrixXd &U=defaultMatrixXd)
QSharedPointer< FiffStream > SPtr
static Eigen::VectorXd combine_xyz(const Eigen::VectorXd &vec)
Definition linalg.cpp:57
static Eigen::SparseMatrix< double > make_block_diag(const Eigen::MatrixXd &A, qint32 n)
Definition linalg.cpp:198
The MNE class provides wrapper functions to stay consistent with mne matlab toolbox.
Definition mne.h:77
static bool write_events_to_fif(QIODevice &p_IODevice, const Eigen::MatrixXi &eventlist)
Definition mne.h:331
static qint32 make_projector(FIFFLIB::FiffInfo &info, Eigen::MatrixXd &proj)
Definition mne.h:244
static qint32 get_current_comp(FIFFLIB::FiffInfo *info)
Definition mne.h:140
static bool read_events_from_ascii(QIODevice &p_IODevice, Eigen::MatrixXi &eventlist)
Definition mne.h:310
static bool make_compensator(const FIFFLIB::FiffInfo &info, FIFFLIB::fiff_int_t from, FIFFLIB::fiff_int_t to, FIFFLIB::FiffCtfComp &ctf_comp, bool exclude_comp_chs=false)
Definition mne.h:187
static FIFFLIB::fiff_int_t make_projector(const QList< FIFFLIB::FiffProj > &projs, const QStringList &ch_names, Eigen::MatrixXd &proj, const QStringList &bads=FIFFLIB::defaultQStringList, Eigen::MatrixXd &U=FIFFLIB::defaultMatrixXd)
Definition mne.h:216
static QList< FIFFLIB::FiffChInfo > set_current_comp(QList< FIFFLIB::FiffChInfo > &chs, FIFFLIB::fiff_int_t value)
Definition mne.h:534
static bool save_raw(const FIFFLIB::FiffRawData &raw, QIODevice &p_IODevice, const Eigen::RowVectorXi &picks=Eigen::RowVectorXi(), int decim=1, int from=-1, int to=-1)
Definition mne.h:450
static bool transform_source_space_to(MNESourceSpaces &p_pMNESourceSpaces, FIFFLIB::fiff_int_t dest, FIFFLIB::FiffCoordTrans &trans)
Definition mne.h:557
virtual ~MNE()
Definition mne.h:85
static void transpose_named_matrix(FIFFLIB::FiffNamedMatrix &mat)
Definition mne.h:578
static bool patch_info(MNEHemisphere &p_Hemisphere)
Definition mne.h:262
static bool read_source_spaces(FIFFLIB::FiffStream::SPtr &p_pStream, bool add_geom, MNESourceSpaces &p_SourceSpace)
Definition mne.h:507
static bool write_events_to_ascii(QIODevice &p_IODevice, const Eigen::MatrixXi &eventlist, float sfreq=0.0f)
Definition mne.h:351
static Eigen::VectorXd combine_xyz(const Eigen::VectorXd &vec)
Definition mne.h:102
static bool read_cov(FIFFLIB::FiffStream::SPtr &p_pStream, const FIFFLIB::FiffDirNode::SPtr &p_Node, FIFFLIB::fiff_int_t cov_kind, FIFFLIB::FiffCov &p_covData)
Definition mne.h:481
static qint32 find_source_space_hemi(MNEHemisphere &p_Hemisphere)
Definition mne.h:121
static bool read_events(const QString &t_sEventName, const QString &t_fileRawName, Eigen::MatrixXi &events)
Definition mne.h:267
static bool read_events_from_fif(QIODevice &p_IODevice, Eigen::MatrixXi &eventlist)
Definition mne.h:289
static FIFFLIB::FiffCov compute_epoch_covariance(const FIFFLIB::FiffRawData &raw, const Eigen::MatrixXi &events, const QList< int > &eventCodes, float tmin, float tmax, float bmin=0.0f, float bmax=0.0f, bool doBaseline=false, bool removeMean=true)
Definition mne.h:383
static QList< FIFFLIB::FiffProj > compute_proj(const FIFFLIB::FiffRawData &raw, const Eigen::MatrixXi &events, int eventCode, float tmin, float tmax, int nGrad, int nMag, int nEeg, const QMap< QString, double > &mapReject=QMap< QString, double >())
Definition mne.h:417
static Eigen::SparseMatrix< double > make_block_diag(const Eigen::MatrixXd &A, qint32 n)
Definition mne.h:164
Hemisphere provides geometry information.
qint32 find_source_space_hemi() const
List of MNESourceSpace objects forming a subject source space.
bool transform_source_space_to(FIFFLIB::fiff_int_t dest, FIFFLIB::FiffCoordTrans &trans)
static bool readFromStream(FIFFLIB::FiffStream::SPtr &p_pStream, bool add_geom, MNESourceSpaces &p_SourceSpace)