[Eeglablist] applying Hanning windows

Bradley Voytek bradley.voytek at gmail.com
Fri Oct 30 14:24:48 PDT 2009


Krysta:

You can do it yourself pretty easily:

data = EEG.data;
srate = EEG.srate;
window_length = srate * 4;
window_overlap = round(srate / 2);
length_of_data = length(data);
hann_window = hann(window_length);

x = 2;
time_points = 1;
while (time_points(x - 1) < length_of_data)
  time_points(x, 1) = 1 + ((window_length - window_overlap) * (x - 1));
  x = x + 1;
end
clear x
time_points(:, 2) = time_points(:, 1) + (window_length - 1);
while (time_points(end, 2) > length_of_data)
  time_points = time_points((1:end-1), :);
end
clear x foo

nfft = 2 ^ (nextpow2(window_length));
f = (0:(window_length / 2) - 1) * (srate / nfft);

power_spectrum = zeros([size(time_points, 1) (window_length / 2)]);

for x = 1:size(time_points, 1)
   temp = fft(hann_window' .* data(time_points(x, 1):time_points(x, 2)), nfft);
   power_spectrum(x, :) = ((abs(temp(1:(window_length / 2))) /
window_length) .^ 2) .* 2;
   clear temp
end
clear x time_points hann_window length_of_data nfft srate window*



More information about the eeglablist mailing list