v2.0.0
Loading...
Searching...
No Matches
MNELIB::MNEProjOp Class Reference

Projection operator managing a set of linear projection items and the final compiled projector matrix. More...

#include <mne_proj_op.h>

Public Types

typedef QSharedPointer< MNEProjOpSPtr
typedef QSharedPointer< const MNEProjOpConstSPtr
using RowMajorMatrixXf = Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>

Public Member Functions

 MNEProjOp ()
 Default constructor.
 ~MNEProjOp ()
 Destructor.
void free_proj ()
 Release the compiled projector data.
MNEProjOpcombine (MNEProjOp *from)
 Append all projection items from another operator.
void add_item_active (const MNENamedMatrix *vecs, int kind, const QString &desc, int is_active)
 Add a projection item with an explicit active/inactive state.
void add_item (const MNENamedMatrix *vecs, int kind, const QString &desc)
 Add a projection item that is active by default.
MNEProjOpdup () const
 Create a deep copy of this projection operator.
int affect (const QStringList &list, int nlist)
int affect_chs (const QList< FIFFLIB::FiffChInfo > &chs, int nch)
int project_vector (float *vec, int nvec, int do_complement)
void report_data (QTextStream &out, const char *tag, int list_data, char **exclude, int nexclude)
void report (QTextStream &out, const char *tag)
int assign_channels (const QStringList &list, int nlist)
int make_proj_bad (char **bad, int nbad)
int make_proj ()
int project_dvector (Eigen::Ref< Eigen::VectorXd > vec, int nch, int do_complement)
int apply_cov (MNECovMatrix *c)

Static Public Member Functions

static MNEProjOpcreate_average_eeg_ref (const QList< FIFFLIB::FiffChInfo > &chs, int nch)
 Create an average EEG reference projector.
static MNEProjOpread_from_node (FIFFLIB::FiffStream::SPtr &stream, const FIFFLIB::FiffDirNode::SPtr &start)
 Read all linear projection items from a FIFF tree node.
static MNEProjOpread (const QString &name)
static bool makeProjection (const QList< QString > &projnames, const QList< FIFFLIB::FiffChInfo > &chs, int nch, std::unique_ptr< MNEProjOp > &result)
 Load and combine SSP projection operators from files for the selected channels.

Public Attributes

QList< MNELIB::MNEProjItemitems
int nitems
QStringList names
int nch
int nvec
RowMajorMatrixXf proj_data

Detailed Description

Projection operator managing a set of linear projection items and the final compiled projector matrix.

MNEProjOp aggregates zero or more MNEProjItem entries, each holding a named matrix of projection vectors. When the operator is compiled (make_projector), the individual items are orthogonalised into a single dense projector stored in proj_data.

Definition at line 86 of file mne_proj_op.h.

Member Typedef Documentation

◆ ConstSPtr

typedef QSharedPointer<const MNEProjOp> MNELIB::MNEProjOp::ConstSPtr

Const shared pointer type for MNEProjOp.

Definition at line 90 of file mne_proj_op.h.

◆ RowMajorMatrixXf

using MNELIB::MNEProjOp::RowMajorMatrixXf = Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>

Dynamic float matrix stored in row-major order (contiguous rows for C-style interop).

Definition at line 93 of file mne_proj_op.h.

◆ SPtr

typedef QSharedPointer<MNEProjOp> MNELIB::MNEProjOp::SPtr

Shared pointer type for MNEProjOp.

Definition at line 89 of file mne_proj_op.h.

Constructor & Destructor Documentation

◆ MNEProjOp()

MNEProjOp::MNEProjOp ( )

Default constructor.

Creates an empty operator with no projection items.

Definition at line 220 of file mne_proj_op.cpp.

◆ ~MNEProjOp()

MNEProjOp::~MNEProjOp ( )

Destructor.

Definition at line 229 of file mne_proj_op.cpp.

Member Function Documentation

◆ add_item()

void MNEProjOp::add_item ( const MNENamedMatrix * vecs,
int kind,
const QString & desc )

Add a projection item that is active by default.

Convenience wrapper around add_item_active() with is_active = TRUE.

Parameters
[in]vecsNamed matrix holding the projection vectors.
[in]kindProjection kind constant.
[in]descHuman-readable description of the projection.

Definition at line 309 of file mne_proj_op.cpp.

◆ add_item_active()

void MNEProjOp::add_item_active ( const MNENamedMatrix * vecs,
int kind,
const QString & desc,
int is_active )

Add a projection item with an explicit active/inactive state.

The projection kind (MEG/EEG) is auto-detected from channel names.

Parameters
[in]vecsNamed matrix holding the projection vectors.
[in]kindProjection kind constant.
[in]descHuman-readable description of the projection.
[in]is_activeWhether the item is active on load.

Definition at line 265 of file mne_proj_op.cpp.

◆ affect()

int MNEProjOp::affect ( const QStringList & list,
int nlist )

Count how many active projection vectors affect a given list of channel names.

Parameters
[in]listList of channel names to test.
[in]nlistNumber of channel names.
Returns
Number of projection vectors that affect at least one channel in the list (0 if none).

Definition at line 368 of file mne_proj_op.cpp.

◆ affect_chs()

int MNEProjOp::affect_chs ( const QList< FIFFLIB::FiffChInfo > & chs,
int nch )

Count how many active projection vectors affect the given channels. Convenience wrapper that extracts channel names and delegates to affect().

Parameters
[in]chsChannel information list.
[in]nchNumber of channels.
Returns
Number of affecting projection vectors (0 if none or nch == 0).

Definition at line 382 of file mne_proj_op.cpp.

◆ apply_cov()

int MNEProjOp::apply_cov ( MNECovMatrix * c)

Apply this projection operator to a covariance matrix from both sides: C' = (I - P) C (I - P)^T (or P C P^T if do_complement is false).

Parameters
[in,out]cThe covariance matrix to project.
Returns
OK on success, FAIL on error.

Definition at line 954 of file mne_proj_op.cpp.

◆ assign_channels()

int MNEProjOp::assign_channels ( const QStringList & list,
int nlist )

Assign a channel name list to this projection operator, invalidating any previously compiled projector.

Parameters
[in]listChannel name list.
[in]nlistNumber of channels.
Returns
OK on success.

Definition at line 675 of file mne_proj_op.cpp.

◆ combine()

MNEProjOp * MNEProjOp::combine ( MNEProjOp * from)

Append all projection items from another operator.

Each item's active_file flag is preserved.

Parameters
[in]fromSource operator whose items are copied.
Returns
Pointer to this operator.

Definition at line 248 of file mne_proj_op.cpp.

◆ create_average_eeg_ref()

MNEProjOp * MNEProjOp::create_average_eeg_ref ( const QList< FIFFLIB::FiffChInfo > & chs,
int nch )
static

Create an average EEG reference projector.

Builds a uniform-weight vector ( $1/\sqrt{N_{\text{EEG}}}$) across all EEG channels.

Parameters
[in]chsChannel information list.
[in]nchNumber of channels.
Returns
A new projection operator, or NULL if no EEG channels are found. Caller takes ownership.

Definition at line 333 of file mne_proj_op.cpp.

◆ dup()

MNEProjOp * MNEProjOp::dup ( ) const

Create a deep copy of this projection operator.

Copies all items, their vectors, descriptions, and active states.

Returns
A newly allocated copy. Caller takes ownership.

Definition at line 316 of file mne_proj_op.cpp.

◆ free_proj()

void MNEProjOp::free_proj ( )

Release the compiled projector data.

Clears proj_data, names, nch, and nvec without touching the underlying projection items.

Definition at line 235 of file mne_proj_op.cpp.

◆ make_proj()

int MNEProjOp::make_proj ( )

Compile the projection operator via SVD (no bad channels). Convenience wrapper around make_proj_bad().

Returns
OK on success, FAIL on error.

Definition at line 855 of file mne_proj_op.cpp.

◆ make_proj_bad()

int MNEProjOp::make_proj_bad ( char ** bad,
int nbad )

Compile the projection operator via SVD, excluding bad channels. Active projection items are picked, expanded to the assigned channel list, bad channels are zeroed, and SVD is performed to produce an orthogonal projector matrix stored in proj_data.

Parameters
[in]badArray of bad channel names (may be nullptr).
[in]nbadNumber of bad channels.
Returns
OK on success, FAIL on error.

Definition at line 704 of file mne_proj_op.cpp.

◆ makeProjection()

bool MNEProjOp::makeProjection ( const QList< QString > & projnames,
const QList< FIFFLIB::FiffChInfo > & chs,
int nch,
std::unique_ptr< MNEProjOp > & result )
static

Load and combine SSP projection operators from files for the selected channels.

Reads projection items from each file in projnames, and if EEG channels are present adds an average EEG reference projector when none is found. Returns nullptr if the resulting projector does not affect any of the given channels.

Refactored: make_projection (dipole_fit_setup.c)

Parameters
[in]projnamesList of FIFF file paths containing projection data.
[in]chsChannel information list.
[in]nchNumber of channels.
[out]resultThe combined projection operator (nullptr when no projection is needed).
Returns
true on success, false on read error.

Definition at line 889 of file mne_proj_op.cpp.

◆ project_dvector()

int MNEProjOp::project_dvector ( Eigen::Ref< Eigen::VectorXd > vec,
int nch,
int do_complement )

Apply the compiled projection operator to a double-precision data vector.

Parameters
[in,out]vecData vector.
[in]nchExpected length (must match operator dimension).
[in]do_complementIf non-zero, compute (I - P) * vec.
Returns
OK on success, FAIL on dimension mismatch.

Definition at line 862 of file mne_proj_op.cpp.

◆ project_vector()

int MNEProjOp::project_vector ( float * vec,
int nvec,
int do_complement )

Apply the compiled projection operator to a data vector in-place.

If do_complement is true, the projected components are subtracted from vec (signal cleaning). Otherwise, vec is replaced by the projection itself.

Parameters
[in,out]vecData vector of length nch.
[in]nvecExpected number of channels (must match nch).
[in]do_complementIf non-zero, compute the complement (I - P) * vec.
Returns
OK on success, FAIL on dimension mismatch.

Definition at line 400 of file mne_proj_op.cpp.

◆ read()

MNEProjOp * MNEProjOp::read ( const QString & name)
static

Read a projection operator from a FIFF file by path. Convenience wrapper that opens the file and delegates to read_from_node().

Parameters
[in]namePath to the FIFF file.
Returns
The loaded projection operator, or NULL on error. Caller takes ownership.

Definition at line 595 of file mne_proj_op.cpp.

◆ read_from_node()

MNEProjOp * MNEProjOp::read_from_node ( FIFFLIB::FiffStream::SPtr & stream,
const FIFFLIB::FiffDirNode::SPtr & start )
static

Read all linear projection items from a FIFF tree node.

Parameters
[in]streamAn open FIFF stream.
[in]startThe tree node to search for projection blocks.
Returns
A populated projection operator (possibly with zero items), or NULL on error. Caller takes ownership.

Definition at line 445 of file mne_proj_op.cpp.

◆ report()

void MNEProjOp::report ( QTextStream & out,
const char * tag )

Write a one-line-per-item summary of all projection items to a text stream (no vector data). Convenience wrapper around report_data().

Parameters
[in,out]outThe text stream to write to.
[in]tagPrefix string printed before each line.

Definition at line 668 of file mne_proj_op.cpp.

◆ report_data()

void MNEProjOp::report_data ( QTextStream & out,
const char * tag,
int list_data,
char ** exclude,
int nexclude )

Write a formatted summary of all projection items to a text stream, optionally including the full projection vector data while zeroing out excluded channels.

Parameters
[in,out]outThe text stream to write to.
[in]tagPrefix string printed before each line.
[in]list_dataIf non-zero, print full vector data.
[in]excludeArray of channel names to exclude from the display.
[in]nexcludeNumber of excluded channels.

Definition at line 615 of file mne_proj_op.cpp.

Member Data Documentation

◆ items

QList<MNELIB::MNEProjItem> MNELIB::MNEProjOp::items

The projection items.

Definition at line 341 of file mne_proj_op.h.

◆ names

QStringList MNELIB::MNEProjOp::names

Names of the channels in the final compiled projector.

Definition at line 343 of file mne_proj_op.h.

◆ nch

int MNELIB::MNEProjOp::nch

Number of channels in the final projector.

Definition at line 344 of file mne_proj_op.h.

◆ nitems

int MNELIB::MNEProjOp::nitems

Number of items.

Definition at line 342 of file mne_proj_op.h.

◆ nvec

int MNELIB::MNEProjOp::nvec

Number of orthogonalized vectors in the final projector.

Definition at line 345 of file mne_proj_op.h.

◆ proj_data

RowMajorMatrixXf MNELIB::MNEProjOp::proj_data

The compiled projector: orthogonalized projection vectors (nvec x nch).

Definition at line 346 of file mne_proj_op.h.


The documentation for this class was generated from the following files: