55 init(p_pFwd, p_bSparsed, p_iN, p_dThr);
68 return "Powell RAP MUSIC";
94 throw std::logic_error(
"RAP MUSIC was not initialized");
100 throw std::invalid_argument(
"Lead field channels do not match number of measurement channels");
116 int t_r =
calcPhi_s(p_matMeasurement, t_pMatPhi_s);
118 int t_iMaxSearch =
m_iN < t_r ?
m_iN : t_r;
122 qDebug() <<
"Warning: Rank " << t_r <<
" of the measurement data is smaller than the " <<
m_iN;
123 qDebug() <<
" sources to find.";
124 qDebug() <<
" Searching now for " << t_iMaxSearch <<
" correlated sources.";
131 t_matOrthProj.setIdentity();
135 t_matA_k_1.setZero();
151 p_RapDipoles.clear();
153 qDebug() <<
"##### Calculation of PWL RAP MUSIC started ######\n\n";
155 MatrixXT t_matProj_Phi_s(t_matOrthProj.rows(), t_pMatPhi_s->cols());
159 for(
int r = 0; r < t_iMaxSearch ; ++r)
161 t_matProj_Phi_s = t_matOrthProj*(*t_pMatPhi_s);
168 Eigen::JacobiSVD< MatrixXT > t_svdProj_Phi_S(t_matProj_Phi_s, Eigen::ComputeThinU);
170 useFullRank(t_svdProj_Phi_S.matrixU(), t_svdProj_Phi_S.singularValues().asDiagonal(), t_matU_B);
178 clock_t start_subcorr, end_subcorr;
179 start_subcorr = clock();
184 int t_iCurrentRow = 2;
189 int t_iMaxIdx_old = -1;
199 while(t_iMaxFound == 0)
204 #pragma omp parallel num_threads(m_iMaxNumThreads)
210 for(
int i = 0; i < t_iNumVecElements; i++)
212 int k = t_pVecIdxElements(i);
215 MatrixX6T t_matProj_G(t_matProj_LeadField.rows(),6);
244 VectorXT::Index t_iMaxIdx;
246 t_val_roh_k = t_vecRoh.maxCoeff(&t_iMaxIdx);
248 if(
static_cast<int>(t_iMaxIdx) == t_iMaxIdx_old)
255 t_iMaxIdx_old = t_iMaxIdx;
262 if(t_iIdx1 == t_iCurrentRow)
263 t_iCurrentRow = t_iIdx2;
265 t_iCurrentRow = t_iIdx1;
271 end_subcorr = clock();
273 float t_fSubcorrElapsedTime = (
static_cast<float>(end_subcorr-start_subcorr) /
static_cast<float>(CLOCKS_PER_SEC) ) * 1000.0f;
274 qDebug() <<
"Time Elapsed: " << t_fSubcorrElapsedTime <<
" ms";
277 qDebug() <<
"Iteration: " << r+1 <<
" of " << t_iMaxSearch
278 <<
"; Correlation: " << t_val_roh_k<<
"; Position (Idx+1): " << t_iIdx1+1 <<
" - " << t_iIdx2+1 <<
"\n\n";
284 MatrixX6T t_matProj_G_k_1(t_matOrthProj.rows(), t_matG_k_1.cols());
285 t_matProj_G_k_1 = t_matOrthProj * t_matG_k_1;
300 qDebug() <<
"Searching stopped, last correlation " << t_val_roh_k;
301 qDebug() <<
" is smaller then the given threshold " <<
m_dThreshold;
315 qDebug() <<
"##### Calculation of PWL RAP MUSIC completed ######";
319 float t_fElapsedTime = (
static_cast<float>(end-start) /
static_cast<float>(CLOCKS_PER_SEC) ) * 1000.0f;
320 qDebug() <<
"Total Time Elapsed: " << t_fElapsedTime <<
" ms";
325 return p_SourceEstimate;
333 return p_iRow*p_iNumPoints - (( (p_iRow-1)*p_iRow) / 2);
346 if (p_pVecElements.size() != p_iNumPoints)
347 p_pVecElements.resize(p_iNumPoints);
350 for(
int i = 0; i <= p_iRow; ++i)
355 int length = p_iNumPoints - p_iRow;
357 for(
int i = p_iRow; i < p_iRow+length; ++i)
359 p_pVecElements(i) = off+k;
Powell-accelerated RAP-MUSIC variant — replaces the exhaustive pair scan with a Powell line-search re...
Core MNE data structures (source spaces, source estimates, hemispheres).
FIFF file I/O, in-memory data structures and high-level readers/writers.
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
Single averaged evoked response: time axis, data, baseline, channel info and averaging metadata.
Source-space inverse-solution container with dense grid plus optional focal-dipole,...
Pair of correlated dipole indices and orientations found by the RAP MUSIC scanning step.
static int PowellOffset(int p_iRow, int p_iNumPoints)
virtual InvSourceEstimate calculateInverse(const FIFFLIB::FiffEvoked &p_fiffEvoked, bool pick_normal=false)
static void PowellIdxVec(int p_iRow, int p_iNumPoints, Eigen::VectorXi &p_pVecElements)
virtual const char * getName() const
virtual ~InvPwlRapMusic()
Eigen::Matrix< double, 6, 1 > Vector6T
static void calcA_k_1(const MatrixX6T &p_matG_k_1, const Vector6T &p_matPhi_k_1, const int p_iIdxk_1, MatrixXT &p_matA_k_1)
virtual InvSourceEstimate calculateInverse(const FIFFLIB::FiffEvoked &p_fiffEvoked, bool pick_normal=false)
static void insertSource(int p_iDipoleIdx1, int p_iDipoleIdx2, const Vector6T &p_vec_phi_k_1, double p_valCor, QList< InvDipolePair< double > > &p_RapDipoles)
bool init(MNELIB::MNEForwardSolution &p_pFwd, bool p_bSparsed=false, int p_iN=2, double p_dThr=0.5)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixXT
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorXT
void calcOrthProj(const MatrixXT &p_matA_k_1, MatrixXT &p_matOrthProj) const
int calcPhi_s(const MatrixXT &p_matMeasurement, MatrixXT *&p_pMatPhi_s) const
static int useFullRank(const MatrixXT &p_Mat, const MatrixXT &p_matSigma_src, MatrixXT &p_matFull_Rank, int type=NOT_TRANSPOSED)
Eigen::Matrix< double, Eigen::Dynamic, 6 > MatrixX6T
MNELIB::MNEForwardSolution m_ForwardSolution
std::vector< Pair > m_ppPairIdxCombinations
static void getGainMatrixPair(const MatrixXT &p_matGainMarix, MatrixX6T &p_matGainMarix_Pair, int p_iIdx1, int p_iIdx2)
int m_iNumLeadFieldCombinations
static double subcorr(MatrixX6T &p_matProj_G, const MatrixXT &p_pMatU_B)
In-memory representation of an -fwd.fif forward solution.