v2.0.0
Loading...
Searching...
No Matches
mne_cortical_map.cpp
Go to the documentation of this file.
1//=============================================================================================================
15
16//=============================================================================================================
17// INCLUDES
18//=============================================================================================================
19
20#include "mne_cortical_map.h"
23
24#include <fiff/fiff_info.h>
26
27//=============================================================================================================
28// QT INCLUDES
29//=============================================================================================================
30
31#include <QDebug>
32
33//=============================================================================================================
34// USED NAMESPACES
35//=============================================================================================================
36
37using namespace MNELIB;
38using namespace FIFFLIB;
39using namespace Eigen;
40
41//=============================================================================================================
42// DEFINE MEMBER METHODS
43//=============================================================================================================
44
46 const MNEForwardSolution& fwd,
47 const MNEInverseOperator& inv,
48 const FiffInfo& info)
49{
50 Q_UNUSED(info);
51
52 // Get the inverse kernel (nSources x nChannels)
53 const MatrixXd& kernel = const_cast<MNEInverseOperator&>(inv).getKernel();
54 if (kernel.rows() == 0 || kernel.cols() == 0) {
55 qWarning("MNECorticalMap::makeCorticalMap - Inverse kernel is empty. "
56 "Make sure the inverse operator has been prepared (assemble_kernel).");
57 return MatrixXd();
58 }
59
60 // Get the forward gain matrix (nChannels x nSources)
61 if (!fwd.sol || fwd.sol->data.rows() == 0) {
62 qWarning("MNECorticalMap::makeCorticalMap - Forward solution is empty.");
63 return MatrixXd();
64 }
65 const MatrixXd& gain = fwd.sol->data;
66
67 // Verify dimension compatibility
68 if (kernel.cols() != gain.rows()) {
69 qWarning("MNECorticalMap::makeCorticalMap - Dimension mismatch: "
70 "kernel is %lld x %lld, gain is %lld x %lld",
71 static_cast<long long>(kernel.rows()),
72 static_cast<long long>(kernel.cols()),
73 static_cast<long long>(gain.rows()),
74 static_cast<long long>(gain.cols()));
75 return MatrixXd();
76 }
77
78 // M = inv_kernel * fwd_gain^T => (nSources x nChannels) * (nChannels x nSources)^T
79 // Actually gain is (nChannels x nSources), so gain^T is (nSources x nChannels)
80 // M = kernel * gain => (nSources x nChannels) * (nChannels x nSources) = (nSources x nSources)
81 MatrixXd M = kernel * gain;
82
83 return M;
84}
Pre-computed inverse operator (whitened SVD of the forward model) for MNE/dSPM/sLORETA.
Vertex-to-vertex map between two cortical surfaces (e.g. subject -> fsaverage).
Forward solution (gain matrix mapping source dipoles to sensor measurements).
Matrix paired with row and column name lists, the on-disk form of FIFFB_PROJ_ITEM / FIFFB_MNE_NAMED_M...
Full FIFF measurement metadata: everything from FIFFB_MEAS / FIFFB_MEAS_INFO needed to interpret a re...
Core MNE data structures (source spaces, source estimates, hemispheres).
FIFF file I/O, in-memory data structures and high-level readers/writers.
Full FIFF measurement info: per-channel descriptors, sampling and filter setup, projectors,...
Definition fiff_info.h:88
static Eigen::MatrixXd makeCorticalMap(const MNEForwardSolution &fwd, const MNEInverseOperator &inv, const FIFFLIB::FiffInfo &info)
In-memory representation of an -fwd.fif forward solution.
FIFFLIB::FiffNamedMatrix::SDPtr sol
MNE-style inverse operator.