Plotting real time windowed Fourier transform in GUIDE

3 次查看(过去 30 天)
Hello, I am streaming in 8 channels of EEG data via the LabStreamingLayer, and have a timer which calculates the Fourier transform of a window of incoming data (1/2 second window) at a rate of 250Hz (or every 0.004 seconds). I want to plot this in a GUIDE window each time the timer executes its callback function. Is there any way to do this?
Here's the timer's callback function (I am updating the variale 'fftx' from the 'obj' passed into the callback. I attempt to get the axes in the GUIDE window, whose tag is 'spectrogram'. This, however, draws a single sine wave onto the axes, and fails to do anything else):
function getFFT(obj, ~, inlet, x)
% updates value of windowed EEG sample from LSL
% pull sample from from LSL inlet at rate of 250Hz
[vec, ~] = inlet.pull_sample();
% load the state of the Fourier-transformed window into this callback
fftx = get(obj, 'UserData');
% if we have fewer than 250 samples
if length(x) < 250 % add the current sample to the window
x = [x; vec];
else % otherwise, remove the oldest sample and add the newest, and compute the FFT
x(1,:) = [];
x = [x; vec];
fftx = fft(x);
end
% set the Fourier-transformed window within the GUI workspace
set(obj, 'UserData', fftx);
h=findobj('Type','axes','Tag','spectrogram');
axes(h);
plot(250*((0:249)*250), fftx(1:250))

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by