Skip to content
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

[MAINT] Add logic for handling AverageTFRArray in old MNE versions #185

Merged
merged 4 commits into from
May 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions examples/cwt_sensor_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
domain using Morlet wavelets and the debiased squared weighted phase lag index
:footcite:`VinckEtAl2011` is used as connectivity metric.
"""

# Author: Martin Luessi <[email protected]>
#
# License: BSD (3-clause)
Expand All @@ -19,7 +20,12 @@
from mne import io
from mne_connectivity import spectral_connectivity_epochs, seed_target_indices
from mne.datasets import sample
from mne.time_frequency import AverageTFR

# XXX: remove logic once support for mne<1.7 is dropped
try:
from mne.time_frequency import AverageTFRArray as AverageTFR
except ImportError:
from mne.time_frequency import AverageTFR
Copy link
Member

Choose a reason for hiding this comment

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

hmm, I'm not crazy about including logic like this in a public-facing example/tutorial. Is it enough to code it whatever way works for the CI docs build, and include a comment to the effect of "if you're on some other version of MNE, use the other class"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I'm happy to take this approach as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How do you feel about this?

# Note that users of mne < 1.7 should use the `AverageTFR` class
tfr = AverageTFRArray(epochs.info, con.get_data(), times, freqs, nave=len(epochs))


print(__doc__)

Expand Down Expand Up @@ -91,7 +97,7 @@

layout = mne.find_layout(epochs.info, "meg") # use full layout

tfr = AverageTFR(epochs.info, con.get_data(), times, freqs, len(epochs))
tfr = AverageTFR(epochs.info, con.get_data(), times, freqs, nave=len(epochs))
tfr.plot_topo(fig_facecolor="w", font_color="k", border="k")


Expand Down
Loading