Skip to content

[WIP] ENH,MAINT: Porting MNE Scan source plugins to MNE Analyze#901

Closed
gabrielbmotta wants to merge 17 commits intomne-tools:mainfrom
gabrielbmotta:source_loc
Closed

[WIP] ENH,MAINT: Porting MNE Scan source plugins to MNE Analyze#901
gabrielbmotta wants to merge 17 commits intomne-tools:mainfrom
gabrielbmotta:source_loc

Conversation

@gabrielbmotta
Copy link
Copy Markdown
Contributor

Porting:

  • Forward Solution plugin
  • Source Localization Plugin
    • single trial
    • [WIP] avg

Adding MNE Analyze Data Models:

  • Fwd Solution
  • Source Localization

Display:

  • [WIP] 3d source loc display

Debugging:

  • [WIP] Debug MNE Analyze
  • [WIP] Verify view changes still working in MNE Scan

@gabrielbmotta gabrielbmotta changed the title [WIP] ENH,MAINT: Porting MNE Scan source plguins to MNE Analyze [WIP] ENH,MAINT: Porting MNE Scan source plugins to MNE Analyze Oct 24, 2022
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 24, 2022

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 36.18%. Comparing base (bd31738) to head (3d0ec9e).
⚠️ Report is 858 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #901      +/-   ##
==========================================
+ Coverage   30.20%   36.18%   +5.98%     
==========================================
  Files         452      198     -254     
  Lines       39208    11812   -27396     
==========================================
- Hits        11841     4274    -7567     
+ Misses      27367     7538   -19829     
Files with missing lines Coverage Δ
libraries/mne/mne_forwardsolution.h 100.00% <ø> (+88.23%) ⬆️
libraries/mne/mne_sourceestimate.h 0.00% <ø> (ø)

... and 282 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@LorenzE LorenzE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor comments :)

/**
* ForwardSolution Plugin
*
* @brief The forwardsolution class provides a plugin for computing averages.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong docu

MatrixXd matDataResized;
matDataResized.resize(iNumberChannels, data.cols());

for(int j = 0; j < iNumberChannels; ++j) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about using more range based loops?

for(const auto& chName: lChNamesInvOp)
   matDataResized.row(j) = data.row(lChNamesFiffInfo.indexOf(chName));

*
* @param[in] parent The parent index.
*/
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a general comment: In cases of classes which are final in their inheritance scheme, I would only keep the override keyword and remove the virtual keyword.

I do not think that ForwardSolutionModel will be used as a base class. Maybe consider marking the whole class as final.

, m_bBusy(false)
, m_bDoRecomputation(false)
, m_bDoClustering(true)
, m_bDoFwdComputation(false)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using in-class member initialisation instead of using the default constructor. The following core guideline is related. Your case does not 100% match the guideline example since you actually do something other than initialising members. Still I think it would make it more apparent to the reader of the class what the default values are.

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c45-dont-define-a-default-constructor-that-only-initializes-data-members-use-in-class-member-initializers-instead


//=============================================================================================================

void ForwardSolution::init()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to avoid two phase initialisation -> https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#nr5-dont-use-two-phase-initialization

I know I probably introduced this a long time ago ;)


void SourceLocalization::onModelRemoved(QSharedPointer<ANSHAREDLIB::AbstractModel> pRemovedModel)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q_UNUSED(pRemovedModel)

//=============================================================================================================

FIFFLIB::FiffCov SourceLocalization::estimateCovariance(const Eigen::MatrixXd& matData,
FIFFLIB::FiffInfo* info)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we maybe pass info as a const reference instead of a raw pointer?

computedCov.data = finalResult.matData;

QStringList exclude;
for(int i = 0; i<info->chs.size(); i++) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A range based loop would improve readability IMO

for(const auto& ch : info->chs) 
  if(ch.kind != FIFFV_MEG_CH && ch.kind != FIFFV_EEG_CH) {
    exclude << ch.ch_name;


void FwdSettingsView::showMeasFileDialog()
{
QString t_sFileName = QFileDialog::getOpenFileName(this,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t_sFileName can be const


void FwdSettingsView::showSourceFileDialog()
{
QString t_sFileName = QFileDialog::getOpenFileName(this,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be const. Check code below as well.

@chdinh chdinh closed this Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants