Skip to content

Change calls to _tfr_from_mt with support for ndarrays #286

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

Merged
merged 5 commits into from
May 22, 2025

Conversation

tsbinns
Copy link
Collaborator

@tsbinns tsbinns commented Feb 10, 2025

Fixes #285.

_tfr_from_mt now supports ndarray after mne-tools/mne-python#13104. Means we can avoid looping over epochs dimensions when passing in data.

Also fixes a bug from #232 where _tfr_from_mt would be imported even when not required, making everything incompatible with MNE<1.10. Now it is only imported when required.

@harpine
Copy link

harpine commented May 21, 2025

Hello !

I think the bug you mentionned from 232 is unfortunately back;
I installed version 0.8.0 from this github with pip (I have mne version 1.7.1)

when trying :
import mne_connectivity

I came on this error:
ImportError: cannot import name '_tfr_from_mt' from 'mne.time_frequency.tfr'

Here is the whole traceback:

ImportError Traceback (most recent call last)
Cell In[2], line 1
----> 1 import mne_connectivity

File ~\AppData\Local\anaconda3\envs\ngb\Lib\site-packages\mne_connectivity_init_.py:27
16 from .base import (
17 Connectivity,
18 EpochConnectivity,
(...) 24 TemporalConnectivity,
25 )
26 from .datasets import make_signals_in_freq_bands, make_surrogate_data
---> 27 from .decoding import CoherencyDecomposition
28 from .effective import phase_slope_index
29 from .envelope import envelope_correlation, symmetric_orth

File ~\AppData\Local\anaconda3\envs\ngb\Lib\site-packages\mne_connectivity\decoding_init_.py:1
----> 1 from .decomposition import CoherencyDecomposition

File ~\AppData\Local\anaconda3\envs\ngb\Lib\site-packages\mne_connectivity\decoding\decomposition.py:18
15 from mne.viz.utils import plt_show
16 from sklearn.base import BaseEstimator, TransformerMixin
---> 18 from ..spectral.epochs_multivariate import (
19 _CaCohEst,
20 _check_n_components_input,
21 _check_rank_input,
22 _MICEst,
23 )
24 from ..utils import _check_multivariate_indices, fill_doc
27 @fill_doc
28 class CoherencyDecomposition(BaseEstimator, TransformerMixin):

File ~\AppData\Local\anaconda3\envs\ngb\Lib\site-packages\mne_connectivity\spectral_init_.py:1
----> 1 from .epochs import spectral_connectivity_epochs
2 from .time import spectral_connectivity_time

File ~\AppData\Local\anaconda3\envs\ngb\Lib\site-packages\mne_connectivity\spectral\epochs.py:28
15 from mne.time_frequency import (
16 EpochsSpectrum,
17 EpochsSpectrumArray,
18 EpochsTFR,
19 EpochsTFRArray,
20 )
21 from mne.time_frequency.multitaper import (
22 _compute_mt_params,
23 _csd_from_mt,
(...) 26 _psd_from_mt_adaptive,
27 )
---> 28 from mne.time_frequency.tfr import _tfr_from_mt, cwt, morlet
29 from mne.utils import _arange_div, _check_option, _time_mask, logger, verbose, warn
31 from ..base import SpectralConnectivity, SpectroTemporalConnectivity

PS: sorry not used to create issues on git, so tell me if I should put it somewhere else/bring more information !
Thanks in advance for your answer :)

@tsbinns
Copy link
Collaborator Author

tsbinns commented May 22, 2025

@harpine Thanks for raising this, sorry for the difficulties.

@larsoner Please could I get a review on this. Fixes a bug from an oversight in #232 since we only test on mne-main.

@larsoner
Copy link
Member

since we only test on mne-main.

Oof we should really have a CI that runs non-main MNE as well! Most repos like MNE-BIDS at a minimum test whatever the latest MNE release is. @tsbinns something for when you're motivated to do a bit of CI work perhaps 😄

@larsoner larsoner merged commit d9c260c into mne-tools:main May 22, 2025
13 checks passed
@tsbinns
Copy link
Collaborator Author

tsbinns commented May 23, 2025

@harpine The error you encountered should be fixed if you grab the latest dev branch version. Cheers!

@harpine
Copy link

harpine commented May 23, 2025

@harpine The error you encountered should be fixed if you grab the latest dev branch version. Cheers!

Thank you both for the fast reaction time, you actually made my day, I could solve a long-lasting bug in my analysis by using version 0.8.0 !!

Have a nice day :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change calls to _tfr_from_mt with support for ndarrays
3 participants