50 using namespace INVERSELIB;
51 using namespace MNELIB;
52 using namespace FIFFLIB;
66 :
RapMusic(p_pFwd, p_bSparsed, p_iN, p_dThr)
69 init(p_pFwd, p_bSparsed, p_iN, p_dThr);
74 PwlRapMusic::~PwlRapMusic()
82 return "Powell RAP MUSIC";
108 std::cout <<
"RAP MUSIC wasn't initialized!";
109 return p_SourceEstimate;
115 std::cout <<
"Lead Field channels do not fit to number of measurement channels!";
116 return p_SourceEstimate;
132 int t_r =
calcPhi_s(p_matMeasurement, t_pMatPhi_s);
134 int t_iMaxSearch =
m_iN < t_r ?
m_iN : t_r;
138 std::cout <<
"Warning: Rank " << t_r <<
" of the measurement data is smaller than the " <<
m_iN;
139 std::cout <<
" sources to find." << std::endl;
140 std::cout <<
" Searching now for " << t_iMaxSearch <<
" correlated sources.";
141 std::cout << std::endl << std::endl;
147 t_matOrthProj.setIdentity();
151 t_matA_k_1.setZero();
167 p_RapDipoles.clear();
169 std::cout <<
"##### Calculation of PWL RAP MUSIC started ######\n\n";
171 MatrixXT t_matProj_Phi_s(t_matOrthProj.rows(), t_pMatPhi_s->cols());
175 for(
int r = 0; r < t_iMaxSearch ; ++r)
177 t_matProj_Phi_s = t_matOrthProj*(*t_pMatPhi_s);
184 Eigen::JacobiSVD< MatrixXT > t_svdProj_Phi_S(t_matProj_Phi_s, Eigen::ComputeThinU);
186 useFullRank(t_svdProj_Phi_S.matrixU(), t_svdProj_Phi_S.singularValues().asDiagonal(), t_matU_B);
194 clock_t start_subcorr, end_subcorr;
195 start_subcorr = clock();
200 int t_iCurrentRow = 2;
205 int t_iMaxIdx_old = -1;
215 while(t_iMaxFound == 0)
220 #pragma omp parallel num_threads(m_iMaxNumThreads)
226 for(
int i = 0; i < t_iNumVecElements; i++)
228 int k = t_pVecIdxElements(i);
231 MatrixX6T t_matProj_G(t_matProj_LeadField.rows(),6);
260 VectorXT::Index t_iMaxIdx;
262 t_val_roh_k = t_vecRoh.maxCoeff(&t_iMaxIdx);
264 if((
int)t_iMaxIdx == t_iMaxIdx_old)
271 t_iMaxIdx_old = t_iMaxIdx;
278 if(t_iIdx1 == t_iCurrentRow)
279 t_iCurrentRow = t_iIdx2;
281 t_iCurrentRow = t_iIdx1;
287 end_subcorr = clock();
289 float t_fSubcorrElapsedTime = ( (float)(end_subcorr-start_subcorr) / (float)CLOCKS_PER_SEC ) * 1000.0f;
290 std::cout <<
"Time Elapsed: " << t_fSubcorrElapsedTime <<
" ms" << std::endl;
293 std::cout <<
"Iteration: " << r+1 <<
" of " << t_iMaxSearch
294 <<
"; Correlation: " << t_val_roh_k<<
"; Position (Idx+1): " << t_iIdx1+1 <<
" - " << t_iIdx2+1 <<
"\n\n";
300 MatrixX6T t_matProj_G_k_1(t_matOrthProj.rows(), t_matG_k_1.cols());
301 t_matProj_G_k_1 = t_matOrthProj * t_matG_k_1;
316 std::cout <<
"Searching stopped, last correlation " << t_val_roh_k;
317 std::cout <<
" is smaller then the given threshold " <<
m_dThreshold << std::endl << std::endl;
331 std::cout <<
"##### Calculation of PWL RAP MUSIC completed ######"<< std::endl << std::endl << std::endl;
335 float t_fElapsedTime = ( (float)(end-start) / (float)CLOCKS_PER_SEC ) * 1000.0f;
336 std::cout <<
"Total Time Elapsed: " << t_fElapsedTime <<
" ms" << std::endl << std::endl;
341 return p_SourceEstimate;
346 int PwlRapMusic::PowellOffset(
int p_iRow,
int p_iNumPoints)
349 return p_iRow*p_iNumPoints - (( (p_iRow-1)*p_iRow) / 2);
354 void PwlRapMusic::PowellIdxVec(
int p_iRow,
int p_iNumPoints, Eigen::VectorXi& p_pVecElements)
363 for(
int i = 0; i <= p_iRow; ++i)
364 p_pVecElements(i) = PwlRapMusic::PowellOffset(i+1,p_iNumPoints)-(p_iNumPoints-p_iRow);
367 int off = PwlRapMusic::PowellOffset(p_iRow,p_iNumPoints);
368 int length = p_iNumPoints - p_iRow;
370 for(
int i = p_iRow; i < p_iRow+length; ++i)
372 p_pVecElements(i) = off+
k;