72:
RapMusic(p_pFwd, p_bSparsed, p_iN, p_dThr)
75 init(p_pFwd, p_bSparsed, p_iN, p_dThr);
88 return "Powell RAP MUSIC";
114 std::cout <<
"RAP MUSIC wasn't initialized!";
115 return p_SourceEstimate;
121 std::cout <<
"Lead Field channels do not fit to number of measurement channels!";
122 return p_SourceEstimate;
138 int t_r =
calcPhi_s(p_matMeasurement, t_pMatPhi_s);
140 int t_iMaxSearch =
m_iN < t_r ?
m_iN : t_r;
144 std::cout <<
"Warning: Rank " << t_r <<
" of the measurement data is smaller than the " <<
m_iN;
145 std::cout <<
" sources to find." << std::endl;
146 std::cout <<
" Searching now for " << t_iMaxSearch <<
" correlated sources.";
147 std::cout << std::endl << std::endl;
153 t_matOrthProj.setIdentity();
157 t_matA_k_1.setZero();
173 p_RapDipoles.clear();
175 std::cout <<
"##### Calculation of PWL RAP MUSIC started ######\n\n";
177 MatrixXT t_matProj_Phi_s(t_matOrthProj.rows(), t_pMatPhi_s->cols());
181 for(
int r = 0; r < t_iMaxSearch ; ++r)
183 t_matProj_Phi_s = t_matOrthProj*(*t_pMatPhi_s);
190 Eigen::JacobiSVD< MatrixXT > t_svdProj_Phi_S(t_matProj_Phi_s, Eigen::ComputeThinU);
192 useFullRank(t_svdProj_Phi_S.matrixU(), t_svdProj_Phi_S.singularValues().asDiagonal(), t_matU_B);
200 clock_t start_subcorr, end_subcorr;
201 start_subcorr = clock();
206 int t_iCurrentRow = 2;
211 int t_iMaxIdx_old = -1;
221 while(t_iMaxFound == 0)
226 #pragma omp parallel num_threads(m_iMaxNumThreads)
232 for(
int i = 0; i < t_iNumVecElements; i++)
234 int k = t_pVecIdxElements(i);
237 MatrixX6T t_matProj_G(t_matProj_LeadField.rows(),6);
266 VectorXT::Index t_iMaxIdx;
268 t_val_roh_k = t_vecRoh.maxCoeff(&t_iMaxIdx);
270 if((
int)t_iMaxIdx == t_iMaxIdx_old)
277 t_iMaxIdx_old = t_iMaxIdx;
284 if(t_iIdx1 == t_iCurrentRow)
285 t_iCurrentRow = t_iIdx2;
287 t_iCurrentRow = t_iIdx1;
293 end_subcorr = clock();
295 float t_fSubcorrElapsedTime = ( (float)(end_subcorr-start_subcorr) / (float)CLOCKS_PER_SEC ) * 1000.0f;
296 std::cout <<
"Time Elapsed: " << t_fSubcorrElapsedTime <<
" ms" << std::endl;
299 std::cout <<
"Iteration: " << r+1 <<
" of " << t_iMaxSearch
300 <<
"; Correlation: " << t_val_roh_k<<
"; Position (Idx+1): " << t_iIdx1+1 <<
" - " << t_iIdx2+1 <<
"\n\n";
306 MatrixX6T t_matProj_G_k_1(t_matOrthProj.rows(), t_matG_k_1.cols());
307 t_matProj_G_k_1 = t_matOrthProj * t_matG_k_1;
322 std::cout <<
"Searching stopped, last correlation " << t_val_roh_k;
323 std::cout <<
" is smaller then the given threshold " <<
m_dThreshold << std::endl << std::endl;
337 std::cout <<
"##### Calculation of PWL RAP MUSIC completed ######"<< std::endl << std::endl << std::endl;
341 float t_fElapsedTime = ( (float)(end-start) / (float)CLOCKS_PER_SEC ) * 1000.0f;
342 std::cout <<
"Total Time Elapsed: " << t_fElapsedTime <<
" ms" << std::endl << std::endl;
347 return p_SourceEstimate;
355 return p_iRow*p_iNumPoints - (( (p_iRow-1)*p_iRow) / 2);
369 for(
int i = 0; i <= p_iRow; ++i)
374 int length = p_iNumPoints - p_iRow;
376 for(
int i = p_iRow; i < p_iRow+length; ++i)
378 p_pVecElements(i) = off+k;
PwlRapMusic algorithm class declaration.
Core MNE data structures (source spaces, source estimates, hemispheres).
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
Pair of correlated dipole indices and orientations found by the RAP MUSIC scanning step.
virtual const char * getName() const
static void PowellIdxVec(int p_iRow, int p_iNumPoints, Eigen::VectorXi &p_pVecElements)
virtual MNELIB::MNESourceEstimate calculateInverse(const FIFFLIB::FiffEvoked &p_fiffEvoked, bool pick_normal=false)
static int PowellOffset(int p_iRow, int p_iNumPoints)
static double subcorr(MatrixX6T &p_matProj_G, const MatrixXT &p_pMatU_B)
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorXT
Eigen::Matrix< double, Eigen::Dynamic, 6 > MatrixX6T
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
int m_iNumLeadFieldCombinations
static void insertSource(int p_iDipoleIdx1, int p_iDipoleIdx2, const Vector6T &p_vec_phi_k_1, double p_valCor, QList< DipolePair< double > > &p_RapDipoles)
void calcOrthProj(const MatrixXT &p_matA_k_1, MatrixXT &p_matOrthProj) const
Pair ** m_ppPairIdxCombinations
virtual MNELIB::MNESourceEstimate calculateInverse(const FIFFLIB::FiffEvoked &p_fiffEvoked, bool pick_normal=false)
static int useFullRank(const MatrixXT &p_Mat, const MatrixXT &p_matSigma_src, MatrixXT &p_matFull_Rank, int type=NOT_TRANSPOSED)
MNELIB::MNEForwardSolution m_ForwardSolution
static void getGainMatrixPair(const MatrixXT &p_matGainMarix, MatrixX6T &p_matGainMarix_Pair, int p_iIdx1, int p_iIdx2)
int calcPhi_s(const MatrixXT &p_matMeasurement, MatrixXT *&p_pMatPhi_s) const
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)