v2.0.0
Loading...
Searching...
No Matches
inv_sensor_set.cpp
Go to the documentation of this file.
1//=============================================================================================================
18
19//=============================================================================================================
20// INCLUDES
21//=============================================================================================================
22
23#include "inv_sensor_set.h"
24#include <iostream>
25#include <fwd/fwd_coil_set.h>
26#include <fiff/fiff_ch_info.h>
27
28//=============================================================================================================
29// QT INCLUDES
30//=============================================================================================================
31
32#include <QCoreApplication>
33
34//=============================================================================================================
35// EIGEN INCLUDES
36//=============================================================================================================
37
38#include <Eigen/Dense>
39
40//=============================================================================================================
41// USED NAMESPACES
42//=============================================================================================================
43
44using namespace INVLIB;
45using namespace FIFFLIB;
46using namespace FWDLIB;
47using namespace Eigen;
48
49//=============================================================================================================
50// DEFINE GLOBAL METHODS
51//=============================================================================================================
52
53//=============================================================================================================
54// DEFINE MEMBER METHODS
55//=============================================================================================================
56
58{
59 if(pFwdSensorSet!=nullptr) {
60 initFromFwdCoilSet(pFwdSensorSet);
61 }
62}
63
64//=============================================================================================================
65
66void InvSensorSet::initFromFwdCoilSet(const QSharedPointer<FWDLIB::FwdCoilSet> pFwdSensorSet)
67{
68 m_ncoils = pFwdSensorSet->ncoil();
69 m_np = pFwdSensorSet->coils[0]->np;
70 initMatrices(m_ncoils,m_np);
71
72 // get data froms Fwd Coilset
73 for(int i = 0; i < m_ncoils; i++){
74 const FwdCoil* coil = pFwdSensorSet->coils[i].get();
75 MatrixXd matRmag = MatrixXd::Zero(m_np,3);
76 MatrixXd matCosmag = MatrixXd::Zero(m_np,3);
77 RowVectorXd vecW(m_np);
78
79 m_r0(i,0) = coil->r0[0];
80 m_r0(i,1) = coil->r0[1];
81 m_r0(i,2) = coil->r0[2];
82
83 m_ez(i,0) = coil->ez[0];
84 m_ez(i,1) = coil->ez[1];
85 m_ez(i,2) = coil->ez[2];
86
87 for (int p = 0; p < m_np; p++){
88 m_w(i*m_np+p) = coil->w[p];
89 for (int c = 0; c < 3; c++) {
90 matRmag(p,c) = coil->rmag(p, c);
91 matCosmag(p,c) = coil->cosmag(p, c);
92 }
93 }
94
95 m_cosmag.block(i*m_np,0,m_np,3) = matCosmag;
96 m_rmag.block(i*m_np,0,m_np,3) = matRmag;
97 }
98 m_tra = MatrixXd::Identity(m_ncoils,m_ncoils);
99}
100
101//=============================================================================================================
102
103void InvSensorSet::initMatrices(int ncoils, int np)
104{
105 m_ez = MatrixXd(ncoils,3);
106 m_r0 = MatrixXd(ncoils,3);
107 m_rmag = MatrixXd(ncoils*np,3);
108 m_cosmag = MatrixXd(ncoils*np,3);
109 m_cosmag = MatrixXd(ncoils*np,3);
110 m_tra = MatrixXd(ncoils,ncoils);
111 m_w = RowVectorXd(ncoils*np);
112}
113
114//=============================================================================================================
115
117{
118 const QString qPath = QString(QCoreApplication::applicationDirPath() + "/../resources/general/coilDefinitions/coil_def.dat");
119 m_pCoilDefinitions = FwdCoilSet::SPtr(FwdCoilSet::read_coil_defs(qPath).release());
120}
121
122//=============================================================================================================
123
124InvSensorSet InvSensorSetCreator::updateSensorSet(const QList<FIFFLIB::FiffChInfo>& channelList,
125 const Accuracy& accuracy)
126{
127 if(channelList.isEmpty()) {
128 return InvSensorSet();
129 } else {
130 auto pCoilMeg = FwdCoilSet::SPtr(m_pCoilDefinitions->create_meg_coils(channelList, channelList.size(), static_cast<int>(accuracy)).release());
131 return InvSensorSet(pCoilMeg);
132 }
133}
134
135//=============================================================================================================
Container of FwdCoil instances representing either a sensor-type template database or a concrete per-...
FIFF channel descriptor record (FIFF_CH_INFO): per-channel logical/scanner numbers,...
Compact MEG sensor-geometry container (positions, orientations, integration weights) used by the HPI ...
FIFF file I/O, in-memory data structures and high-level readers/writers.
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
Forward modelling — BEM solver, spherical models, sensor/coil definitions and the lead-field assembly...
Definition compute_fwd.h:83
Eigen::Matrix< float, Eigen::Dynamic, 3, Eigen::RowMajor > cosmag
Definition fwd_coil.h:171
Eigen::Vector3f r0
Definition fwd_coil.h:165
Eigen::Matrix< float, Eigen::Dynamic, 3, Eigen::RowMajor > rmag
Definition fwd_coil.h:170
Eigen::Vector3f ez
Definition fwd_coil.h:168
Eigen::VectorXf w
Definition fwd_coil.h:172
static FwdCoilSet::UPtr read_coil_defs(const QString &name)
QSharedPointer< FwdCoilSet > SPtr
Stores MEG sensor geometry (positions, orientations, weights, coil count) for a single sensor type.
InvSensorSet updateSensorSet(const QList< FIFFLIB::FiffChInfo > &channelList, const Accuracy &accuracy)