Skip to main content

MNESparseNamedMatrix

Namespace: MNELIB  ·  Library: MNE Library

#include <mne/mne_sparse_named_matrix.h>

class MNELIB::MNESparseNamedMatrix

Sparse named matrix - matrix specification with row/column name lists.

src/examples/ex_mne_api/main.cpp
// A bipolar EOG-like montage in MNE-C's text syntax, saved as a derivation file and applied while reading raw data
const QString montage = tmp.filePath("montage.txt");
QFile montageFile(montage);
ok &= montageFile.open(QIODevice::WriteOnly | QIODevice::Text);
montageFile.write("\"EEG001-EEG002\" = \"EEG001\" - \"EEG002\"\n\"FRONT\" = 0.5 * \"EEG001\" + 0.5 * \"EEG002\" - \"EEG999\"\n");
montageFile.close();
const auto derivations = MNEDerivSet::readText(montage);
derivations->write(tmp.filePath("montage-deriv.fif"));
const auto fromFif = MNEDerivSet::read(tmp.filePath("montage-deriv.fif"));
const int usable = mneRaw->attachDerivations(*fromFif); // FRONT needs EEG999 and is dropped
MNEChSelection bipolar;
bipolar.chspick = bipolar.chspick_nospace = {"EEG001-EEG002", "EEG001", "EEG002"};
bipolar.nchan = bipolar.ndef = 3;
bipolar.nderiv = 1;
bipolar.pick = (VectorXi(3) << -1, mneRaw->ch_names.indexOf("EEG001"), mneRaw->ch_names.indexOf("EEG002")).finished();
bipolar.pick_deriv = (VectorXi(3) << 0, -1, -1).finished();
mneRaw->proj.reset();
mneRaw->pick_data(&bipolar, mneRaw->first_samp + 2990, ns, rows.data());

Public Methods​

MNESparseNamedMatrix()​


~MNESparseNamedMatrix()​


write(stream, kind)​

Writes the matrix as a FIFFB_MNE_NAMED_MATRIX block (MNE-C mne_write_sparse_named_matrix).

Parameters:

  • stream : FiffStream & A FIFF stream open for writing.

  • kind : int The tag for the sparse matrix.


Static Methods​

read(stream, node, kind)​

Reads a sparse named matrix (MNE-C mne_read_sparse_named_matrix).

Parameters:

  • stream : FIFFLIB::FiffStream::SPtr & An open FIFF stream.

  • node : const FIFFLIB::FiffDirNode::SPtr & A FIFFB_MNE_NAMED_MATRIX block, or a block whose direct children contain one.

  • kind : int The tag holding the sparse matrix.

Returns:

  • std::unique_ptr< MNESparseNamedMatrix > — The matrix, or nullptr if it is missing or its name lists do not fit.

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 517
// The derived channel is the difference of its inputs, read in one pass
ok &= expect(derivations->count() == 2 && fromFif->count() == 2 && usable == 1 && mneRaw->deriv_matched->deriv_data->nrow == 1 && segment.row(0).isApprox(segment.row(1) - segment.row(2), 1e-6f),
"MNEDerivSet/MNEDeriv/MNESparseNamedMatrix: MNE-C montage file, matched to the recording and read by MNERawData");

Authors of this file​