Biopac 数据导入 matlab 处理方法
第一步:在 AcqKnowledge 软件中,将数据通道的 mark 信息导入到 Graph,并将数据存储为 acq3 的格式
第二步:MATLAB中读取acq3文件脚本
clc
clear
%%%所有被试这一层路径
pathsub = fullfile(fileparts(pwd),'data1_origin');
dirsub = dir(pathsub);
namesub={dirsub.name};
for nsub = 3:length(namesub)
%%%每个被试这一层路径
pathdata = fullfile(pathsub,namesub{nsub});
dirdata = dir(pathdata);
namedata = {dirdata.name};
for ndata = 3:length(namedata)
acq_name = fullfile(pathdata,namedata{ndata});
acq=load_acq(acq_name);
marker_scan=[];
marker_scan(1,:)=acq.markers.lSample(1,:);
marker_name=acq.markers.szText;
%% 将文本转为数字 segment -> 555
[~,idx]=ismember(marker_name,{'Segment 1','Segment 2','Segment 3'});%
a=find(idx~=0);
if isempty(a)==0
for k=1:length(a)
marker_name{1,a(k)}='555';
end
end
marker_name=str2num(char(marker_name));
marker_scan(2,:)=marker_name;
marker_scan=transpose(marker_scan);
% 删除静息 mark 和分段 mark
b=find(marker_scan(:,2) == 555);
b=sort(b,'descend');
for n_b=1:length(b)
marker_scan(b(n_b),:)=[];
end
marker_time=marker_scan;
namesave = namedata{ndata}(1:end-4);
if ~exist(fullfile(fileparts(pwd),'data2_mat',namesub{nsub}),'dir')
mkdir(pathsave);
end
pathsave = fullfile(fileparts(pwd),'data2_mat',namesub{nsub},strcat(namesave,'.mat'));
save(pathsave, 'acq', 'marker_time');
end
end