Skip to main content

MNERawBufDef

Namespace: MNELIB  ·  Library: MNE Library

#include <mne/mne_raw_buf_def.h>

class MNELIB::MNERawBufDef

Definition of one raw data buffer within a FIFF file.

Each MNERawBufDef describes a contiguous chunk of samples, either loaded from the FIFF file or produced by the overlap-add filter pipeline. Sample values are stored in a row-major matrix (nchan x ns) that is managed by an external ring buffer; an empty (0x0) matrix indicates that the data are not currently resident in memory.

src/examples/ex_mne_api/main.cpp
// MNE-C style reader: buffer directory, channel selection, projection and overlap-add filter
MNEFilterDef filter; // 40 Hz lowpass, 5 Hz transition, 4096-sample blocks
filter.filter_on = true;
filter.size = 4096;
filter.taper_size = 2048;
filter.lowpass = filter.eog_lowpass = 40.0f;
filter.lowpass_width = filter.eog_lowpass_width = 5.0f;
std::unique_ptr<MNERawData> mneRaw(MNERawData::open_file(rawFile.fileName(), false, false, filter));
const MNERawInfo& rawInfo = *mneRaw->info;
const MNERawBufDef& firstBuffer = mneRaw->bufs.front();

MNEChSelection sel; // channel names are stored without spaces
sel.chspick = sel.chspick_nospace = {"MEG0113", "EEG001", "EOG061"};
sel.nchan = sel.ndef = static_cast<int>(sel.chspick.size());
sel.pick_deriv = VectorXi::Constant(sel.nchan, -1);
sel.pick.resize(sel.nchan);
for (int c = 0; c < sel.nchan; ++c) {
sel.pick[c] = static_cast<int>(mneRaw->ch_names.indexOf(sel.chspick[c]));
}

const int ns = 25;
Matrix<float, Dynamic, Dynamic, RowMajor> segment(sel.nchan, ns);
std::vector<float*> rows{segment.row(0).data(), segment.row(1).data(), segment.row(2).data()};
mneRaw->pick_data(&sel, mneRaw->first_samp + 2990, ns, rows.data()); // calibrated, across a buffer boundary
const double eegRaw = segment(1, 0);
mneRaw->pick_data_filt(&sel, mneRaw->first_samp + 2990, ns, rows.data());
const double eegFilt = segment(1, 0);

// The file stores its 4 SSP projectors as inactive; makeProjection switches them on
std::unique_ptr<MNEProjOp> proj;
MNEProjOp::makeProjection({rawFile.fileName()}, rawInfo.chInfo, rawInfo.nchan, proj);
proj->assign_channels(mneRaw->ch_names, rawInfo.nchan);
proj->make_proj();
const MNEProjItem& firstItem = proj->items[0];
mneRaw->proj = std::move(proj);
mneRaw->pick_data_proj(&sel, mneRaw->first_samp + 2990, ns, rows.data());
const double eegProj = segment(1, 0);

Public Methods​

MNERawBufDef()​

Default constructor.


~MNERawBufDef()​

Destructor.


Example​

Used in examples​

ex_mne_api​

MNE library: BEM surfaces, surface projection, ICP, source spaces and epochs.

src/examples/ex_mne_api/main.cpp, line 271
filter.lowpass_width = filter.eog_lowpass_width = 5.0f;
std::unique_ptr<MNERawData> mneRaw(MNERawData::open_file(rawFile.fileName(), false, false, filter));
const MNERawInfo& rawInfo = *mneRaw->info;
const MNERawBufDef& firstBuffer = mneRaw->bufs.front();

Authors of this file​