0
$\begingroup$

I have EEG data.

I have 51 values(complex numbers) that are supposed to represent the frequency.

I plot the absolute values.

enter image description here

They have negative values and have an imaginary component as well:

array([ 209.28168     +0.j        ,   -9.189357  +165.30928j   ,
        -73.242516   +16.988483j  ,  -56.90396     -6.681808j  ,
          2.368906   -73.34094j   ,   77.60809    +51.808327j  ,
       -127.98835   +102.01125j   , -130.74635   -187.83682j   ,
        178.67984   -114.41258j   ,   47.705574   +87.53061j   ,
         28.301582   -19.40547j   ,   52.638763   +96.17305j   ,
       -103.75746    +68.47661j   ,  -86.84241    -89.90001j   ,
         78.26882    -93.51044j   ,   72.987045   +61.222275j  ,
        -38.35683    +44.473587j  ,  -35.613907   -24.128868j  ,
         15.530724   -41.42018j   ,   36.37819     -6.4717045j ,
         37.23372    +14.647099j  ,    4.8836637  +47.6666j    ,
        -31.395866    +6.009075j  ,   10.648441   -16.590837j  ,
         18.799345   +35.3611j    ,  -56.23816    +16.46596j   ,
          9.5054     -62.397247j  ,   51.61265    +42.241302j  ,
        -56.021103   +31.970703j  ,  -10.403204   -52.568584j  ,
         48.29229    +12.685957j  ,  -32.49025    +44.99341j   ,
        -36.23934    -36.369003j  ,   20.976671   -28.656288j  ,
         34.212887    +0.95503426j,   10.58852    +48.998833j  ,
        -57.62168    +18.617676j  ,  -30.762165   -53.3849j    ,
         40.68946    -38.06536j   ,   28.283798   +23.822248j  ,
         -5.9956245   +9.426829j  ,   -1.0014873   +6.1050067j ,
         -8.298754    -6.1727304j ,   10.428       -5.2445345j ,
          2.635398    +5.918062j  ,   -0.13528198  -0.94400257j,
          6.9935513   +0.06301874j,    2.293034    +9.832797j  ,
         -5.2560153   +3.3630538j ,   -4.138683    +0.770857j  ,
         -1.1582437   -4.4128532j ], dtype=complex64)

I also have this information provided:

sampling rate: 250Hz per second winlength: 0.5s => 125 point overlap: 0.25s => 63 points

I don't exactly know what they mean 250 the sampling period, my understanding says that I should than have 125 values in the frequency decomposition. Our should I somehow expand this decomposition to 250 values.

I run the inverse fourier from scipy

enter image description here

It seems a bit odd. Should I perhaps somehow taken into account the information about the sampling rate.

$\endgroup$

1 Answer 1

3
$\begingroup$

I am assuming the original EEG data was real (which seems reasonable) and therefore can conclude that the result given represents just the positive frequencies; since the complete spectrum would be complex conjugate symmetric in the case of a real signal and due to the redundancy it is common to not show the negative frequencies.

The comments on the window length and overlap make me believe that the results shown are the averaged result after a much larger data set with 50% overlap and add of 125 point FFT blocks. The result of this would be an FFT the size of the window (125 points), with just 63 points if we include only the DC bin and the positive frequencies. My guess here is that remaining 12 DFT bins not shown were just low values and excluded (and these higher bins should be in the transition band of the anti-alias filter in front of the ADC regardless). In this case each bin would have a bin width of $250/125 = 2$ Hz, and we could change the horizontal axis from frequency index to frequency in Hz by simply doubling what is shown (so we see the positive frequencies from DC to 100 Hz).

To compute the inverse DFT, we need to use the complete DFT including the positive and negative frequency bins. To do this using my assumptions above, and with this case of an odd number of bins, first zero pad out to the Nyquist bin 62 (with bins $k=0 \ldots N-1$ where $N= 125$, (meaning make bins 52 to 62 equal to 0) and then introduce the negative frequencies as mapped from the positive frequencies according to:

$$W[62+k] = W[62-k]^*$$

Where ($^*$) is the complex conjugate, and $k$ here are the remaining indices to map the negative frequencies using $k=0 \ldots 62$ in the formula above.

Meaning, populate a complete 125 point DFT with $k= 0 \ldots 124$ using the complex conjugate of the current sample at bin $62-1 =61$ to be the sample at bin $62+1 =63$, the complex conjugate of the current sample at bin 60 to be the sample at bin 64 and continued all the way to bin 124 using the complex conjugate of bin 1 as bin 124. Note here of course that the samples from bin 52 to 61 are assumed to be zero, and therefore so will be the samples from 63 to 72. It's possible, and likely, that each of the bins in the 51 samples originally given were doubled to account for the negative frequencies, but this is just a simple scaling by two in the overall result.

$\endgroup$
8
  • $\begingroup$ Thank you for your answer. The data has negative values and the imaginary component, I just didn't know how to plot it, I printed it out in the edited question now. And I did use this data in the inverse fourier transform. $\endgroup$
    – Borut Flis
    Jan 8, 2022 at 15:30
  • $\begingroup$ Yes makes sense, typically we plot the magnitude (absolute value) and phase in separate plots, or often with regards to a spectrum the magnitude only is of interest and that is what is shown. Not sure if you have any further question or if you were just commenting on that? $\endgroup$ Jan 8, 2022 at 15:32
  • $\begingroup$ Are you saying that I should populate the entire 125 point before running the inverse fft? $\endgroup$
    – Borut Flis
    Jan 8, 2022 at 15:35
  • $\begingroup$ Yes that is what I said. But in the manner as I listed specifically (mirror your existing points with a complex conjugate). $\endgroup$ Jan 8, 2022 at 15:35
  • 1
    $\begingroup$ dsp.stackexchange.com/a/64894/21048 $\endgroup$ Jan 8, 2022 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.