-
Notifications
You must be signed in to change notification settings - Fork 34
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
Conversation
Again some strange MacOS-specific runtime errors for code not touched by this PR like in #184. |
examples/cwt_sensor_connectivity.py
Outdated
# 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 |
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.
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"?
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.
Sure, I'm happy to take this approach as well.
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.
How do you feel about this?
mne-connectivity/examples/cwt_sensor_connectivity.py
Lines 95 to 96 in 12f23ac
# Note that users of mne < 1.7 should use the `AverageTFR` class | |
tfr = AverageTFRArray(epochs.info, con.get_data(), times, freqs, nave=len(epochs)) |
Unrelated spelling mistake just now being caught with updated codespell version addressed in #186. |
Looks like comments have been address so I'll mark for merge-when-green, thanks @tsbinns ! |
Problem
Since MNE-Python v1.7 the API of
time_frequency.AverageTFR
has been changed. The old API from <= v1.6 is now available in the new classtime_frequency.AverageTFRArray
.The example
cwt_sensor_connectivity.py
usesAverageTFR
with the old API, causing documentation building to fail when using MNE-Python >= v1.7.Solution
One possibility is to check whether the new class
AverageTFRArray
is available and import this (for >= v1.7), otherwise use the oldAverageTFR
(for v <= 1.6):mne-connectivity/examples/cwt_sensor_connectivity.py
Lines 19 to 28 in 397d6d7
Also necessary to explicitly set the
nave
parameter, as the newAverageTFRArray
does not support this as a positional argument:mne-connectivity/examples/cwt_sensor_connectivity.py
Line 100 in 397d6d7
Very open to other ideas for implementing such a logic. Cheers!