From 5abd7b13f53092a389f5699d007898a709a780d5 Mon Sep 17 00:00:00 2001 From: Bhargav Kowshik Date: Fri, 8 May 2026 10:46:16 +0530 Subject: [PATCH 1/3] DOC: Fix apply_function shape description for Epochs The fun parameter docstring for mne.Epochs.apply_function incorrectly stated that the array passed to the user's function when channel_wise=False has shape (len(picks), n_times). The actual shape is (n_epochs, n_channels, n_times). Adds a new fun_applyfun_epochs docdict entry alongside fun_applyfun_evoked and fun_applyfun_stc, leaving the Raw docstring (where (len(picks), n_times) is correct) untouched. Per scott-huberty's review suggestion on #13136. Fixes #13118 --- mne/epochs.py | 2 +- mne/utils/docs.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mne/epochs.py b/mne/epochs.py index 8aaf1316305..442359f3d65 100644 --- a/mne/epochs.py +++ b/mne/epochs.py @@ -1974,7 +1974,7 @@ def apply_function( Parameters ---------- - %(fun_applyfun)s + %(fun_applyfun_epochs)s %(picks_all_data_noref)s %(dtype_applyfun)s %(n_jobs)s Ignored if ``channel_wise=False`` as the workload diff --git a/mne/utils/docs.py b/mne/utils/docs.py index fac59e0852f..f6a1e308238 100644 --- a/mne/utils/docs.py +++ b/mne/utils/docs.py @@ -1919,6 +1919,9 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["fun_applyfun"] = applyfun_fun_base.format( " if ``channel_wise=True`` and ``(len(picks), n_times)`` otherwise" ) +docdict["fun_applyfun_epochs"] = applyfun_fun_base.format( + " if ``channel_wise=True`` and ``(n_epochs, n_channels, n_times)`` otherwise" +) docdict["fun_applyfun_evoked"] = applyfun_fun_base.format( " because it will apply channel-wise" ) From 01c233a5d20b3eefc1d8e41fd08ac7368e85fba4 Mon Sep 17 00:00:00 2001 From: Bhargav Kowshik Date: Tue, 12 May 2026 17:06:48 +0530 Subject: [PATCH 2/3] DOC: address review on apply_function Epochs docstring (#13891) Apply @tsbinns review suggestion (n_channels -> len(picks); explain channel_wise=True shape). --- mne/utils/docs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mne/utils/docs.py b/mne/utils/docs.py index f6a1e308238..98fac7232ae 100644 --- a/mne/utils/docs.py +++ b/mne/utils/docs.py @@ -1920,7 +1920,9 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): " if ``channel_wise=True`` and ``(len(picks), n_times)`` otherwise" ) docdict["fun_applyfun_epochs"] = applyfun_fun_base.format( - " if ``channel_wise=True`` and ``(n_epochs, n_channels, n_times)`` otherwise" + " if ``channel_wise=True`` (because it will apply to 1-D" + " slices along the times axis) and" + " ``(n_epochs, len(picks), n_times)`` otherwise" ) docdict["fun_applyfun_evoked"] = applyfun_fun_base.format( " because it will apply channel-wise" From 3f3793cc6797b13c446cc40ccca4024ee81c562c Mon Sep 17 00:00:00 2001 From: Bhargav Kowshik Date: Tue, 12 May 2026 17:07:41 +0530 Subject: [PATCH 3/3] DOC: add changelog entry for #13891 Add 13891.other.rst (other type) and Bhargav Kowshik to names.inc as new contributor. --- doc/changes/dev/13891.other.rst | 1 + doc/changes/names.inc | 1 + 2 files changed, 2 insertions(+) create mode 100644 doc/changes/dev/13891.other.rst diff --git a/doc/changes/dev/13891.other.rst b/doc/changes/dev/13891.other.rst new file mode 100644 index 00000000000..4c60a55c67d --- /dev/null +++ b/doc/changes/dev/13891.other.rst @@ -0,0 +1 @@ +Fixed the ``fun`` shape description in :meth:`mne.Epochs.apply_function`'s docstring, by :newcontrib:`Bhargav Kowshik`. diff --git a/doc/changes/names.inc b/doc/changes/names.inc index e20fad63acb..86644392e3b 100644 --- a/doc/changes/names.inc +++ b/doc/changes/names.inc @@ -40,6 +40,7 @@ .. _Beige Jin: https://github.com/BeiGeJin .. _Ben Beasley: https://github.com/musicinmybrain .. _Benedikt Ehinger: https://www.benediktehinger.de +.. _Bhargav Kowshik: https://github.com/bkowshik .. _Bradley Voytek: https://github.com/voytek .. _Britta Westner: https://britta-wstnr.github.io .. _Bruno Aristimunha: https://bruaristimunha.github.io