-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix apply_function docstring for Epochs #13118 #13136
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
base: main
Are you sure you want to change the base?
Conversation
Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴 |
I've made the necessary changes, built the documentation successfully, and verified that the updates are rendering correctly. I've now submitted the pull request for review. Let me know if any further modifications are needed. Thanks! |
@@ -1861,7 +1861,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): | |||
additional argument(s) to your function definition. | |||
""" | |||
docdict["fun_applyfun"] = applyfun_fun_base.format( | |||
" if ``channel_wise=True`` and ``(len(picks), n_times)`` otherwise" | |||
" if ``channel_wise=True`` then a 3D array of shape ``(n_epochs, len(picks), n_times)`` is passed, otherwise a 3D array of shape ``(n_epochs, n_channels, n_times)`` is passed" | |||
) |
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.
This isn't quite right, because this change will be reflected in the documentation for raw.apply_function
and evoked.apply_function
, but we don't want it to, since those data will never be 3D!
Thanks @Imama-Kainat for brining this to attention! Can you help me to better understand the issue, by providing a minimally working example (MWE) of a user-defined function that works with You can start with this: import mne
sample_fpath = mne.datasets.sample.data_path()
fpath = sample_fpath / "MEG" / "sample" / "sample_audvis_raw.fif"
raw = mne.io.read_raw(sample_fpath, preload=True).pick("eeg")
epochs = mne.make_fixed_length_epochs(raw, duration=1, preload=True)
def my_fun(x):
"""My function that works with epoch.apply_function(channel_wise=True)"""
return If docdict["fun_applyfun_epochs"] = applyfun_fun_base.format(
" if ``channel_wise=True`` and ``(n_epochs, n_channels, n_times)`` otherwise"
) And then use |
The current documentation for apply_function in mne.Epochs is misleading, as it does not accurately describe the shape of the epochs data (3D arrays). This can cause confusion about how the function processes the data across different dimensions.
This PR updates the relevant docstrings in mne/utils/docs.py to clearly state how apply_function operates on the epochs data, ensuring users understand the function's behavior when applied to multi-dimensional data structures. The updated documentation improves clarity and consistency with other MNE functions.