Skip to main content

MNEProjItem

Namespace: MNELIB  ·  Library: MNE Library

#include <mne/mne_proj_item.h>

class MNELIB::MNEProjItem

A single SSP (Signal-Space Projection) item.

MNEProjItem holds one linear projection operator consisting of a set of projection vectors (stored as an MNENamedMatrix), together with metadata such as the projection kind, a human-readable description, and flags indicating whether the item is currently active and which channel types (MEG / EEG) it covers.

Projection items are aggregated by MNEProjOp to form the complete SSP operator that is applied during inverse computations and dipole fitting.

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​

MNEProjItem()​

Default constructor.

Initialises all flags to their default values (active = true, kind = FIFFV_PROJ_ITEM_NONE, no MEG/EEG channels).


MNEProjItem(other)​

Copy constructor.

Deep-copies the projection vectors (unique_ptr member).

Parameters:

  • other : const MNEProjItem & Projection item to copy.

operator=(other)​

Copy assignment operator.

Deep-copies the projection vectors (unique_ptr member).

Parameters:

Returns:


MNEProjItem()​

Move constructor (defaulted).


operator=()​

Move assignment operator (defaulted).

Returns:


~MNEProjItem()​

Destructor.


affect(list, nlist)​

Test whether this projection item affects any of the listed channels.

Iterates over list and checks if any channel name matches a column in the projection vectors that contains at least one non-zero entry.

Parameters:

  • list : const QStringList & Channel names to test against.

  • nlist : int Number of channel names in list.

Returns:

  • int — true (non-zero) if this item affects at least one channel, false (0) otherwise.

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 295
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);
// mne.io.read_raw_fif: first_samp 12900, 6007 samples, 376 channels, 2 bads; EEG 001 at offset 2990 -1.01223e-09
// numpy port of MNE-C's overlap-add 40 Hz lowpass: -1.06402e-09; apply_proj(): -4.10778e-10
ok &= expect(mneRaw->first_samp == 12900 && mneRaw->nsamp == 6007 && rawInfo.nchan == 376 && mneRaw->nbad == 2 && firstBuffer.firsts == 12900 && mneRaw->bufs.size() > 1,
"MNERawData/MNERawInfo/MNERawBufDef: buffer directory of the sample recording like mne.io.read_raw_fif");
ok &= expect(sel.pick.minCoeff() >= 0 && near(eegRaw, -1.0122332562412516e-09, 1e-5) && near(eegProj, -4.107782047805238e-10, 1e-4) && near(eegFilt, -1.064022285676407e-09, 1e-3),
"MNEChSelection/MNEFilterDef: plain, projected and filtered reads match mne");

Authors of this file​