From 397d6d737a09ee976f8814c7ad90ded1ea9c8609 Mon Sep 17 00:00:00 2001 From: Thomas Samuel Binns Date: Thu, 23 May 2024 15:54:35 +0200 Subject: [PATCH 1/2] Add logic for handling AverageTFRArray in old MNE versions --- examples/cwt_sensor_connectivity.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/cwt_sensor_connectivity.py b/examples/cwt_sensor_connectivity.py index 3be7913c..fabfc4d2 100644 --- a/examples/cwt_sensor_connectivity.py +++ b/examples/cwt_sensor_connectivity.py @@ -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 # # License: BSD (3-clause) @@ -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 print(__doc__) @@ -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") From 12f23ac888c9d55adaa3aa020b0af575ceebb733 Mon Sep 17 00:00:00 2001 From: Thomas Samuel Binns Date: Fri, 24 May 2024 13:47:23 +0200 Subject: [PATCH 2/2] Switch to AverageTFRArray --- examples/cwt_sensor_connectivity.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/cwt_sensor_connectivity.py b/examples/cwt_sensor_connectivity.py index fabfc4d2..5c6e1eef 100644 --- a/examples/cwt_sensor_connectivity.py +++ b/examples/cwt_sensor_connectivity.py @@ -20,12 +20,7 @@ from mne import io from mne_connectivity import spectral_connectivity_epochs, seed_target_indices from mne.datasets import sample - -# 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 +from mne.time_frequency import AverageTFRArray print(__doc__) @@ -97,7 +92,8 @@ layout = mne.find_layout(epochs.info, "meg") # use full layout -tfr = AverageTFR(epochs.info, con.get_data(), times, freqs, nave=len(epochs)) +# Note that users of mne < 1.7 should use the `AverageTFR` class +tfr = AverageTFRArray(epochs.info, con.get_data(), times, freqs, nave=len(epochs)) tfr.plot_topo(fig_facecolor="w", font_color="k", border="k")