v2.0.0
Loading...
Searching...
No Matches
mne_cortical_map.cpp
Go to the documentation of this file.
1//=============================================================================================================
34
35//=============================================================================================================
36// INCLUDES
37//=============================================================================================================
38
39#include "mne_cortical_map.h"
42
43#include <fiff/fiff_info.h>
45
46//=============================================================================================================
47// QT INCLUDES
48//=============================================================================================================
49
50#include <QDebug>
51
52//=============================================================================================================
53// USED NAMESPACES
54//=============================================================================================================
55
56using namespace MNELIB;
57using namespace FIFFLIB;
58using namespace Eigen;
59
60//=============================================================================================================
61// DEFINE MEMBER METHODS
62//=============================================================================================================
63
65 const MNEForwardSolution& fwd,
66 const MNEInverseOperator& inv,
67 const FiffInfo& info)
68{
69 Q_UNUSED(info);
70
71 // Get the inverse kernel (nSources x nChannels)
72 const MatrixXd& kernel = const_cast<MNEInverseOperator&>(inv).getKernel();
73 if (kernel.rows() == 0 || kernel.cols() == 0) {
74 qWarning("MNECorticalMap::makeCorticalMap - Inverse kernel is empty. "
75 "Make sure the inverse operator has been prepared (assemble_kernel).");
76 return MatrixXd();
77 }
78
79 // Get the forward gain matrix (nChannels x nSources)
80 if (!fwd.sol || fwd.sol->data.rows() == 0) {
81 qWarning("MNECorticalMap::makeCorticalMap - Forward solution is empty.");
82 return MatrixXd();
83 }
84 const MatrixXd& gain = fwd.sol->data;
85
86 // Verify dimension compatibility
87 if (kernel.cols() != gain.rows()) {
88 qWarning("MNECorticalMap::makeCorticalMap - Dimension mismatch: "
89 "kernel is %lld x %lld, gain is %lld x %lld",
90 static_cast<long long>(kernel.rows()),
91 static_cast<long long>(kernel.cols()),
92 static_cast<long long>(gain.rows()),
93 static_cast<long long>(gain.cols()));
94 return MatrixXd();
95 }
96
97 // M = inv_kernel * fwd_gain^T => (nSources x nChannels) * (nChannels x nSources)^T
98 // Actually gain is (nChannels x nSources), so gain^T is (nSources x nChannels)
99 // M = kernel * gain => (nSources x nChannels) * (nChannels x nSources) = (nSources x nSources)
100 MatrixXd M = kernel * gain;
101
102 return M;
103}
FiffInfo class declaration.
FiffNamedMatrix class declaration.
MNEForwardSolution class declaration.
MNECorticalMap class declaration.
MNEInverseOperator class declaration.
Core MNE data structures (source spaces, source estimates, hemispheres).
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
FIFF measurement file information.
Definition fiff_info.h:86
static Eigen::MatrixXd makeCorticalMap(const MNEForwardSolution &fwd, const MNEInverseOperator &inv, const FIFFLIB::FiffInfo &info)
FIFFLIB::FiffNamedMatrix::SDPtr sol
MNE-style inverse operator.