align FFT windows to good data spans in psd_array_welch#12536
align FFT windows to good data spans in psd_array_welch#12536larsoner merged 3 commits intomne-tools:mainfrom
Conversation
|
Thanks @drammock ! |
| weights = [ | ||
| split.shape[-1] for split in x_splits if split.shape[-1] >= n_per_seg | ||
| ] |
There was a problem hiding this comment.
was actually just wondering if this is in fact the most accurate weighting. Perhaps this is better?
# weights reflect the number of welch windows in each span
stepsize = n_per_seg - n_overlap
weights = [(span.shape[-1] - n_overlap) // stepsize for span in x_splits]
weights = np.array(weights)[np.array(weights) > 0]Old code weights based on total samples in the span (as long as span > n_per_seg). New code weights based on number of welch windows that fit into the span, i.e., should reflect how much data in the span is actually used in the computation. If that seems correct, I can open a follow-up PR. cc @agramfort @larsoner
There was a problem hiding this comment.
The new way seems more correct to me
|
I just tested this with the MWE in #11413, and at least for me this example is not fixed. I now get a different error: This is the second plot (after adding an annotation). The first plot works (as previously). |
* upstream/main: (50 commits) ENH: Improve OPM auditory dataset and example (mne-tools#12539) MAINT: Bump to latest pydata-sphinx-theme (mne-tools#12228) MRG: Simplify manual installation instructions a little by dropping explicit mention of (lib)mamba (mne-tools#12362) fix PSD weights handling when bad annotations present (mne-tools#12538) Fix phase loading (mne-tools#12537) align FFT windows to good data spans in psd_array_welch (mne-tools#12536) explicitly disallow multitaper in presence of bad annotations (mne-tools#12535) MAINT: Clean up PyVista contexts (mne-tools#12533) MAINT: Complete API change of ordered (mne-tools#12534) MAINT: Reinstall statsmodels and improve logging (mne-tools#12532) MAINT: Remove scipy.signal.morlet2 (mne-tools#12531) Update README badge links (mne-tools#12529) BUG: Fix bug with reading his_id from snirf (mne-tools#12526) [pre-commit.ci] pre-commit autoupdate (mne-tools#12524) Fix file format check in _check_eeglab_fname function (mne-tools#12523) MAINT: Reenable picard in pre testing (mne-tools#12525) MAINT: Bump to large resource class (mne-tools#12522) MAINT: Restore 2 jobs on Windows (mne-tools#12520) Add exclude_after_unique option to mne.io.read_raw_edf/read_raw_edf to search for exclude channels after making channel names unique (mne-tools#12518) Improve consistency of sensor types in code and documentation (mne-tools#12509) ...
closes #11413