資源簡介
EEG 讀取的文件
代碼片段和文件信息
%----------------------------------------------------------------------
%FileName:?ReadEEG_vhdr.m
%FunctionName:?ReadEEG_vhdr
%Usage:?read?.eeg?and?.vmrk?file?through?reading?.vhdr?file
%Author:?Chen?Qian
%Date:?2018-01-08
%----------------------------------------------------------------------
function?[Mat_rawconfig]?=?ReadEEG_vhdr(?dir_path?)
%ReadEEG_vhdr?Summary?of?this?function?goes?here
%???vhdr?format?eeg?signal?read?--->?eeg?raw?signal?in?Mat_raw?vhdr?info
%???in?config?vmrk?info?in?config.mark
%???Detailed?explanation?goes?here
%?Read?vhdr?file?to?obtain?the?information?of?files
vhdr?=?dir([dir_path‘*.vhdr‘]);
vhdr_path?=?[dir_path?vhdr.name];
fp?=?fopen(vhdr_path);
if?fp?==?-1
error(‘ERR:ReadEEG_vhdr:FileNotReadable‘‘Couldn‘‘t?read?header?file‘)
end
%?read?the?whole?file?as?one?cell?array
raw={};
while?~feof(fp)
????raw?=?[raw;?{fgetl(fp)}];
end
fclose(fp);
%?Remove?comments?and?empty?lines
raw(strmatch(‘;‘?raw))?=?[];
raw(cellfun(‘isempty‘?raw)?==?true)?=?[];
n_line?=?length(raw);
for?i=1:n_line
???if(strfind(raw{i}‘=‘))
???????S?=?regexp(raw(i)‘=‘‘split‘);
???????switch?(S{1}{1})
???????????case?‘DataFile‘
???????????????config.eegName?=?S{1}{2};
???????????case?‘MarkerFile‘
???????????????config.markName?=?S{1}{2};
???????????case?‘NumberOfChannels‘
???????????????config.Nchannel?=?str2num(S{1}{2});
???????????case?‘DataPoints‘
???????????????config.DataPoints?=?str2num(S{1}{2});
???????????case?‘SamplingInterval‘
???????????????config.SamplingInterval?=?str2num(S{1}{2});
???????????????config.SampleFrequency?=?1000000/config.SamplingInterval;
???????????case?‘BinaryFormat‘
???????????????config.BinaryFormat?=?S{1}{2};
???????end
???end
end
%
評論
共有 條評論