How to apply a linear ramp to start and end of several EEG epochs to attenuate the abrupt onset and offset?

2 vues (au cours des 30 derniers jours)
Hey there! I have a set of auditory EEG data recorded collected with the presentation of auditory stimuli, where each stimulus consists of a 3-second speech with a 5-second inter-stimulus interval. Each stimulus onset is marked by an S1 trigger. Currently I have cut off the EEG data without audio input, but for the remain EEG data with auditory stimulation I would like to apply a linear ramp to to both sides of each trial corresponded neural response (10% at each side) to attenuate the abrupt onset and offset. Could you please help me with the code to accomplish this task? Thanks a lot!

Réponse acceptée

William Rose
William Rose le 6 Juin 2024
I will assume you have imported the EEG data into vector x, with T*Fs rows, where T=3 s=record duration, and Fs=sampling rate. I assume you want the signal to ramp up from 0 to full scale over the first 10% of the record, and ramp down from full scale to zero in the final 10%.
Fs=256; % sampling rate (Hz)
T=3; % record duration (s)
N=T*Fs; % record length (samples)
x=rand(N,1)-0.5; % simulated EEG signal with mean=0
t=(0:N-1)/Fs; % time vector (s)
Make the multiplier
m=ones(N,1);
Nt=round(N/10);
m(1:Nt)=(0:Nt-1)/Nt;
m(N-Nt+1:N)=(Nt-1:-1:0)/Nt;
Adjust the EEG signal
y=x.*m;
Plot results
subplot(211), plot(t,x,'-r'); grid on; ylabel('Original'); title('EEG')
subplot(212), plot(t,y,'-r'); grid on; ylabel('Adjusted'); xlabel('Time (s)')
OK

Plus de réponses (0)

Catégories

En savoir plus sur EEG/MEG/ECoG dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by