使用biopac软件记录了心电,肌电和皮电数据后,将数据导入到eeglab中,发现,缺少event信息,也就是,EEG.event是空的,同时,在EEG.data里发现,除了记录的数据,mark信息是在多个channel中保存的,比如:第16导记录的是1,第15导记录的是2,第14导记录的是4,以此类推。如果mark是5,那么会在第16导和第14导都有记录,通过两个导的相加得到实际的mark。
以下函数可以自动将10-16导记录的mark信息转换成EEG.event, 这样就可以像脑电数据那样在EEGLAB中进行分析了
function eventMaker(savename,savepath)
%this function is for making EEG.event after importing the biopac data into
%EEGLAB with the biopac extention
%input: a string to indicate the name of the saved file after running
%this function ; a string to inciate the location to place the data
%output: an EEG .set data and .fdt data
%the function assumes that channel 10 to channel 16 are the channels to
%record event triggers; channel 10 represents 2^7, channel 11 represents
%2^6, channel 12 represents 2^5, and so forth. Event markers are the sum
%of all seven channels in a specific time points
%the result is an EEG structure with the updated EEG.event, EEG.urevent and
%EEG.enentdescription
markers=[];
EEG.data(10:16,:)=EEG.data(10:16,:)/5;
base=[];
for j=10:16
base(j-9)=2^(16-j);
end
mchannel=[];
for i=1:size(EEG.times,2)
mchannel(1:7,i)=base.*vec2mat(EEG.data(10:16,i),7);
end
for i=1:size(EEG.times,2)
markers(i)=sum(mchannel(1:7,i));
end
event=[];
events=[];
timepoint=[];
sequence=0;
EEG.event.type=0;
EEG.event.latency=0;
EEG.event.urevent=0;
for i=2:size(EEG.times,2)
if markers(i)>0 & markers(i)~=markers(i-1)
event=markers(i);
timepoint=EEG.times(i);
sequence=sequence+1;
EEG.event(sequence).type=event;
EEG.event(sequence).latency=timepoint;
EEG.event(sequence).urevent=sequence;
%events=[event,timepoint,sequence];
%EEG.event=[EEG.event;events];
end
end
EEG.urevent=EEG.event;
EEG.eventdescription={0,0,0};
pop_saveset( EEG, 'filename',savename,'filepath',savepath);