Skip to content

tfr_array_morlet issues with wavelet #11645

Closed

Description

@RainyMeadows

Steps to reproduce

import numpy as np
from mne.time_frequency import tfr_array_morlet

freqs=np.arange(1, 50, 1)
power = tfr_array_morlet(Input_data, 1000, freqs, n_cycles=7.0, output='avg_power') # Input data is a 70 * 128 * 7000 array

Link to data

I can provide actual data of a single (or couple) channel(s), if necessary.

Expected results

An array of shape (n_chans, n_freqs, n_times)

Actual results

ValueError: At least one of the wavelets is longer than the signal. Use a longer signal or shorter wavelets.

The function works ONLY for n_cycles <= 4.

Additional information

Platform: Windows-10-10.0.22621-SP0
Python: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
Executable: C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe
CPU: Intel64 Family 6 Model 167 Stepping 1, GenuineIntel: 12 cores
Memory: 15.7 GB

mne: 1.3.1
numpy: 1.24.2 {unknown linalg bindings (threadpoolctl module not found: No module named 'threadpoolctl')}
scipy: 1.10.1

Activity

  1. welcome commented on Apr 23, 2023

    @welcome

    Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

  2. agramfort commented on Apr 23, 2023

    @agramfort
    SponsorMember
  3. RainyMeadows commented on Apr 23, 2023

    @RainyMeadows
    Author

    Ah, I was assuming that at lowest (1 Hz), 7 cycles equate to 7s of signal!

    It appears that the minimum length, as obtained from len([mne.time_frequency.morlet(1000, np.arange(1, 50, 1), n_cycles=7.0)][0][0]) = 11141 Maybe, the error message can be a bit more suggestive in mentioning the maximum wave number feasible given the current choice of wave number, min freq, and time sample?

  4. agramfort commented on Apr 24, 2023

    @agramfort
    SponsorMember
  5. RainyMeadows commented on Apr 24, 2023

    @RainyMeadows
    Author

    See my (edited) comment; l I did take a look!

  6. agramfort commented on Apr 25, 2023

    @agramfort
    SponsorMember

    @RainyMeadows would you be up for submitting a PR to update our doc? that would be much appreciated. thanks

  7. drammock commented on Apr 25, 2023

    @drammock
    Member

    @RainyMeadows In the code there's a comment that I think would resolve your confusion:

    # time vector. We go 5 standard deviations out to make sure we're
    # *very* close to zero at the ends. We also make sure that there's a
    # sample at exactly t=0

    In other words, the wavelet will always be 10 * sigma - 1 samples long (after converting sigma into a number of samples rather than seconds).

    (If sigma isn't specified it defaults to n_cycles / (2.0 * np.pi * f))

  8. added
    sprint-2023
    on Jul 5, 2023
  9. added a commit that references this issue on Oct 4, 2023
    ddb7f3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DOCEASYsprint-2023

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions