I'm borrowing an EEG device whose accompanying software also computes the FFT of the data it collects. The software provides the user with a file of EEG values and a file of FFT values computed from the EEG file, and I wanted to learn how to compute the FFT values on my own.
Here's the manufacturer's description of how they do it: "Each path contains 129 decimal values with a range of roughly -40.0 to 20.0. Each array represents FFT coefficients (expressed as Power Spectral Density) for each channel, for a frequency range from 0hz-110Hz divided into 129 bins. We use a Hamming window of 256 samples(at 220Hz), then for the next FFT we slide the window 22 samples over(1/10th of a second). This gives a 90% overlap from one window to the next. These values are emitted at 10Hz."
Going through MATLAB's documentation I ended up with this code:
X = data(:, 1);
h = hamming(256);
buf = buffer(X, 256, 234);
hWin = buf.*repmat(h(:), [1, size(buf, 2)]);
Y = fft(hWin);
P2 = (abs(Y))';
P1 = P2(:, 1:256/2 + 1);
P1(:, 2:end-1) = 2*P1(:, 2:end-1);
P1 = 10 * log10(P1);
But it doesn't produce the sames values that I see in the four FFT files given to me by the manufacturer. First, let me start by saying that their EEG file contains a 193011 X 4 matrix of data, and each column corresponds to the data collected by one of the four channels/sensors on the EEG device. And with each column of data, they were able to compute four separate files, which they named raw_fft0, raw_fft1, raw_fft2, and raw_fft3. Each raw_fft file contains a 8607 X 129 matrix whose values should be somewhere between -40 and -20. The actual observed values for their FFT files are somewhere between -30 to -20 to the low-to-mid 40s.
On the other hand, my FFT files are of the dimension 8774 X 129, and the range of values in my files are bigger than what the manufacturer says they should be. Would anyone mind pointing out what I've done wrong or pointing me to information that could clarify what I've done wrong?
buffer
function and not hamming window as the output dimensions depend onbuffer
. $\endgroup$ – Irreducible Mar 9 '18 at 12:01193011
is the number of samples (input buffer) prior to the overlapping or after. $\endgroup$ – dsp_user Mar 9 '18 at 18:27