From 7e70d1d2cb3264323aa94b2ae9e1f685ae32e605 Mon Sep 17 00:00:00 2001 From: johaenns Date: Tue, 2 Apr 2024 10:01:45 +0200 Subject: [PATCH] adapted fwdsettingsview for adaptive clustering --- .../mne_scan/plugins/rtfwd/rtfwd.cpp | 4 ++- .../disp/viewers/formfiles/fwdsettingsview.ui | 27 +++++++++++++++++++ .../disp/viewers/fwdsettingsview.cpp | 3 +++ src/libraries/disp/viewers/fwdsettingsview.h | 16 +++++++++++ .../fwd/computeFwd/compute_fwd_settings.h | 1 + 5 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/applications/mne_scan/plugins/rtfwd/rtfwd.cpp b/src/applications/mne_scan/plugins/rtfwd/rtfwd.cpp index aa9ddf85461..2122644b287 100644 --- a/src/applications/mne_scan/plugins/rtfwd/rtfwd.cpp +++ b/src/applications/mne_scan/plugins/rtfwd/rtfwd.cpp @@ -105,6 +105,7 @@ RtFwd::RtFwd() m_pFwdSettings->include_eeg = true; m_pFwdSettings->accurate = true; m_pFwdSettings->mindist = 5.0f/1000.0f; + m_pFwdSettings->ncluster = 200; m_sAtlasDir = QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/subjects/sample/label"; } @@ -345,6 +346,7 @@ void RtFwd::onDoForwardComputation() { m_mutex.lock(); m_bDoFwdComputation = true; + // get value for number in cluster and set m_pFwdSettings->ncluster here m_mutex.unlock(); } @@ -513,7 +515,7 @@ void RtFwd::run() if(bDoClustering && bFwdReady) { emit statusInformationChanged(3); // clustering - pClusteredFwd = MNEForwardSolution::SPtr(new MNEForwardSolution(pFwdSolution->cluster_forward_solution(*m_pAnnotationSet.data(), 200))); + pClusteredFwd = MNEForwardSolution::SPtr(new MNEForwardSolution(pFwdSolution->cluster_forward_solution(*m_pAnnotationSet.data(), m_pFwdSettings->ncluster))); emit clusteringAvailable(pClusteredFwd->nsource); m_pRTFSOutput->measurementData()->setValue(pClusteredFwd); diff --git a/src/libraries/disp/viewers/formfiles/fwdsettingsview.ui b/src/libraries/disp/viewers/formfiles/fwdsettingsview.ui index bc044a84f2a..5a0bc2175a3 100644 --- a/src/libraries/disp/viewers/formfiles/fwdsettingsview.ui +++ b/src/libraries/disp/viewers/formfiles/fwdsettingsview.ui @@ -221,6 +221,33 @@ + + + + + + Desired number of clustered Sources + + + + + + + + 0 + 0 + + + + 20 + + + 1000 + + + + + diff --git a/src/libraries/disp/viewers/fwdsettingsview.cpp b/src/libraries/disp/viewers/fwdsettingsview.cpp index de6941ecc2b..5975ba5749a 100644 --- a/src/libraries/disp/viewers/fwdsettingsview.cpp +++ b/src/libraries/disp/viewers/fwdsettingsview.cpp @@ -37,6 +37,7 @@ //============================================================================================================= #include "fwdsettingsview.h" +#include "QtWidgets/qspinbox.h" #include "ui_fwdsettingsview.h" #include @@ -115,6 +116,8 @@ FwdSettingsView::FwdSettingsView(const QString& sSettingsPath, this, &FwdSettingsView::onClusteringStatusChanged); connect(m_pUi->m_qPushButton_ComputeForward, &QPushButton::clicked, this, &FwdSettingsView::doForwardComputation); + connect(m_pUi->m_spinBox_iNDipoleClustered, &QSpinBox::valueChanged, + this, &FwdSettingsView::clusterNumberChanged); // load settings loadSettings(); diff --git a/src/libraries/disp/viewers/fwdsettingsview.h b/src/libraries/disp/viewers/fwdsettingsview.h index 58468642f9a..ee574fd7ded 100644 --- a/src/libraries/disp/viewers/fwdsettingsview.h +++ b/src/libraries/disp/viewers/fwdsettingsview.h @@ -120,6 +120,14 @@ class DISPSHARED_EXPORT FwdSettingsView : public AbstractView */ bool getClusteringStatusChanged(); + //========================================================================================================= + /** + * Get status of cluster size spin box. + * + * @return Desired number of sources in clustered source space. + */ + int getClusterNumber(); + //========================================================================================================= /** * Shows atlas selection dialog @@ -235,6 +243,14 @@ class DISPSHARED_EXPORT FwdSettingsView : public AbstractView */ void doForwardComputation(); + //========================================================================================================= + /** + * Emit this signal whenever a forward computation is supposed to be triggered. + * + * @param[in] iNCluster Number of desired sources in the clustered source space. + */ + void clusterNumberChanged(int iNCluster); + }; //============================================================================================================= diff --git a/src/libraries/fwd/computeFwd/compute_fwd_settings.h b/src/libraries/fwd/computeFwd/compute_fwd_settings.h index c9c169e1e5c..3a30cbd23db 100644 --- a/src/libraries/fwd/computeFwd/compute_fwd_settings.h +++ b/src/libraries/fwd/computeFwd/compute_fwd_settings.h @@ -131,6 +131,7 @@ class FWDSHARED_EXPORT ComputeFwdSettings bool do_all; QStringList labels; /**< Compute the solution only for these labels. */ int nlabel; + int ncluster; /**< Number of sources desired in clustered solution. */ QString eeg_model_file; /**< File of EEG sphere model specifications. */ QString eeg_model_name; /**< Name of the EEG model to use. */