MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
sphara.cpp
Go to the documentation of this file.
1//=============================================================================================================
36//=============================================================================================================
37// INCLUDES
38//=============================================================================================================
39
40#include "sphara.h"
41
42//=============================================================================================================
43// QT INCLUDES
44//=============================================================================================================
45
46#include <QDebug>
47
48//=============================================================================================================
49// USED NAMESPACES
50//=============================================================================================================
51
52using namespace RTPROCESSINGLIB;
53using namespace Eigen;
54
55//=============================================================================================================
56// DEFINE GLOBAL RTPROCESSINGLIB METHODS
57//=============================================================================================================
58
59MatrixXd RTPROCESSINGLIB::makeSpharaProjector(const MatrixXd& matBaseFct,
60 const VectorXi& vecIndices,
61 int iOperatorDim,
62 int iNBaseFct,
63 int iSkip)
64{
65 MatrixXd matSpharaOperator = MatrixXd::Identity(iOperatorDim, iOperatorDim);
66
67 if(matBaseFct.size() == 0) {
68 qWarning()<<"[RTPROCESSINGLIB::makeSpharaProjector] Basis function matrix was empty. Returning identity matrix instead.";
69 return matSpharaOperator;
70 }
71
72 //Remove unwanted base functions
73 MatrixXd matSpharaGradCut = matBaseFct.block(0,0,matBaseFct.rows(),iNBaseFct);
74 MatrixXd matSpharaMultGrad = matSpharaGradCut * matSpharaGradCut.transpose().eval();
75
76 //Create the SPHARA operator
77 int rowIndex = 0;
78 int colIndex = 0;
79
80 for(int i = 0; i<=iSkip; i++) {
81 for(int r = i; r<vecIndices.rows(); r+=1+iSkip) {
82 for(int c = i; c<vecIndices.rows(); c+=1+iSkip) {
83 if((r < vecIndices.rows() || c < vecIndices.rows()) && (rowIndex < matSpharaMultGrad.rows() || colIndex < matSpharaMultGrad.cols())) {
84 matSpharaOperator(vecIndices(r),vecIndices(c)) = matSpharaMultGrad(rowIndex,colIndex);
85 } else {
86 qWarning()<<"RTPROCESSINGLIB::makeSpharaProjector - Index is out of range. Returning identity matrix.";
87 //matSpharaOperator.setZero();
88 matSpharaOperator = MatrixXd::Identity(iOperatorDim, iOperatorDim);
89 return matSpharaOperator;
90 }
91
92 ++colIndex;
93 }
94
95 colIndex = 0;
96 ++rowIndex;
97 }
98
99 rowIndex = 0;
100 }
101
102 return matSpharaOperator;
103}
104
Declaration of the Sphara class.
RTPROCESINGSHARED_EXPORT Eigen::MatrixXd makeSpharaProjector(const Eigen::MatrixXd &matBaseFct, const Eigen::VectorXi &vecIndices, int iOperatorDim, int iNBaseFct, int iSkip=0)