1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Time frequency spectrogram in Python

Discussão em 'Python' iniciado por Stack, Fevereiro 14, 2025.

  1. Stack

    Stack Membro Participativo

    I have some 64 channel EEG data sampled at 256Hz and I'm trying to conduct a time frequency analysis for each channel and plot a spectrogram.

    The data is stored in a NumPy 3d array, where one of the dimensions has length 256, each element containing a microvolt reading over all sampled time points (total length is 1 second for each channel of data).

    To be clear: my 3D array is 64256913 (electrode * voltages * trial). The trial is just a single trial of an experiment. So what I want to do is take a single electrode, from a single trial, and the entire 1D voltage vector and create a time-frequency spectrogram. So I want to create a spectrogram plot from data[0,:,0] for example.

    For each electrode, I want a plot where the y axis is frequency, x-axis is time, and colour/intensity is power

    I have tried using this in python:

    from matplotlib.pyplot import specgram
    #data = np.random.rand(256)
    specgram(data, NFFT=256, Fs=256)


    This gives me something that looks like this:

    [​IMG]

    Right off the bat, this looks incorrect to me because the axis ranges are incorrect

    Furthermore, when I run the same code for all EEG channels, over all of my data, I end up with the exact same plot (even though I have verified that the data is different for each)

    I'm pretty new to signal processing, is there somewhere that I went wrong in either how my data is laid out or how I used my function?

    Continue reading...

Compartilhe esta Página