MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
spectral.h
Go to the documentation of this file.
1//=============================================================================================================
40#ifndef SPECTRAL_H
41#define SPECTRAL_H
42
43//=============================================================================================================
44// INCLUDES
45//=============================================================================================================
46
47#include "utils_global.h"
48
49#include <vector>
50#include <utility>
51
52//=============================================================================================================
53// EIGEN INCLUDES
54//=============================================================================================================
55
56#include <Eigen/Core>
57
58//=============================================================================================================
59// QT INCLUDES
60//=============================================================================================================
61
62#include <QString>
63#include <QPair>
64#include <QSharedPointer>
65
66//=============================================================================================================
67// DEFINE NAMESPACE UTILSLIB
68//=============================================================================================================
69
70namespace UTILSLIB
71{
72
74 Eigen::RowVectorXd vecData;
75 Eigen::MatrixXd matTaper;
76 int iNfft;
77};
78
79//=============================================================================================================
86{
87
88public:
89 //=========================================================================================================
93 Spectral() = delete;
94
95 //=========================================================================================================
105 static Eigen::MatrixXcd computeTaperedSpectraRow(const Eigen::RowVectorXd &vecData,
106 const Eigen::MatrixXd &matTaper,
107 int iNfft);
108
109 //=========================================================================================================
120 static QVector<Eigen::MatrixXcd> computeTaperedSpectraMatrix(const Eigen::MatrixXd &matData,
121 const Eigen::MatrixXd &matTaper,
122 int iNfft,
123 bool bUseThreads = true);
124
125// //=========================================================================================================
126// /**
127// * Calculates the full tapered spectra of a given input matrix data. This function calculates each row in parallel.
128// *
129// * @param[in] matData input matrix data (time domain), for which the spectrum is computed.
130// * @param[in] matTaper tapers used to compute the spectra.
131// * @param[in] iNfft FFT length.
132// * @param[in] bUseThreads Whether to use multiple threads.
133// *
134// * @return tapered spectra of the input data.
135// */
136// static std::vector<Eigen::MatrixXcd> computeTaperedSpectraMatrix(const Eigen::MatrixXd &matData,
137// const Eigen::MatrixXd &matTaper,
138// int iNfft,
139// bool bUseThreads = true);
140
141 //=========================================================================================================
149 static Eigen::MatrixXcd compute(const TaperedSpectraInputData& inputData);
150
151 //=========================================================================================================
158 static void reduce(QVector<Eigen::MatrixXcd>& finalData,
159 const Eigen::MatrixXcd& resultData);
160
161// //=========================================================================================================
162// /**
163// * Reduces the taperedSpectra results to a final result. This function gets called in parallel.
164// *
165// * @param[out] finalData The final data data.
166// * @param[in] resultData The resulting data from the computation step.
167// */
168// static void reduce(std::vector<Eigen::MatrixXcd>& finalData,
169// const Eigen::MatrixXcd& resultData);
170
171 //=========================================================================================================
182 static Eigen::RowVectorXd psdFromTaperedSpectra(const Eigen::MatrixXcd &matTapSpectrum,
183 const Eigen::VectorXd &vecTapWeights,
184 int iNfft,
185 double dSampFreq=1.0);
186
187 //=========================================================================================================
200 static Eigen::RowVectorXcd csdFromTaperedSpectra(const Eigen::MatrixXcd &vecTapSpectrumSeed,
201 const Eigen::MatrixXcd &vecTapSpectrumTarget,
202 const Eigen::VectorXd &vecTapWeightsSeed,
203 const Eigen::VectorXd &vecTapWeightsTarget,
204 int iNfft,
205 double dSampFreq = 1.0);
206
207 //=========================================================================================================
216 static Eigen::VectorXd calculateFFTFreqs(int iNfft, double dSampFreq);
217
218 //=========================================================================================================
227 static QPair<Eigen::MatrixXd, Eigen::VectorXd> generateTapers(int iSignalLength,
228 const QString &sWindowType = "hanning");
229
230 //=========================================================================================================
239 static std::pair<Eigen::MatrixXd, Eigen::VectorXd> generateTapers(int iSignalLength,
240 const std::string &sWindowType = "hanning");
241
242private:
243 //=========================================================================================================
251 static Eigen::MatrixXd hanningWindow(int iSignalLength);
252};
253
254//=============================================================================================================
255// INLINE DEFINITIONS
256//=============================================================================================================
257}//namespace
258
259#endif // SPECTRAL_H
utils library export/import macros.
#define UTILSSHARED_EXPORT
Computes spectral measures of input data.
Definition spectral.h:86