From 647c4877d5f86a7d931ec0947d25a2ebf1cb8d2c Mon Sep 17 00:00:00 2001 From: juangpc Date: Tue, 5 Oct 2021 15:49:22 -0400 Subject: [PATCH 1/9] fix leak test corregistration --- testframes/test_coregistration/test_coregistration.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/testframes/test_coregistration/test_coregistration.cpp b/testframes/test_coregistration/test_coregistration.cpp index de5107dab01..57d3c67a1c1 100644 --- a/testframes/test_coregistration/test_coregistration.cpp +++ b/testframes/test_coregistration/test_coregistration.cpp @@ -97,7 +97,6 @@ private slots: private: // declare your thresholds, variables and error values here - double dEpsilon; FiffCoordTrans transFitMatched; FiffCoordTrans transPerformICP; FiffCoordTrans transFitMatchedRef; @@ -107,7 +106,6 @@ private slots: //============================================================================================================= TestCoregistration::TestCoregistration() - : dEpsilon(0.000001) { } @@ -173,7 +171,7 @@ void TestCoregistration::initTestCase() fiff_int_t iFrom = digSetSrc[0].coord_frame; fiff_int_t iTo = bemSurface.data()->coord_frame; transFitMatched = FiffCoordTrans::make(iFrom, iTo, matTrans); - transPerformICP = *new FiffCoordTrans(transFitMatched); + transPerformICP = FiffCoordTrans(transFitMatched); // Prepare Icp: VectorXf vecWeightsICP(digSetHsp.size()); // Weigths vector From 0dfa36bab669958bc80fd946fe446d8785ca8c13 Mon Sep 17 00:00:00 2001 From: juangpc Date: Tue, 5 Oct 2021 15:54:12 -0400 Subject: [PATCH 2/9] fix fitMatchedPoints value fscale not being used --- .../mne_analyze/plugins/coregistration/coregistration.cpp | 2 +- examples/ex_coreg/main.cpp | 2 +- libraries/rtprocessing/icp.cpp | 3 +-- testframes/test_coregistration/test_coregistration.cpp | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/applications/mne_analyze/plugins/coregistration/coregistration.cpp b/applications/mne_analyze/plugins/coregistration/coregistration.cpp index 792415dd7c0..85c0dacc006 100644 --- a/applications/mne_analyze/plugins/coregistration/coregistration.cpp +++ b/applications/mne_analyze/plugins/coregistration/coregistration.cpp @@ -445,7 +445,7 @@ void CoRegistration::onFitFiducials() Matrix3f matMri(digSetFidMRI.size(),3); Matrix4f matTrans; Vector3f vecWeights; // LPA, Nasion, RPA - float fScale = 0.0; + float fScale = 1.0f; // get coordinates for(int i = 0; i< digSetFidHead.size(); ++i) { diff --git a/examples/ex_coreg/main.cpp b/examples/ex_coreg/main.cpp index 82fea966fe8..00b1b7bff6e 100644 --- a/examples/ex_coreg/main.cpp +++ b/examples/ex_coreg/main.cpp @@ -163,7 +163,7 @@ int main(int argc, char *argv[]) Matrix3f matDst(digSetDst.size(),3); Matrix4f matTrans; Vector3f vecWeights(digSetSrc.size()); // LPA, Nasion, RPA - float fScale; + float fScale = 1.0f; // get coordinates for(int i = 0; i< digSetSrc.size(); ++i) { diff --git a/libraries/rtprocessing/icp.cpp b/libraries/rtprocessing/icp.cpp index 1be4bf932cf..c4e2a22d035 100644 --- a/libraries/rtprocessing/icp.cpp +++ b/libraries/rtprocessing/icp.cpp @@ -93,7 +93,7 @@ bool RTPROCESSINGLIB::performIcp(const MNEProjectToSurface::SPtr mneSurfacePoint // Initialization int iNP = matPointCloud.rows(); // The number of points float fMSEPrev,fMSE = 0.0; // The mean square error - float fScale = 1.0; + float fScale = 1.0f; MatrixXf matP0 = matPointCloud; // Initial Set of points MatrixXf matPk = matP0; // Transformed Set of points MatrixXf matYk(matPk.rows(),matPk.cols()); // Iterative closest points on the surface @@ -175,7 +175,6 @@ bool RTPROCESSINGLIB::fitMatchedPoints(const MatrixXf& matSrcPoint, Matrix3f matRot = Matrix3f::Identity(3,3); Vector3f vecTrans; float fTrace = 0.0; - fScale = 1.0; // test size of point clouds if(matSrcPoint.size() != matDstPoint.size()) { diff --git a/testframes/test_coregistration/test_coregistration.cpp b/testframes/test_coregistration/test_coregistration.cpp index 57d3c67a1c1..1c603f5e3e9 100644 --- a/testframes/test_coregistration/test_coregistration.cpp +++ b/testframes/test_coregistration/test_coregistration.cpp @@ -147,7 +147,7 @@ void TestCoregistration::initTestCase() Matrix3f matDst(digSetDst.size(),3); Matrix4f matTrans; Vector3f vecWeights(digSetSrc.size()); // LPA, Nasion, RPA - float fScale; + float fScale = 1.0f; bool bScale = true; // get coordinates From 49aa000ed4d6bfe5f2cfb4511766ad897ca76d65 Mon Sep 17 00:00:00 2001 From: juangpc Date: Tue, 5 Oct 2021 16:03:49 -0400 Subject: [PATCH 3/9] delete unused epsilon variable --- .../test_mne_msh_display_surface_set.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/testframes/test_mne_msh_display_surface_set/test_mne_msh_display_surface_set.cpp b/testframes/test_mne_msh_display_surface_set/test_mne_msh_display_surface_set.cpp index 0dbc20412fa..abf28342b3d 100644 --- a/testframes/test_mne_msh_display_surface_set/test_mne_msh_display_surface_set.cpp +++ b/testframes/test_mne_msh_display_surface_set/test_mne_msh_display_surface_set.cpp @@ -79,15 +79,12 @@ private slots: void cleanupTestCase(); private: - double dEpsilon; - MneMshDisplaySurfaceSet::SPtr m_pSurfSetBemLoaded; }; //============================================================================================================= TestMneMshDisplaySurfaceSet::TestMneMshDisplaySurfaceSet() -: dEpsilon(0.000001) { } From 787b0679bea3c7f53537f984f24c69720af483f9 Mon Sep 17 00:00:00 2001 From: juangpc Date: Tue, 5 Oct 2021 16:07:01 -0400 Subject: [PATCH 4/9] init variables before using them --- libraries/rtprocessing/icp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/rtprocessing/icp.cpp b/libraries/rtprocessing/icp.cpp index c4e2a22d035..54559c86161 100644 --- a/libraries/rtprocessing/icp.cpp +++ b/libraries/rtprocessing/icp.cpp @@ -92,7 +92,8 @@ bool RTPROCESSINGLIB::performIcp(const MNEProjectToSurface::SPtr mneSurfacePoint // Initialization int iNP = matPointCloud.rows(); // The number of points - float fMSEPrev,fMSE = 0.0; // The mean square error + float fMSEPrev = 0.0f; // The mean square error of previous iteration. + float fMSE = 0.0f; // The mean square error float fScale = 1.0f; MatrixXf matP0 = matPointCloud; // Initial Set of points MatrixXf matPk = matP0; // Transformed Set of points From 683501b90ff209563bfe0446deb2f2da989f7fe2 Mon Sep 17 00:00:00 2001 From: juangpc Date: Tue, 5 Oct 2021 16:08:16 -0400 Subject: [PATCH 5/9] fix unused variable --- examples/ex_coreg/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ex_coreg/main.cpp b/examples/ex_coreg/main.cpp index 00b1b7bff6e..ba60ac1843e 100644 --- a/examples/ex_coreg/main.cpp +++ b/examples/ex_coreg/main.cpp @@ -227,7 +227,7 @@ int main(int argc, char *argv[]) AbstractView::SPtr p3DAbstractView = AbstractView::SPtr(new AbstractView()); Data3DTreeModel::SPtr p3DDataModel = p3DAbstractView->getTreeModel(); DigitizerSetTreeItem* pDigSrcSetTreeItem = p3DDataModel->addDigitizerData("Sample", "Fiducials Transformed", digSetSrc); - DigitizerSetTreeItem* pDigHspSetTreeItem = p3DDataModel->addDigitizerData("Sample", "Digitizer", digSetHsp); +// DigitizerSetTreeItem* pDigHspSetTreeItem = p3DDataModel->addDigitizerData("Sample", "Digitizer", digSetHsp); pDigSrcSetTreeItem->setTransform(transHeadMri,true); BemTreeItem* pBemItem = p3DDataModel->addBemData("Sample", "Head", bemHead); From bdf285482b7f87b03ae86fcc0082ac9cb02f74b0 Mon Sep 17 00:00:00 2001 From: juangpc Date: Tue, 5 Oct 2021 16:31:00 -0400 Subject: [PATCH 6/9] fix warnings --- .../mne_analyze/libs/anShared/Model/eventmodel.cpp | 4 ++-- examples/ex_averaging/main.cpp | 2 +- examples/ex_connectivity_comparison/main.cpp | 2 +- examples/ex_connectivity_performance/main.cpp | 3 +++ .../main.cpp | 12 ++++++------ .../ex_st_clustered_inverse_pwl_rap_music/main.cpp | 12 ++++++------ libraries/disp3D/engine/view/view3D.cpp | 2 +- libraries/inverse/hpiFit/hpifit.cpp | 5 +++++ libraries/mne/mne.cpp | 1 - libraries/mne/mne_forwardsolution.cpp | 12 ++++++------ libraries/mne/mne_forwardsolution.h | 14 +++++++++++--- libraries/mne/mne_inverse_operator.cpp | 2 +- testframes/test_filtering/test_filtering.cpp | 2 +- testframes/test_geometryinfo/test_geometryinfo.cpp | 4 ++-- testframes/test_hpiFit/test_hpiFit.cpp | 6 ++++-- .../test_interpolation/test_interpolation.cpp | 2 +- 16 files changed, 51 insertions(+), 34 deletions(-) diff --git a/applications/mne_analyze/libs/anShared/Model/eventmodel.cpp b/applications/mne_analyze/libs/anShared/Model/eventmodel.cpp index 6225352f34a..58016008457 100644 --- a/applications/mne_analyze/libs/anShared/Model/eventmodel.cpp +++ b/applications/mne_analyze/libs/anShared/Model/eventmodel.cpp @@ -175,7 +175,7 @@ void EventModel::setSamplePos(int iSamplePos) int EventModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); - return m_EventManager.getEventsInGroups(m_selectedEventGroups)->size(); + return static_cast(m_EventManager.getEventsInGroups(m_selectedEventGroups)->size()); } //============================================================================================================= @@ -628,7 +628,7 @@ std::unique_ptr > EventModel::getEventsToDisplay(i void EventModel::eventsUpdated() { emit dataChanged(createIndex(0,0), createIndex(rowCount(), columnCount())); - emit headerDataChanged(Qt::Vertical, 0, m_EventManager.getAllEvents()->size()); + emit headerDataChanged(Qt::Vertical, 0, static_cast(m_EventManager.getAllEvents()->size())); } //============================================================================================================= diff --git a/examples/ex_averaging/main.cpp b/examples/ex_averaging/main.cpp index 490e8156d0f..aa6cf8c51e5 100644 --- a/examples/ex_averaging/main.cpp +++ b/examples/ex_averaging/main.cpp @@ -171,7 +171,7 @@ int main(int argc, char *argv[]) fTMin, fTMax, event, - -1.0f, + true, -1.0f, true, mapReject, diff --git a/examples/ex_connectivity_comparison/main.cpp b/examples/ex_connectivity_comparison/main.cpp index 2049e556098..4015288df18 100644 --- a/examples/ex_connectivity_comparison/main.cpp +++ b/examples/ex_connectivity_comparison/main.cpp @@ -383,7 +383,7 @@ int main(int argc, char *argv[]) lNetworks); for(int j = 0; j < lNetworkTreeItems.size(); ++j) { - lNetworkTreeItems.at(j)->setThresholds(QVector3D(0.9,0.95,1.0)); + lNetworkTreeItems.at(j)->setThresholds(QVector3D(0.9f, 0.95f, 1.0f)); } //Read and show sensor helmets diff --git a/examples/ex_connectivity_performance/main.cpp b/examples/ex_connectivity_performance/main.cpp index 1f235907ee3..0a7e07c3756 100644 --- a/examples/ex_connectivity_performance/main.cpp +++ b/examples/ex_connectivity_performance/main.cpp @@ -133,6 +133,9 @@ void customMessageHandler(QtMsgType type, const QMessageLogContext &context, con */ int main(int argc, char *argv[]) { + Q_UNUSED(argc); + Q_UNUSED(argv); + #ifdef STATICBUILD Q_INIT_RESOURCE(disp3d); #endif diff --git a/examples/ex_roi_clustered_inverse_pwl_rap_music/main.cpp b/examples/ex_roi_clustered_inverse_pwl_rap_music/main.cpp index 82f02405d1d..83aae71215e 100644 --- a/examples/ex_roi_clustered_inverse_pwl_rap_music/main.cpp +++ b/examples/ex_roi_clustered_inverse_pwl_rap_music/main.cpp @@ -384,12 +384,12 @@ int main(int argc, char *argv[]) p3DDataModel->addSurfaceSet(parser.value(subjectOption), "HemiLRSet", t_surfSet, t_annotationSet); - MneDataTreeItem* pRTDataItem = p3DDataModel->addSourceData(parser.value(subjectOption), - "HemiLRSet", - sourceEstimate, - t_clusteredFwd, - t_surfSet, - t_annotationSet); +// MneDataTreeItem* pRTDataItem = p3DDataModel->addSourceData(parser.value(subjectOption), +// "HemiLRSet", +// sourceEstimate, +// t_clusteredFwd, +// t_surfSet, +// t_annotationSet); p3DAbstractView->show(); diff --git a/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp b/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp index 2bb195a2595..3f75399392f 100644 --- a/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp +++ b/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp @@ -370,12 +370,12 @@ int main(int argc, char *argv[]) p3DDataModel->addSurfaceSet(parser.value(subjectOption), "HemiLRSet", t_surfSet, t_annotationSet); - MneDataTreeItem* pRTDataItem = p3DDataModel->addSourceData(parser.value(subjectOption), - "HemiLRSet", - sourceEstimate, - t_clusteredFwd, - t_surfSet, - t_annotationSet); +// MneDataTreeItem* pRTDataItem = p3DDataModel->addSourceData(parser.value(subjectOption), +// "HemiLRSet", +// sourceEstimate, +// t_clusteredFwd, +// t_surfSet, +// t_annotationSet); p3DAbstractView->show(); diff --git a/libraries/disp3D/engine/view/view3D.cpp b/libraries/disp3D/engine/view/view3D.cpp index 29cf697adba..7d1fed68050 100644 --- a/libraries/disp3D/engine/view/view3D.cpp +++ b/libraries/disp3D/engine/view/view3D.cpp @@ -494,7 +494,7 @@ void View3D::initMultiView() updateMultiViewAspectRatio(); - auto noDraw = new Qt3DRender::QNoDraw(clearBuffers); +// auto noDraw = new Qt3DRender::QNoDraw(clearBuffers); } //============================================================================================================= diff --git a/libraries/inverse/hpiFit/hpifit.cpp b/libraries/inverse/hpiFit/hpifit.cpp index cacfc3837db..ee05c1ed064 100644 --- a/libraries/inverse/hpiFit/hpifit.cpp +++ b/libraries/inverse/hpiFit/hpifit.cpp @@ -112,6 +112,11 @@ void HPIFit::fitHPI(const MatrixXd& t_mat, int iMaxIterations, float fAbortError) { + if(bDoDebug) + { + std::cout << "Debug mode ON\n"; + } + //Check if data was passed if(t_mat.rows() == 0 || t_mat.cols() == 0 ) { std::cout<(label_ids.rows()), curr_name.toUtf8().constData()); // // Get source space indeces @@ -875,7 +875,7 @@ FiffCov MNEForwardSolution::compute_depth_prior(const MatrixXd &Gain, const Fiff } } - printf("\tlimit = %d/%ld = %f", n_limit + 1, d.size(), sqrt(limit / ws[0])); + printf("\tlimit = %d/%ld = %f", n_limit + 1, static_cast(d.size()), sqrt(limit / ws[0])); double scale = 1.0 / limit; printf("\tscale = %g exp = %g", scale, exp); @@ -1773,7 +1773,7 @@ void MNEForwardSolution::restrict_gain_matrix(MatrixXd &G, const FiffInfo &info) // Figure out which ones have been used if(info.chs.size() != G.rows()) { - printf("Error G.rows() and length of info.chs do not match: %ld != %i", G.rows(), info.chs.size()); //ToDo throw + printf("Error G.rows() and length of info.chs do not match: %ld != %i", static_cast(G.rows()), info.chs.size()); //ToDo throw return; } @@ -1783,7 +1783,7 @@ void MNEForwardSolution::restrict_gain_matrix(MatrixXd &G, const FiffInfo &info) for(qint32 i = 0; i < sel.size(); ++i) G.row(i) = G.row(sel[i]); G.conservativeResize(sel.size(), G.cols()); - printf("\t%ld planar channels", sel.size()); + printf("\t%ld planar channels", static_cast(sel.size())); } else { @@ -1793,7 +1793,7 @@ void MNEForwardSolution::restrict_gain_matrix(MatrixXd &G, const FiffInfo &info) for(qint32 i = 0; i < sel.size(); ++i) G.row(i) = G.row(sel[i]); G.conservativeResize(sel.size(), G.cols()); - printf("\t%ld magnetometer or axial gradiometer channels", sel.size()); + printf("\t%ld magnetometer or axial gradiometer channels", static_cast(sel.size())); } else { @@ -1803,7 +1803,7 @@ void MNEForwardSolution::restrict_gain_matrix(MatrixXd &G, const FiffInfo &info) for(qint32 i = 0; i < sel.size(); ++i) G.row(i) = G.row(sel[i]); G.conservativeResize(sel.size(), G.cols()); - printf("\t%ld EEG channels\n", sel.size()); + printf("\t%ld EEG channels\n", static_cast(sel.size())); } else printf("Could not find MEG or EEG channels\n"); diff --git a/libraries/mne/mne_forwardsolution.h b/libraries/mne/mne_forwardsolution.h index a6b7bd70b2d..c4d34e1c985 100644 --- a/libraries/mne/mne_forwardsolution.h +++ b/libraries/mne/mne_forwardsolution.h @@ -79,6 +79,16 @@ namespace MNELIB { +//============================================================================================================= +// DEFAULT VARIABLES DEFINITION +//============================================================================================================= + +namespace { + const FIFFLIB::FiffCov defaultCov; + const FIFFLIB::FiffInfo defaultInfo; + Eigen::MatrixXd defaultD; +} + //========================================================================================================= /** * Gain matrix output data for one region, used for clustering @@ -157,9 +167,7 @@ struct RegionData } }; -const static FIFFLIB::FiffCov defaultCov; -const static FIFFLIB::FiffInfo defaultInfo; -static Eigen::MatrixXd defaultD; + //============================================================================================================= /** diff --git a/libraries/mne/mne_inverse_operator.cpp b/libraries/mne/mne_inverse_operator.cpp index 269f1a60d9b..88e72c2492a 100644 --- a/libraries/mne/mne_inverse_operator.cpp +++ b/libraries/mne/mne_inverse_operator.cpp @@ -435,7 +435,7 @@ MatrixXd MNEInverseOperator::cluster_kernel(const AnnotationSet &p_AnnotationSet if (label_ids[i] != 0) { QString curr_name = t_CurrentColorTable.struct_names[i];//obj.label2AtlasName(label(i)); - printf("\tCluster %d / %ld %s...", i+1, label_ids.rows(), curr_name.toUtf8().constData()); + printf("\tCluster %d / %ld %s...", i+1, static_cast(label_ids.rows()), curr_name.toUtf8().constData()); // // Get source space indeces diff --git a/testframes/test_filtering/test_filtering.cpp b/testframes/test_filtering/test_filtering.cpp index e04e8d6529b..3542841b6af 100644 --- a/testframes/test_filtering/test_filtering.cpp +++ b/testframes/test_filtering/test_filtering.cpp @@ -149,7 +149,7 @@ void TestFiltering::initTestCase() fiff_int_t to = rawFirstInRaw.last_samp; // initialize filter settings - QString sFilterName = "example_cosine"; +// QString sFilterName = "example_cosine"; int type = FilterKernel::m_filterTypes.indexOf(FilterParameter("BPF")); double dSFreq = rawFirstInRaw.info.sfreq; double dCenterfreq = 10; diff --git a/testframes/test_geometryinfo/test_geometryinfo.cpp b/testframes/test_geometryinfo/test_geometryinfo.cpp index 26f18106af4..66f38de8b10 100644 --- a/testframes/test_geometryinfo/test_geometryinfo.cpp +++ b/testframes/test_geometryinfo/test_geometryinfo.cpp @@ -153,7 +153,7 @@ void TestGeometryInfo::testBadChannelFiltering() { return; } QVector vMegSensors; - for( const FiffChInfo &info : evoked.info.chs) { + for( const FiffChInfo &info : qAsConst(evoked.info.chs)) { if(info.kind == FIFFV_MEG_CH) { vMegSensors.push_back(info.chpos.r0); } @@ -166,7 +166,7 @@ void TestGeometryInfo::testBadChannelFiltering() { // filter for bad MEG channels: QVector vErasedColums = GeometryInfo::filterBadChannels(pDistanceMatrix, evoked.info, FIFFV_MEG_CH); - for (qint32 col : vErasedColums) { + for (qint32 col : qAsConst(vErasedColums)) { qint64 iNotInfCount = 0; for (qint32 row = 0; row < pDistanceMatrix->rows(); ++row) { if (pDistanceMatrix->coeff(row, col) != FLOAT_INFINITY) { diff --git a/testframes/test_hpiFit/test_hpiFit.cpp b/testframes/test_hpiFit/test_hpiFit.cpp index 21cba67c52b..2f35f6c4519 100644 --- a/testframes/test_hpiFit/test_hpiFit.cpp +++ b/testframes/test_hpiFit/test_hpiFit.cpp @@ -177,7 +177,6 @@ void TestHpiFit::initTestCase() FiffDigPointSet fittedPointSet; Eigen::MatrixXd mProjectors = Eigen::MatrixXd::Identity(pFiffInfo->chs.size(), pFiffInfo->chs.size()); QString sHPIResourceDir = QCoreApplication::applicationDirPath() + "/HPIFittingDebug"; - bool bDoDebug = true; HPIFit HPI = HPIFit(pFiffInfo, true); @@ -212,6 +211,9 @@ void TestHpiFit::initTestCase() } qInfo() << "HPI-Fit..."; + + bool bDoDebug = false; + HPI.fitHPI(mData, mProjectors, pFiffInfo->dev_head_t, @@ -220,7 +222,7 @@ void TestHpiFit::initTestCase() vGoF, fittedPointSet, pFiffInfo, - bDoDebug = 0, + bDoDebug, sHPIResourceDir, 200, 1e-5f); diff --git a/testframes/test_interpolation/test_interpolation.cpp b/testframes/test_interpolation/test_interpolation.cpp index 921e8ab136f..9a0762f877b 100644 --- a/testframes/test_interpolation/test_interpolation.cpp +++ b/testframes/test_interpolation/test_interpolation.cpp @@ -119,7 +119,7 @@ void TestInterpolation::initTestCase() if(evoked.isEmpty()) { return; } - for( const FiffChInfo &info : evoked.info.chs) { + for( const FiffChInfo &info : qAsConst(evoked.info.chs)) { if(info.kind == FIFFV_MEG_CH && info.unit == FIFF_UNIT_T) { vMegSensors.push_back(info.chpos.r0); } From f276bc596b2f887e6b9d2dff083e1281fedc17ac Mon Sep 17 00:00:00 2001 From: juangpc Date: Tue, 12 Oct 2021 23:04:00 -0400 Subject: [PATCH 7/9] dont use pod variables in library layer --- .../ex_clustered_inverse_mne_raw/main.cpp | 2 +- libraries/mne/mne_forwardsolution.cpp | 12 ++++++ libraries/mne/mne_forwardsolution.h | 37 ++++++++++--------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/examples/ex_clustered_inverse_mne_raw/main.cpp b/examples/ex_clustered_inverse_mne_raw/main.cpp index 318ba80bae1..a5818a1831d 100644 --- a/examples/ex_clustered_inverse_mne_raw/main.cpp +++ b/examples/ex_clustered_inverse_mne_raw/main.cpp @@ -493,7 +493,7 @@ int main(int argc, char *argv[]) // Cluster forward solution; // MatrixXd D; - MNEForwardSolution t_clusteredFwd = t_Fwd.cluster_forward_solution(t_annotationSet, 20, D, noise_cov, evoked.info); + MNEForwardSolution t_clusteredFwd = t_Fwd.cluster_forward_solution(t_annotationSet, 20, D, noise_cov, evoked.info, "citiblock"); // // make an inverse operators diff --git a/libraries/mne/mne_forwardsolution.cpp b/libraries/mne/mne_forwardsolution.cpp index 8a4a2210cc5..69187cc3956 100644 --- a/libraries/mne/mne_forwardsolution.cpp +++ b/libraries/mne/mne_forwardsolution.cpp @@ -160,6 +160,18 @@ void MNEForwardSolution::clear() //============================================================================================================= +MNEForwardSolution MNEForwardSolution::cluster_forward_solution(const AnnotationSet &p_AnnotationSet, + qint32 p_iClusterSize) const +{ + const FIFFLIB::FiffCov p_pNoise_cov; + const FIFFLIB::FiffInfo p_pInfo; + Eigen::MatrixXd p_D; + + return cluster_forward_solution(p_AnnotationSet, p_iClusterSize, p_D, p_pNoise_cov, p_pInfo, "cityblock"); +} + +//============================================================================================================= + MNEForwardSolution MNEForwardSolution::cluster_forward_solution(const AnnotationSet &p_AnnotationSet, qint32 p_iClusterSize, MatrixXd& p_D, diff --git a/libraries/mne/mne_forwardsolution.h b/libraries/mne/mne_forwardsolution.h index c4d34e1c985..026b04a21a0 100644 --- a/libraries/mne/mne_forwardsolution.h +++ b/libraries/mne/mne_forwardsolution.h @@ -79,16 +79,6 @@ namespace MNELIB { -//============================================================================================================= -// DEFAULT VARIABLES DEFINITION -//============================================================================================================= - -namespace { - const FIFFLIB::FiffCov defaultCov; - const FIFFLIB::FiffInfo defaultInfo; - Eigen::MatrixXd defaultD; -} - //========================================================================================================= /** * Gain matrix output data for one region, used for clustering @@ -233,19 +223,32 @@ class MNESHARED_EXPORT MNEForwardSolution * * @param[in] p_AnnotationSet Annotation set containing the annotation of left & right hemisphere. * @param[in] p_iClusterSize Maximal cluster size per roi. - * @param[out] p_D The cluster operator. - * @param[in] p_pNoise_cov. - * @param[in] p_pInfo. + * @param[out] p_D The cluster operator. + * @param[in] p_pNoise_cov + * @param[in] p_pInfo * @param[in] p_sMethod "cityblock" or "sqeuclidean". * * @return clustered MNE forward solution. */ MNEForwardSolution cluster_forward_solution(const FSLIB::AnnotationSet &p_AnnotationSet, qint32 p_iClusterSize, - Eigen::MatrixXd& p_D = defaultD, - const FIFFLIB::FiffCov &p_pNoise_cov = defaultCov, - const FIFFLIB::FiffInfo &p_pInfo = defaultInfo, - QString p_sMethod = "cityblock") const; + Eigen::MatrixXd& p_D, + const FIFFLIB::FiffCov &p_pNoise_cov, + const FIFFLIB::FiffInfo &p_pInfo, + QString p_sMethod) const; + + //========================================================================================================= + /** + * Cluster the forward solution and stores the result to p_fwdOut. + * The clustering is done by using the provided annotations + * + * @param[in] p_AnnotationSet Annotation set containing the annotation of left & right hemisphere. + * @param[in] p_iClusterSize Maximal cluster size per roi. + * + * @return clustered MNE forward solution. + */ + MNEForwardSolution cluster_forward_solution(const FSLIB::AnnotationSet &p_AnnotationSet, + qint32 p_iClusterSize) const; //========================================================================================================= /** From 4e25e630bb88e34597f5966f2102def408eed6bf Mon Sep 17 00:00:00 2001 From: juangpc Date: Tue, 12 Oct 2021 23:15:32 -0400 Subject: [PATCH 8/9] uncomment probably unneeded code, but who knows --- .../ex_st_clustered_inverse_pwl_rap_music/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp b/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp index 3f75399392f..5bcbd76117a 100644 --- a/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp +++ b/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp @@ -370,12 +370,12 @@ int main(int argc, char *argv[]) p3DDataModel->addSurfaceSet(parser.value(subjectOption), "HemiLRSet", t_surfSet, t_annotationSet); -// MneDataTreeItem* pRTDataItem = p3DDataModel->addSourceData(parser.value(subjectOption), -// "HemiLRSet", -// sourceEstimate, -// t_clusteredFwd, -// t_surfSet, -// t_annotationSet); + p3DDataModel->addSourceData(parser.value(subjectOption), + "HemiLRSet", + sourceEstimate, + t_clusteredFwd, + t_surfSet, + t_annotationSet); p3DAbstractView->show(); From d118b7c9c3641a1e16d01d4c6a6604fd7400753f Mon Sep 17 00:00:00 2001 From: juangpc Date: Mon, 25 Oct 2021 14:46:35 -0400 Subject: [PATCH 9/9] improve formatting --- .../ex_st_clustered_inverse_pwl_rap_music/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp b/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp index 5bcbd76117a..31d99a9ffc9 100644 --- a/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp +++ b/examples/ex_st_clustered_inverse_pwl_rap_music/main.cpp @@ -371,11 +371,11 @@ int main(int argc, char *argv[]) p3DDataModel->addSurfaceSet(parser.value(subjectOption), "HemiLRSet", t_surfSet, t_annotationSet); p3DDataModel->addSourceData(parser.value(subjectOption), - "HemiLRSet", - sourceEstimate, - t_clusteredFwd, - t_surfSet, - t_annotationSet); + "HemiLRSet", + sourceEstimate, + t_clusteredFwd, + t_surfSet, + t_annotationSet); p3DAbstractView->show();