For most signals of VEP,  when the stimuli occurs , the response  are expected from our brain then recored by the EEG,  in thi case    we have observed the timepoint and try to cut the signals with same length, as usual,  the averaged signal could give more useful and markable information .

we have a example code from EMG,  right or left hands had been lifted when the signal was given, we have three kind types of  data and 32 channels .

微信截图_20160311163924

signal markers:

 

clear all;
%% parameter
sr=10.24;%resample rate
channel=5;%channel
segment_length=50;%
segment_tplength=round(sr*segment_length);% data length
select_type=1;
%% mark the movement time lind

load(‘fNIRSdata.mat’);

right_hand=find(stimarker(:,1)==1);% find the movement
left_hand=find(stimarker(:,2)==1);

signal=Hbdata(:,select_type,channel);%get the signal

figure
plot(taxis,signal);hold on

for i=1:length(right_hand)

plot([taxis(right_hand(i)),taxis(right_hand(i))],[min(signal),max(signal)],’r–‘,’linewidth’,2);

end
for i=1:length(left_hand)

plot([taxis(left_hand(i)),taxis(left_hand(i))],[min(signal),max(signal)] ,’k–‘,’linewidth’,2)
% plot the mark with fuction ([x,x],[y,y])
end
xlabel(‘time’);
ylabel(‘H2o’);

%% segment signals
rightsignal=[];
leftsignal=[];
for i=1:length(right_hand)
rightsignal(:,i)=signal(right_hand(i):right_hand(i)+segment_tplength-1);
%cut and store the signal
end
for i=1:length(left_hand)
leftsignal(:,i)=signal(left_hand(i):left_hand(i)+segment_tplength-1);

end

meanright=mean(rightsignal,2);
meanleft=mean(leftsignal,2);% mean for column

figure
plot(1:segment_tplength,meanright,’r’);
hold on

plot(1:segment_tplength,meanleft,’b’);

legend(‘right’,’left’)

微信截图_20160311182545 微信截图_20160311182634