Azzera filtri
Azzera filtri

How do I use the buffer function to operate real time on EEG signal files?

2 visualizzazioni (ultimi 30 giorni)
Hello, I've got a code where I detect signals through thresholding, but I'd like for the thresholding to reapply to the signal every 40 seconds or so if I enter a 5 minute signal. I've found buffering can help with this, but I am having some issues applying it. I want to segment the signal into 40 second segments (can be overlapping or non overlapping), however since the original signal (300 seconds) has been multiplied by the frequency 256, it is now 76800 values and I'm slightly confused. I am not sure which variables to alter, and the wiki example doesn't seem to apply to my signal type. I help appreciate some help understanding how the function works and how to apply if possible.
eegsignal = (data_array2(710656:787456)); %signal to be inserted around 5 mins long
%contains non-seizure and then seizure
fs = 256;
frame_length = 40
signal_length = 300*256
sig = buffer(1:76800,40);
n = 5;
p = 1;
opt = -5;
z = [];
for i = 1:size(sig,2)
x = sig(:,i);
[y,z,oppt] = buffer([z;x],n,p,opt);
if i <= 4
disp('no seizure')
end
opt = oppt;
end

Risposte (1)

Star Strider
Star Strider il 12 Mag 2024
I seriously doubt that MATLAB can do real-time signal processing, unless you are also useing the Data Acquisition Toolbox and appropriate hardware with it. (I have never done that, always using recorded signals.)
That aside, to use the buffer function, it uses the number of samples as the second argument. That can easily be caluculated as:
samples = desired_secondds * sampling frequency
so here that would be —
sampling_frequency = 256; % Hz
segments = 40; % Segment Length (seconds)
samples = sampling_frequency * segments % Samplse/second * Seconds = Samples
samples = 10240
A 300 second signal sampled at 256 Hz would be —
Signal_Total_Time = 300;
Signal_Length = Signal_Total_Time * sampling_frequency
Signal_Length = 76800
You can only segment your signal in this number of frames —
NrFrames = Signal_Total_Time / segments
NrFrames = 7.5000
The buffer function will return 8 frames (columns) with the last 5120 entries in the last column set to 0.
Most EEG signals are sampled at at least i kHz. Your sampling frequency may not capture all the details.
.
  2 Commenti
Tania Akhtar
Tania Akhtar il 12 Mag 2024
My mistake, I should've specified. I do not want real time as in receiving real time EEG's from patients. I've got EEG signal recordings that are about a couple of minutes long, and I want my code to be able to analyse around a couple seconds at a time to determine if there's a seizure yet. For example I've got a feature that calculates standard deviation and determines if there's a seizure based on the value, but I want the code to recalculate the standard deviation every couple of seconds to see if there's a seizure present later on in the eeg recording. And thank you so much for your answer, I will try implement this in the buffer code.
Star Strider
Star Strider il 12 Mag 2024
Seizures are different. For example absence seizures are characterised by 3 Hz spike-wave characteristics. If you are classifying them, there may already be lilterature on that. If you have not already done so, do a PubMed search.
My approach should work for recorded signals.

Accedi per commentare.

Categorie

Scopri di più su EEG/MEG/ECoG in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by