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//=============================================================================================================
77
79{
80public:
81 //=========================================================================================================
85 virtual ~MNE()
86 {
87 }
88
89 //=========================================================================================================
103 inline static Eigen::VectorXd combine_xyz(const Eigen::VectorXd& vec)
104 {
106 }
107
108 //=========================================================================================================
122 inline static qint32 find_source_space_hemi(MNEHemisphere& p_Hemisphere)
123 {
124 return p_Hemisphere.find_source_space_hemi();
125 }
126
127 //=========================================================================================================
141 static inline qint32 get_current_comp(FIFFLIB::FiffInfo* info)
142 {
143 return info->get_current_comp();
144 }
145
146 //=========================================================================================================
165 static inline Eigen::SparseMatrix<double> make_block_diag(const Eigen::MatrixXd& A, qint32 n)
166 {
168 }
169
170 //=========================================================================================================
188 inline static bool make_compensator(const FIFFLIB::FiffInfo& info,
192 bool exclude_comp_chs = false)
193 {
194 return info.make_compensator(from, to, ctf_comp, exclude_comp_chs);
195 }
196
197 //=========================================================================================================
217 inline static FIFFLIB::fiff_int_t make_projector(const QList<FIFFLIB::FiffProj>& projs,
218 const QStringList& ch_names,
219 Eigen::MatrixXd& proj,
220 const QStringList& bads = FIFFLIB::defaultQStringList,
221 Eigen::MatrixXd& U = FIFFLIB::defaultMatrixXd)
222 {
224 ch_names,
225 proj,
226 bads,
227 U);
228 }
229
230 //=========================================================================================================
245 static inline qint32 make_projector(FIFFLIB::FiffInfo& info,
246 Eigen::MatrixXd& proj)
247 {
248 return info.make_projector(proj);
249 }
250
251 //=========================================================================================================
263 static bool patch_info(MNEHemisphere& p_Hemisphere)
264 {
265 return p_Hemisphere.compute_patch_info();
266 }
267
268 inline static bool read_events(const QString& t_sEventName,
269 const QString& t_fileRawName,
270 Eigen::MatrixXi& events)
271 {
272 FIFFLIB::FiffEvents fiffEvents;
273 if (!FIFFLIB::FiffEvents::read(t_sEventName, t_fileRawName, fiffEvents))
274 return false;
275 events = fiffEvents.events;
276 return true;
277 }
278
279 //=========================================================================================================
290 inline static bool read_events_from_fif(QIODevice& p_IODevice,
291 Eigen::MatrixXi& eventlist)
292 {
293 FIFFLIB::FiffEvents fiffEvents;
294 if (!FIFFLIB::FiffEvents::read_from_fif(p_IODevice, fiffEvents))
295 return false;
296 eventlist = fiffEvents.events;
297 return true;
298 }
299
300 //=========================================================================================================
311 inline static bool read_events_from_ascii(QIODevice& p_IODevice,
312 Eigen::MatrixXi& eventlist)
313 {
314 FIFFLIB::FiffEvents fiffEvents;
315 if (!FIFFLIB::FiffEvents::read_from_ascii(p_IODevice, fiffEvents))
316 return false;
317 eventlist = fiffEvents.events;
318 return true;
319 }
320
321 //=========================================================================================================
332 inline static bool write_events_to_fif(QIODevice& p_IODevice,
333 const Eigen::MatrixXi& eventlist)
334 {
335 FIFFLIB::FiffEvents fiffEvents;
336 fiffEvents.events = eventlist;
337 return fiffEvents.write_to_fif(p_IODevice);
338 }
339
340 //=========================================================================================================
352 inline static bool write_events_to_ascii(QIODevice& p_IODevice,
353 const Eigen::MatrixXi& eventlist,
354 float sfreq = 0.0f)
355 {
356 FIFFLIB::FiffEvents fiffEvents;
357 fiffEvents.events = eventlist;
358 return fiffEvents.write_to_ascii(p_IODevice, sfreq);
359 }
360
361 //=========================================================================================================
385 const Eigen::MatrixXi& events,
386 const QList<int>& eventCodes,
387 float tmin,
388 float tmax,
389 float bmin = 0.0f,
390 float bmax = 0.0f,
391 bool doBaseline = false,
392 bool removeMean = true)
393 {
394 return FIFFLIB::FiffCov::compute_from_epochs(raw, events, eventCodes, tmin, tmax, bmin, bmax, doBaseline, removeMean);
395 }
396
397 //=========================================================================================================
418 inline static QList<FIFFLIB::FiffProj> compute_proj(const FIFFLIB::FiffRawData& raw,
419 const Eigen::MatrixXi& events,
420 int eventCode,
421 float tmin,
422 float tmax,
423 int nGrad,
424 int nMag,
425 int nEeg,
426 const QMap<QString, double>& mapReject = QMap<QString, double>())
427 {
428 return FIFFLIB::FiffProj::compute_from_raw(raw, events, eventCode, tmin, tmax, nGrad, nMag, nEeg, mapReject);
429 }
430
431 //=========================================================================================================
451 inline static bool save_raw(const FIFFLIB::FiffRawData& raw,
452 QIODevice& p_IODevice,
453 const Eigen::RowVectorXi& picks = Eigen::RowVectorXi(),
454 int decim = 1,
455 int from = -1,
456 int to = -1)
457 {
458 return raw.save(p_IODevice, picks, decim, from, to);
459 }
460
461 static void setup_compensators(FIFFLIB::FiffRawData& raw,
462 FIFFLIB::fiff_int_t dest_comp,
463 bool keep_comp);
464
465 //=========================================================================================================
482 inline static bool read_cov(FIFFLIB::FiffStream::SPtr& p_pStream,
483 const FIFFLIB::FiffDirNode::SPtr& p_Node,
484 FIFFLIB::fiff_int_t cov_kind,
485 FIFFLIB::FiffCov& p_covData)
486 {
487 return p_pStream->read_cov(p_Node,
488 cov_kind,
489 p_covData);
490 }
491
492 //=========================================================================================================
509 bool add_geom,
510 MNESourceSpaces& p_SourceSpace)
511 {
512 return MNESourceSpaces::readFromStream(p_pStream,
513 add_geom,
514 p_SourceSpace);
515 }
516
517 //ToDo FiffChInfoList Class
518 //=========================================================================================================
535 static QList<FIFFLIB::FiffChInfo> set_current_comp(QList<FIFFLIB::FiffChInfo>& chs,
537 {
539 value);
540 }
541
542 //=========================================================================================================
558 static inline bool transform_source_space_to(MNESourceSpaces& p_pMNESourceSpaces,
561 {
562 return p_pMNESourceSpaces.transform_source_space_to(dest,
563 trans);
564 }
565
566 //=========================================================================================================
580 {
582 }
583};
584} // NAMESPACE
585
586#endif // MNE_H
Symbolic FIFF tag, block, value, unit and channel-type constants shared across FIFFLIB.
Set of averaged evoked responses sharing a FiffInfo, plus the ave-style category / rejection descript...
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_...
FIFF continuous raw recording: FiffInfo plus a directory of FIFF_DATA_BUFFER tags for random-access s...
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.
Single closed BEM surface (triangulation, normals, conductivity).
Per-hemisphere cortical surface bundle with decimation, patch info and rendering buffers.
Boundary element model bundle (inner skull, outer skull, outer skin) loaded from -bem....
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.
Container pairing the left and right cortical source spaces of a subject.
Core MNE data structures (source spaces, source estimates, hemispheres).
qint32 fiff_int_t
Definition fiff_types.h:86
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:82
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, const RejectionParams *rej=nullptr)
Definition fiff_cov.cpp:452
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:76
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:90
void set_current_comp(fiff_int_t value)
Definition fiff_info.h:317
qint32 make_projector(Eigen::MatrixXd &proj) const
Definition fiff_info.h:303
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)
Continuous FIFF raw recording: FiffInfo plus a random-access directory of FIFF_DATA_BUFFER tags.
bool save(QIODevice &p_IODevice, const Eigen::RowVectorXi &picks=Eigen::RowVectorXi(), int decim=1, int from=-1, int to=-1) const
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:193
The MNE class provides wrapper functions to stay consistent with mne matlab toolbox.
Definition mne.h:79
static bool write_events_to_fif(QIODevice &p_IODevice, const Eigen::MatrixXi &eventlist)
Definition mne.h:332
static qint32 make_projector(FIFFLIB::FiffInfo &info, Eigen::MatrixXd &proj)
Definition mne.h:245
static qint32 get_current_comp(FIFFLIB::FiffInfo *info)
Definition mne.h:141
static bool read_events_from_ascii(QIODevice &p_IODevice, Eigen::MatrixXi &eventlist)
Definition mne.h:311
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:188
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:217
static QList< FIFFLIB::FiffChInfo > set_current_comp(QList< FIFFLIB::FiffChInfo > &chs, FIFFLIB::fiff_int_t value)
Definition mne.h:535
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:451
static bool transform_source_space_to(MNESourceSpaces &p_pMNESourceSpaces, FIFFLIB::fiff_int_t dest, FIFFLIB::FiffCoordTrans &trans)
Definition mne.h:558
virtual ~MNE()
Definition mne.h:85
static void transpose_named_matrix(FIFFLIB::FiffNamedMatrix &mat)
Definition mne.h:579
static bool patch_info(MNEHemisphere &p_Hemisphere)
Definition mne.h:263
static bool read_source_spaces(FIFFLIB::FiffStream::SPtr &p_pStream, bool add_geom, MNESourceSpaces &p_SourceSpace)
Definition mne.h:508
static bool write_events_to_ascii(QIODevice &p_IODevice, const Eigen::MatrixXi &eventlist, float sfreq=0.0f)
Definition mne.h:352
static Eigen::VectorXd combine_xyz(const Eigen::VectorXd &vec)
Definition mne.h:103
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:482
static qint32 find_source_space_hemi(MNEHemisphere &p_Hemisphere)
Definition mne.h:122
static bool read_events(const QString &t_sEventName, const QString &t_fileRawName, Eigen::MatrixXi &events)
Definition mne.h:268
static bool read_events_from_fif(QIODevice &p_IODevice, Eigen::MatrixXi &eventlist)
Definition mne.h:290
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:384
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:418
static Eigen::SparseMatrix< double > make_block_diag(const Eigen::MatrixXd &A, qint32 n)
Definition mne.h:165
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)