Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

gabrielbmotta
Copy link
Collaborator

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

codecov bot commented Oct 24, 2022

Codecov Report

Merging #901 (3d0ec9e) into main (bd31738) will increase coverage by 5.98%.
The diff coverage is 0.70%.

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     
Impacted Files Coverage Δ
libraries/disp/viewers/helpers/scalecontrol.h 0.00% <ø> (ø)
libraries/inverse/hpiFit/hpifit.h 0.00% <ø> (-60.00%) ⬇️
libraries/inverse/hpiFit/hpimodelparameters.h 0.00% <0.00%> (ø)
libraries/inverse/hpiFit/sensorset.h 0.00% <0.00%> (ø)
libraries/inverse/hpiFit/signalmodel.h 0.00% <0.00%> (ø)
libraries/mne/mne_forwardsolution.h 100.00% <ø> (+88.23%) ⬆️
libraries/mne/mne_sourceestimate.h 0.00% <ø> (ø)
libraries/rtprocessing/rthpis.cpp 1.78% <0.00%> (-0.07%) ⬇️
libraries/rtprocessing/rthpis.h 0.00% <ø> (ø)
libraries/utils/file.cpp 0.00% <ø> (ø)
... and 294 more

Copy link
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
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
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
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
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
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
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
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
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
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
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.

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.

2 participants