Skip to main content

MNE

Namespace: MNELIB  ·  Library: MNE Library

#include <mne/mne.h>

class MNELIB::MNE

DECLARE MNE WRAPPER CLASS.

The MNE class provides wrapper functions to stay consistent with mne matlab toolbox.

src/examples/ex_mne_api/main.cpp
// The MNE facade mirrors the MNE-Matlab/Python toolbox functions
const QString eveName = tmp.filePath("audvis-eve.fif");
{
QFile eveOut(eveName);
MNE::write_events_to_fif(eveOut, events.events);
}
MatrixXi eventsBack;
MNE::read_events(eveName, rawFile.fileName(), eventsBack);
QList<FiffProj> projs = raw.info.projs; // stored inactive in the raw file
FiffProj::activate_projs(projs);
MatrixXd ssp; // like mne._fiff.proj.make_projector(info['projs'], ch_names, bads)
const int nProj = MNE::make_projector(projs, raw.info.ch_names, ssp, raw.info.bads);

Public Methods​

~MNE()​

dtor


Static Methods​

combine_xyz(vec)​

mne_combine_xyz

Parameters:

  • vec : const Eigen::VectorXd & Input row vector [ x1 y1 z1 ... x_n y_n z_n ].

Returns:

  • Eigen::VectorXd — Output vector [x1^2+y1^2+z1^2 ... x_n^2+y_n^2+z_n^2 ].

find_source_space_hemi(p_Hemisphere)​

mne_find_source_space_hemi

Parameters:

Returns:

  • qint32 — the deduced hemisphere id.

get_current_comp(info)​

mne_get_current_comp

Parameters:

  • info : *FiffInfo ** Fiff measurement info.

Returns:

  • qint32 — the current compensation.

make_block_diag(A, n)​

mne_block_diag - encoding part

Parameters:

  • A : const Eigen::MatrixXd & Matrix which should be diagonlized.

  • n : qint32 Columns of the submatrices.

Returns:

  • Eigen::SparseMatrix< double > — A sparse block diagonal, diagonalized from the elements in "A".

make_compensator(info, from, to, ctf_comp, exclude_comp_chs)​

mne_make_compensator

Parameters:

  • info : const FiffInfo & measurement info as returned by the fif reading routines.

  • from : FIFFLIB::fiff_int_t compensation in the input data.

  • to : FIFFLIB::fiff_int_t desired compensation in the output.

  • ctf_comp : FiffCtfComp & Compensation Matrix.

  • exclude_comp_chs : bool exclude compensation channels from the output (optional).

Returns:

  • bool — true if succeeded, false otherwise.

make_projector(projs, ch_names, proj, bads, U)​

make_projector

Parameters:

  • projs : const QList< FiffProj > & A set of projection vectors.

  • ch_names : const QStringList & A cell array of channel names.

  • proj : Eigen::MatrixXd & The projection operator to apply to the data.

  • bads : const QStringList & Bad channels to exclude.

  • U : Eigen::MatrixXd & The orthogonal basis of the projection vectors (optional).

Returns:

  • FIFFLIB::fiff_int_t — nproj - How many items in the projector.

make_projector(info, proj)​

mne_make_projector_info

Parameters:

  • info : FiffInfo & Fiff measurement info.

  • proj : Eigen::MatrixXd & The projection operator to apply to the data.

Returns:

  • qint32 — nproj - How many items in the projector.

patch_info(p_Hemisphere)​

mne_patch_info

Parameters:

Returns:

  • bool — true if succeeded, false otherwise.

read_events(t_sEventName, t_fileRawName, events)​


read_events_from_fif(p_IODevice, eventlist)​

mne_read_events

Read an event list from a fif file

Parameters:

  • p_IODevice : QIODevice & The I/O device to read from.

  • eventlist : Eigen::MatrixXi & The read eventlist m x 3; with m events; colum: 1 - position in samples, 3 - eventcode.

Returns:

  • bool — true if succeeded, false otherwise.

read_events_from_ascii(p_IODevice, eventlist)​

read_events

Read a list of events from an eve file

Parameters:

  • p_IODevice : QIODevice & The I/O device to read from.

  • eventlist : Eigen::MatrixXi & List of events.

Returns:

  • bool — true if succeeded, false otherwise.

write_events_to_fif(p_IODevice, eventlist)​

write_events_to_fif

Write an event list to a FIFF file.

Parameters:

  • p_IODevice : QIODevice & The I/O device to write to.

  • eventlist : const Eigen::MatrixXi & The event list (nEvents x 3): [sample, before, after].

Returns:

  • bool — true if succeeded, false otherwise.

write_events_to_ascii(p_IODevice, eventlist, sfreq)​

write_events_to_ascii

Write an event list to a text file (MNE-C compatible format).

Parameters:

  • p_IODevice : QIODevice & The I/O device to write to.

  • eventlist : const Eigen::MatrixXi & The event list (nEvents x 3): [sample, before, after].

  • sfreq : float Sampling frequency for time column computation.

Returns:

  • bool — true if succeeded, false otherwise.

compute_epoch_covariance(raw, events, eventCodes, tmin, tmax, bmin, bmax, doBaseline, removeMean)​

compute_epoch_covariance

Parameters:

  • raw : const FiffRawData & The raw data.

  • events : const Eigen::MatrixXi & Event matrix (nEvents x 3): [sample, before, after].

  • eventCodes : const QList< int > & Which event codes to include.

  • tmin : float Start of time window relative to event (seconds).

  • tmax : float End of time window relative to event (seconds).

  • bmin : float Baseline start (seconds, relative to event). Only used if doBaseline is true.

  • bmax : float Baseline end (seconds, relative to event). Only used if doBaseline is true.

  • doBaseline : bool Whether to apply baseline correction before covariance computation.

  • removeMean : bool Whether to remove sample mean from the covariance estimate.

Returns:

  • FiffCov — The computed noise covariance matrix, or empty FiffCov on failure.

compute_proj(raw, events, eventCode, tmin, tmax, nGrad, nMag, nEeg, mapReject)​

compute_proj

Parameters:

  • raw : const FiffRawData & The raw data.

  • events : const Eigen::MatrixXi & Event matrix (nEvents x 3).

  • eventCode : int Which event code to select epochs for.

  • tmin : float Start of epoch relative to event (seconds).

  • tmax : float End of epoch relative to event (seconds).

  • nGrad : int Number of gradiometer projection vectors.

  • nMag : int Number of magnetometer projection vectors.

  • nEeg : int Number of EEG projection vectors.

  • mapReject : const QMap< QString, double > & Rejection thresholds (key = channel type string, value = threshold).

Returns:

  • QList< FiffProj > — List of FiffProj items, or empty list on failure.

save_raw(raw, p_IODevice, picks, decim, from, to)​

save_raw

Parameters:

  • raw : const FiffRawData & The raw data to save.

  • p_IODevice : QIODevice & Output device to write to.

  • picks : const Eigen::RowVectorXi & Channel indices to include (empty = all channels).

  • decim : int Decimation factor (1 = no decimation).

  • from : int First sample to save (-1 = from start of raw data).

  • to : int Last sample to save (-1 = to end of raw data).

Returns:

  • bool — true on success.

setup_compensators(raw, dest_comp, keep_comp)​


read_cov(p_pStream, p_Node, cov_kind, p_covData)​

mne_read_cov

Parameters:

  • p_pStream : FIFFLIB::FiffStream::SPtr & an open fiff file.

  • p_Node : const FIFFLIB::FiffDirNode::SPtr & look for the matrix in here.

  • cov_kind : FIFFLIB::fiff_int_t what kind of a covariance matrix do we want?.

  • p_covData : FiffCov & the read covariance matrix.

Returns:

  • bool — true if succeeded, false otherwise.

read_source_spaces(p_pStream, add_geom, p_SourceSpace)​

mne_read_source_spaces

Parameters:

  • p_pStream : FIFFLIB::FiffStream::SPtr & The open fiff file.

  • add_geom : bool Add geometry information to the source spaces.

  • p_SourceSpace : MNESourceSpaces & The read source spaces.

Returns:

  • bool — true if succeeded, false otherwise.

set_current_comp(chs, value)​

mne_set_current_comp

Parameters:

  • chs : QList< FiffChInfo > & fiff channel info list.

  • value : FIFFLIB::fiff_int_t compensation value.

Returns:

  • QList< FiffChInfo > — the current compensation.

transform_source_space_to(p_pMNESourceSpaces, dest, trans)​

mne_transform_source_space_to

Parameters:

  • p_pMNESourceSpaces : MNESourceSpaces & the source space which is should be transformed.

  • dest : FIFFLIB::fiff_int_t destination check code.

  • trans : FiffCoordTrans & transformation information.

Returns:

  • bool — true if succeeded, false otherwise.

transpose_named_matrix(mat)​

mne_transpose_named_matrix

Parameters:


Example​

Used in examples​

ex_clustered_inverse_mne_raw​

Example of the computation of a clustered inverse mne raw.

src/examples/ex_clustered_inverse_mne_raw/main.cpp, line 95
QCommandLineOption inputOption("fileIn", "The input file <in>.", "in", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis_raw.fif");
QCommandLineOption surfOption("surfType", "FsSurface type <type>.", "type", "inflated");
QCommandLineOption annotOption("annotType", "FsAnnotation type <type>.", "type", "aparc.a2009s");
QCommandLineOption subjectOption("subject", "Selected subject <subject>.", "subject", "sample");
QCommandLineOption subjectPathOption("subjectPath", "Selected subject path <subjectPath>.", "subjectPath", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/subjects");
QCommandLineOption fwdOption("fwd", "Path to forwad solution <file>.", "file", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif");
QCommandLineOption covFileOption("cov", "Path to the covariance <file>.", "file", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis-cov.fif");
QCommandLineOption evokedIndexOption("aveIdx", "The average <index> to choose from the average file.", "index", "1");
QCommandLineOption eventsFileOption("eve", "Path to the event <file>.", "file", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis_raw-eve.fif");
QCommandLineOption hemiOption("hemi", "Selected hemisphere <hemi>.", "hemi", "2");
QCommandLineOption methodOption("method", "Inverse estimation <method>, i.e., 'MNE', 'dSPM' or 'sLORETA'.", "method", "dSPM"); //"MNE" | "dSPM" | "sLORETA"
QCommandLineOption snrOption("snr", "The SNR value used for computation <snr>.", "snr", "1.0"); //3.0;//0.1;//3.0;
QCommandLineOption invFileOutOption("invOut", "Path to inverse <file>, which is to be written.", "file", "");
QCommandLineOption stcFileOutOption("stcOut", "Path to stc <file>, which is to be written.", "file", "");

ex_inverse_mne_raw​

Example of a computation of a raw inverse.

src/examples/ex_inverse_mne_raw/main.cpp, line 94
// Command Line Parser
QCommandLineParser parser;
parser.setApplicationDescription("Compute Raw Inverse MNE Example");
parser.addHelpOption();

ex_connectivity​

Example of using the MNE-CPP Connectivity library.

src/examples/ex_connectivity/main.cpp, line 111
QCommandLineOption rawFileOption("fileIn", "The input file <in>.", "in", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis_raw.fif");
QCommandLineOption eventsFileOption("eve", "Path to the event <file>.", "file", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis_raw-eve.fif");
QCommandLineOption fwdOption("fwd", "Path to forwad solution <file>.", "file", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif");
QCommandLineOption subjectOption("subject", "Selected subject <subject>.", "subject", "sample");
QCommandLineOption subjectPathOption("subjectPath", "Selected subject path <subjectPath>.", "subjectPath", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/subjects");
QCommandLineOption covFileOption("cov", "Path to the covariance <file>.", "file", QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/MEG/sample/sample_audvis-cov.fif");
QCommandLineOption annotOption("annotType", "FsAnnotation <type> (for source level usage only).", "type", "aparc.a2009s");

Also used in ex_connectivity_comparison, ex_disp_3D, ex_inv_api, ex_clustered_inverse_pwl_rap_music_raw, ex_clustered_inverse_rap_music_raw, ex_mne_api, ex_histogram, ex_averaging, ex_compute_forward, ex_inverse_mne, ex_read_epochs, ex_roi_clustered_inverse_pwl_rap_music, ex_st_clustered_inverse_pwl_rap_music, ex_interpolation, ex_inverse_pwl_rap_music, ex_inverse_rap_music, ex_disp, ex_fiff_io, ex_read_fwd_disp_3D, ex_connectivity_performance, ex_dsp_rt, ex_evoked_grad_amp, ex_fiff_sniffer, ex_find_evoked, ex_fwd_api, ex_inv_beamformer, ex_read_evoked, ex_read_raw.

Authors of this file​