v2.0.0
Loading...
Searching...
No Matches
mne_epoch_data.cpp
Go to the documentation of this file.
1//=============================================================================================================
17
18//=============================================================================================================
19// INCLUDES
20//=============================================================================================================
21
22#include "mne_epoch_data.h"
23
24#include <cmath>
25
26#include <math/numerics.h>
27
28//=============================================================================================================
29// USED NAMESPACES
30//=============================================================================================================
31
32using namespace MNELIB;
33using namespace Eigen;
34using namespace UTILSLIB;
35
36//=============================================================================================================
37// DEFINE MEMBER METHODS
38//=============================================================================================================
39
41: event(-1)
42, eventSample(-1)
43, tmin(-1)
44, tmax(-1)
45, bReject(false)
46, bUserReject(false)
47{
48}
49
50//=============================================================================================================
51
53: epoch(p_MNEEpochData.epoch)
54, event(p_MNEEpochData.event)
55, eventSample(p_MNEEpochData.eventSample)
56, tmin(p_MNEEpochData.tmin)
57, tmax(p_MNEEpochData.tmax)
58, bReject(p_MNEEpochData.bReject)
59, bUserReject(p_MNEEpochData.bUserReject)
60{
61}
62
63//=============================================================================================================
64
68
69//=============================================================================================================
70
71void MNEEpochData::applyBaselineCorrection(const QPair<float, float>& baseline)
72{
73 // Times on whole sample offsets: an interpolated float grid puts the stimulus sample just after 0
74 const Eigen::Index n = this->epoch.cols();
75 const double step = n > 1 ? (static_cast<double>(this->tmax) - this->tmin) / static_cast<double>(n - 1) : 1.0;
76 const double first = std::round(this->tmin / step);
77 RowVectorXf times(n);
78 for (Eigen::Index i = 0; i < n; ++i)
79 times(i) = static_cast<float>((first + static_cast<double>(i)) * step);
80 this->epoch = Numerics::rescale(this->epoch, times, baseline, QString("mean"));
81}
82
83//=============================================================================================================
84
85void MNEEpochData::pick_channels(const RowVectorXi& sel)
86{
87 if (sel.cols() == 0) {
88 qWarning("MNEEpochData::pick_channels - Warning : No channels were provided.\n");
89 return;
90 }
91
92 // Reduce data set
93 MatrixXd selBlock(1, 1);
94
95 if (selBlock.rows() != sel.cols() || selBlock.cols() != epoch.cols()) {
96 selBlock.resize(sel.cols(), epoch.cols());
97 }
98
99 for (qint32 l = 0; l < sel.cols(); ++l) {
100 if (sel(l) <= epoch.rows()) {
101 selBlock.row(l) = epoch.row(sel(0, l));
102 } else {
103 qWarning("FiffEvoked::pick_channels - Warning : Selected channel index out of bound.\n");
104 }
105 }
106
107 epoch = selBlock;
108}
General numerical helpers: GCD, log2, histogram binning, baseline rescaling, sparsity tests.
Single epoch (one trial slice of preprocessed sensor data) with timing and rejection metadata.
Core MNE data structures (source spaces, source estimates, hemispheres).
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
static Eigen::MatrixXd rescale(const Eigen::MatrixXd &data, const Eigen::RowVectorXf &times, const QPair< float, float > &baseline, QString mode)
void pick_channels(const Eigen::RowVectorXi &sel)
void applyBaselineCorrection(const QPair< float, float > &baseline)
Eigen::MatrixXd epoch
FIFFLIB::fiff_int_t eventSample
FIFFLIB::fiff_int_t event