Skip to content

Conversation

@wmvanvliet
Copy link
Contributor

@wmvanvliet wmvanvliet commented Sep 12, 2018

This fixes a bug in the LCMV beamformer code:

Fix weight normalization when pick_ori='normal', weight_norm='unit_noise_gain'. The existing implementation has a bug where the weights were first normalized to have unit length before picking the normal direction. Instead, the weights should be normalized to unit length after picking the orientation.

@wmvanvliet wmvanvliet added the BUG label Sep 12, 2018
@wmvanvliet
Copy link
Contributor Author

wmvanvliet commented Sep 12, 2018

Here is an overview of whether the old and new LCMV code produce the same output.

#5511 is the current PR
#5447 is the beamformer refactor PR

pick_ori weight_norm master = #5511 master = #5447 #5511 = #5447
None None True True True
None unit-noise-gain True True True
None nai NA NA NA
normal None True True True
normal unit-noise-gain True False False
normal nai NA NA NA
max-power None NA NA NA
max-power unit-noise-gain True True True
max-power nai True True True
vector None True True True
vector unit-noise-gain True True True
vector nai NA NA NA

@codecov
Copy link

codecov bot commented Sep 12, 2018

Codecov Report

Merging #5511 into master will increase coverage by 0.07%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #5511      +/-   ##
==========================================
+ Coverage   88.27%   88.35%   +0.07%     
==========================================
  Files         360      363       +3     
  Lines       66898    67665     +767     
  Branches    11320    11463     +143     
==========================================
+ Hits        59056    59784     +728     
- Misses       5020     5042      +22     
- Partials     2822     2839      +17

@wmvanvliet wmvanvliet changed the title Fix weight normalization for LCMV beamformer [MRG] Fix weight normalization for LCMV beamformer Sep 13, 2018
Copy link
Contributor

@massich massich left a comment

Choose a reason for hiding this comment

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

this PR changes a condition, where there's no test for both branches. It would be good to have it. Rather than that LGTM

@britta-wstnr
Copy link
Member

Super, thanks! Makes it definitely easier to check, I am on it.

@massich massich changed the title [MRG] Fix weight normalization for LCMV beamformer [MRG+1] Fix weight normalization for LCMV beamformer Sep 18, 2018
@agramfort
Copy link
Member

@britta-wstnr are you ok with this?

@britta-wstnr
Copy link
Member

Sorry guys, I am packed these days. Not forgotten though and on top of list for next week!

rank_Cm = estimate_rank(Cm, tol='auto', norm=False,
return_singular=False)
noise = noise[len(noise) - rank_Cm]
noise = noise[rank_Cm]
Copy link
Member

Choose a reason for hiding this comment

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

I do not think this is correct. Note that we use linalg.eigh which returns the eigenvalues in ascending order. The old version gives the same results as Fieldtrip.

Copy link
Member

Choose a reason for hiding this comment

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

All tests are passing which suggests we need a test that would have caught this case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aah, ascending order... how weird!

@wmvanvliet
Copy link
Contributor Author

@britta-wstnr I think I've fixed it now. The table with results has been updated. The NAI beamformer's output is now the same as in master.

@britta-wstnr
Copy link
Member

@wmvanvliet yep, NAI beamformer is fine again.
regarding the normal orientation: that is very old code that was always only copied over to the refactoring. I think you are right with the changes you propose - AFAIK not possible to externally validate since not supported in other toolboxes though.

@larsoner
Copy link
Member

@britta-wstnr feel free to click the green button (we usually squash and merge nowadays) if you're happy

@agramfort agramfort merged commit 438206d into mne-tools:master Sep 28, 2018
@agramfort
Copy link
Member

thx @wmvanvliet @britta-wstnr for the team effort !

@wmvanvliet wmvanvliet deleted the lcmv_fixes branch September 28, 2018 14:43
@wmvanvliet
Copy link
Contributor Author

Ok, now we are in good shape to move ahead with #5447

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants