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

4 次查看(过去 30 天)
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!

采纳的回答

William Rose
William Rose 2024-6-6
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

更多回答(0 个)

类别

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

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by