-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MRG, BUG: Refactor beamformer code #7656
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7656 +/- ##
==========================================
+ Coverage 90.12% 90.15% +0.03%
==========================================
Files 455 455
Lines 83836 84149 +313
Branches 13262 13368 +106
==========================================
+ Hits 75557 75867 +310
+ Misses 5413 5412 -1
- Partials 2866 2870 +4 |
|
@larsoner The test looks fine to me, thanks for putting it together! The vector case will be a whole other story I fear but let's discuss this later - let's try and get the scalar version green for this one first! |
|
So the test fails (at least) for the two filters ('unit-noise-gain' and 'unit-gain' filters) not relying on the same lead field if the orientation is picked. |
|
Can the orientation picking be done last, after all other computations? If so, then maybe we shouldn't even bother doing it during filter creation but rather during |
|
No, it should ideally be done before the filter computation and then we pick the lead field and recompute the filter. |
|
Why even bother storing the leadfield in the |
|
Well in this case it would come in handy for the test. I do not know how many use-cases there are, one argument for it is that we change the lead field if we do orientation selection. The plotting of the orientation itself is sometimes done, to get an overview of which orientations the filter uses, so that would in any case be useful (and would give the actually used lead field as well, if needed). |
|
+1 for storing the selected orientations (surprised we didn't already do this?). Whether you store the entire leadfield or the selected one is up to you. The selected one is just the BTW would it be possible at some point to provide the "variance explained" like we do for minimum norm and mixed norm solvers? Probably not for this PR but a follow-up one, it would be nice to have. |
* upstream/master: DOC: Order added reference FIX: Working working version ENH: More efficient actually working csd, needs review MAINT: Update dataset and add constant test (mne-tools#7866) DOC: update link to glasser supplementary info; convert to footbib (mne-tools#7864) FIX: Fix subtract_evoked with decim (mne-tools#7855) FIX: Fix reading of old TFRs (mne-tools#7851) DOC: Add evoked movecomp to example (mne-tools#7852) Deprecate meg=True in pick_types (mne-tools#7823) ENH: Allow reading broken file (mne-tools#7846) MRG, ENH: Add mixed source estimate support to compute_source_morph (mne-tools#7734) FIX: Fix bug with metadata and event_repeated (mne-tools#7733) MRG, ENH: Add axes to plot_evoked_white (mne-tools#7831) MRG, ENH: Add example of projection to source space (mne-tools#7705)
* upstream/master: (24 commits) WIP: Fix Travis (mne-tools#7906) WIP: Prototype of notebook viz (screencast) (mne-tools#7758) MRG, FIX: Speed up I/O tests, mark some slow (mne-tools#7904) Proper attribution for Blender tutorial (mne-tools#7900) MAINT: Check usage [ci skip] (mne-tools#7902) Allow find_bad_channels_maxwell() to return scores (mne-tools#7845) Warn if NIRx directory structure has been modified from original format (mne-tools#7898) Pin pvyista to 0.24.3 (mne-tools#7899) MRG: Add support for reading and writing sufaces to .obj (mne-tools#7824) Fix _auto_topomap_coords docstring. (mne-tools#7895) MRG, FIX: Ensure Info H5-writeable (mne-tools#7887) Website contents (mne-tools#7889) MRG, ENH: Add mri_resolution="sparse" (mne-tools#7888) MRG, ENH: Allow disabling FXAA (mne-tools#7877) remove "and and" [ci skip] (mne-tools#7882) fix evoked nave → inverse guidance (mne-tools#7881) ENH: Better error messages (mne-tools#7879) FIX : EDF+ Annotation Timestamps missing sub-second accuracy (mne-tools#7875) FIX: Fix get_channel_types (mne-tools#7878) MRG, BUG: Fix combine evokeds (mne-tools#7869) ...
* upstream/master: MRG, ENH: Add method to project onto max power ori (mne-tools#7883) WIP: Warn if untested NIRX device (mne-tools#7905) MRG, BUG: Fix bug with volume morph and subject_to!="fsaverage" (mne-tools#7896) MRG, MAINT: Clean up use of bool, float, int (mne-tools#7917) ENH: Better error message for incompatible Evoked objects (mne-tools#7910) try to fix nullcontext (mne-tools#7908)
britta-wstnr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@larsoner I updated the FieldTrip data according to FieldTrip's newest release (and fixed some resulting deprecation warnings in our script while I was already on it, see here: mne-tools/mne-scripts#24).
For me, test_external passes with this data.
I still get 3 errors for the test_localization_bias_free, but I feel you have the better overview there right now.
I in principle fixed the W @ G.T test for the Sekihara unit-noise-gain vector beamformer, just did not know how to implement it proper (see review).
Close to merging, maybe? 😄
mne/beamformer/tests/test_lcmv.py
Outdated
| # got = w @ use_G.swapaxes(-2, -1) | ||
| # s = np.linalg.svd(got, compute_uv=False) | ||
| # theta = np.repeat(s[..., :1], s.shape[-1], axis=-1) | ||
| # assert_allclose(s, theta, rtol=1e-1, err_msg='G.T @ w = θI') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@larsoner This is not right I think - it is easier than you tested for.
w @ G.T should not have a constant on the diagonal, it just should be a diagonal matrix. This holds for me in the test above:
np.allclose(np.diag(np.diag(got[0])), got[0])
I just did not know how to do this on our 3-dimensional matrix ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last I checked it, it wasn't diagonal I don't think. But I can look early next week. If you want to try something, feel free to just make it a simple loop and I can vectorize the check later
* upstream/master: (30 commits) MRG: Add remove_labels to _Brain (mne-tools#7964) Add get_picked_points (mne-tools#7963) ENH: Add OpenGL info to mne sys_info (mne-tools#7976) [MRG] Fix reject_tmin and reject_tmax for reject_by_annotation in mne.Epochs (mne-tools#7967) mrg: Add scalar mult and div operators for AverageTFR (mne-tools#7957) MRG, MAINT: Cleaner workaround for Sphinx linking issue (mne-tools#7970) MRG, ENH: Speed up epochs.copy (mne-tools#7968) MRG, BUG: Allow ref mags to have a comp grade (mne-tools#7965) do not forget to pass adjacency (mne-tools#7961) [MRG] fix Issue with stc.project after restricting to a label (mne-tools#7950) Only process nirx event file if present (mne-tools#7951) MRG+1: BUG: info['bads'] order shouldn't matter in write_evokeds() (mne-tools#7954) Fix some small glitches introduced via mne-tools#7845 (mne-tools#7952) Add time player (mne-tools#7940) MAINT: Clean up VTK9 offset array [circle front] (mne-tools#7953) MAINT: Skip a few more on macOS (mne-tools#7948) fix links [skip travis] (mne-tools#7949) MRG, MAINT: Tweak CIs (mne-tools#7943) MRG, BUG: Fix vector scaling (mne-tools#7934) MRG, VIZ, BUG: handle CSD channel type when topo plotting (mne-tools#7935) ...
|
@agramfort do you want to see if the changes make sense to you based on the doc updates, etc.? |
agramfort
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this branch on some phantom data and I don't see any regression on the LCMV side.
@britta-wstnr it's some data from beamformer NI paper
wmvanvliet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge when green!
* upstream/master: (21 commits) MRG: Add SSP projectors to Report (mne-tools#7991) BUG: Fix warning (mne-tools#8006) WIP: TFR Doc/test changes (mne-tools#7998) MAINT: Remove numpydoc test on 3.6 (mne-tools#8005) MAINT: Better error message for mismatch (mne-tools#8007) MRG: Allow removal of active projectors if channels they applied to have meanwhile been dropped (mne-tools#8003) MRG Freesurfer coordinate frame tutorial (mne-tools#7578) FIX: Fix stockwell checks (mne-tools#7996) MRG, ENH: Add array-spacing plugin and reorganize deps (mne-tools#7997) MRG, ENH: Reduce memory usage of Welch PSD (mne-tools#7994) STY: One more [ci skip] STY: Docstyle [ci skip] Report parsing (mne-tools#7990) MRG, ENH: BrainVision impedance parsing (mne-tools#7974) BUG: Fix missing source space points (mne-tools#7988) [MRG] Strip base directory name from Report captions when using parse_folder (mne-tools#7986) DOC: Update estimates [skip travis] (mne-tools#7987) DOC: Try to improve find_bad_channels_maxwell doc (mne-tools#7982) VIZ, BUG: fix tickmarks in evoked topomap colorbar (mne-tools#7980) Add low-pass filter to find_bad_channels_maxwell() (mne-tools#7983) ...
|
Thanks @britta-wstnr @wmvanvliet ! |
|
Congrats 🎉 🍾🍻
|
|
Whee! |
To be fixed with @britta-wstnr
_normalized_weightspath_reg_pinvnot maintaining Hermitian symmetry'pick_ori='max-power'andpick_ori='normal'tf_lcmv'unit-noise-gain'norm / rotation invarianceCloses #7021