Skip to content

MRG+1: Unit-gain LCMV beamformer - #6213

Merged
larsoner merged 13 commits into
mne-tools:masterfrom
britta-wstnr:fix_unitgain
Apr 26, 2019
Merged

larsoner merged 13 commits into
mne-tools:masterfrom
britta-wstnr:fix_unitgain

Conversation

@britta-wstnr

@britta-wstnr britta-wstnr commented Apr 24, 2019 •

Copy link
Copy Markdown
Member

This fixes the pseudo-inversion in the filter computation.
In the old code, the pinv had an arbitray cond=0.1 set. We already stumbled across this in the past several times (the code is from before we started the overhaul of the module). So far we kept it, since we had no good motivation to change it.
Now, I ran our beamformer against FieldTrip, and if I get rid of this threshold cond=0.1, the variance explained between the toolboxes for the beamformer output jumps from 0% to 100% and the output gets much more plausible than before.

After investigating this, I would consider the old code a bug.

Of course, we'd have to change the value ranges for the unit tests now ...

Thoughts? @larsoner @agramfort @wmvanvliet

Edit: I added the FieldTrip comparisons here as well - closes #6183

@wmvanvliet

Copy link
Copy Markdown
Contributor

+100 from me on this!

@agramfort agramfort changed the title [FIX] Unit-gain LCMV beamformer WIP [FIX] Unit-gain LCMV beamformer Apr 24, 2019
Comment thread mne/beamformer/tests/test_external.py Outdated
reject = dict(grad=4000e-13, mag=4e-12)

# where FieldTrip data should be saved to / imported from
ft_data_path = ' '

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@larsoner where should the data live?

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.

I would make it MNE-testing-data/fieldtrip/*

Comment thread mne/beamformer/tests/test_external.py Outdated
assert pearson[0, 1] >= 0.99


test_lcmv_fieldtrip()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is it right that this needs to be changed in run_tests_if_main() ? Do I have to add the test somewhere for it to work?

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.

Don't call the test manually, let pytest mne/... do it. run_tests_if_main() in theory should do this if you run the file as a script but in practice this mode is currently broken for many tests. So feel free to add run_tests_if_main to the bottom for future compat

@codecov

codecov Bot commented Apr 25, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #6213 into master will increase coverage by 1.79%.
The diff coverage is 90.17%.

@@            Coverage Diff             @@
##           master    #6213      +/-   ##
==========================================
+ Coverage   87.28%   89.08%   +1.79%     
==========================================
  Files         413      414       +1     
  Lines       74503    74604     +101     
  Branches    12296    12318      +22     
==========================================
+ Hits        65030    66460    +1430     
+ Misses       6600     5247    -1353     
- Partials     2873     2897      +24

Comment thread mne/beamformer/tests/test_external.py Resolved
@larsoner

Copy link
Copy Markdown
Member

I'll push a commit to fix the tests unless you're working on it now

@britta-wstnr

Copy link
Copy Markdown
Member Author

Thanks for the tests, @larsoner ! Just fixed the beamformer name in whats_new.
Do you want to have a look, @wmvanvliet ?

@larsoner

Copy link
Copy Markdown
Member

@britta-wstnr don't worry about changing the conditional for dics here regarding weight_norm=None, inversion='matrix' in tests here, I looked and I think it's already mostly doing that.

@britta-wstnr

Copy link
Copy Markdown
Member Author

I also made sure now that the ill-defined combination weight_norm='unit-noise-gain', normalize_fwd=True, inversion='single' throws an error, prompting the user to drop the forward normalization.
That involved fixing some tests, but I only added normalize_fwd=True, no assertion values were changed.
I also added a test for the error message.

@larsoner

Copy link
Copy Markdown
Member

Good to go from your end?

The renaming of normalize_fwd should be a subsequent PR

@larsoner larsoner changed the title WIP [FIX] Unit-gain LCMV beamformer MRG: Unit-gain LCMV beamformer Apr 26, 2019
@larsoner

Copy link
Copy Markdown
Member

Ahh I saw the change at the project end, so have retitled accordingly

@larsoner larsoner left a comment

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.

LGTM +1 for merge

@larsoner larsoner changed the title MRG: Unit-gain LCMV beamformer MRG+1: Unit-gain LCMV beamformer Apr 26, 2019
@britta-wstnr

Copy link
Copy Markdown
Member Author

Yes, I think I am done here, let's hope we come back green!

@wmvanvliet

Copy link
Copy Markdown
Contributor

MEG+1 from me.

@larsoner
larsoner merged commit 39ae853 into mne-tools:master Apr 26, 2019
@larsoner

Copy link
Copy Markdown
Member

Thanks @britta-wstnr !

jeythekey pushed a commit to jeythekey/mne-python that referenced this pull request Apr 27, 2019
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.

MAINT: Beamformer comparisons

3 participants