31
elements
enabling technologies for Life Science
eONE - User’s guide
% check if the header file is present
headerFile = dir(strcat(pathname, basefilename,
'*.txt'
));
if
isempty(headerFile)
headerFile = dir(strcat(pathname, basefilename,
'*.edh'
));
end
if
length(headerFile) == 1
fid = fopen(fullfile(pathname, headerFile.name));
% open header file for read
% look for range and bandwidth data
while
1
line = fgetl(fid);
if
~ischar(line)
break
% empty header line, exit while cycle
end
% look for Channels line
if
strfind(line,
'Channels:'
) >= 0
[unused, remainder] = strtok(line);
secondToken = strtok(remainder);
Nch = str2double(secondToken);
display([
'Number of channels: '
, num2str(Nch)]);
end
% look for range line
if
strfind(line,
'Range:'
) >= 0
[unused, remainder] = strtok(line);
secondToken = strtok(remainder);
switch
str2double(secondToken)
case
200
range = 0; display(
'200 pA range'
);
case
20
range = 1;
display(
'20 nA range'
);
otherwise
display(
'Warning: cannot read range from header file, using default (200 pA)'
);
end
end
% look for bandwidth line
if
strfind(line,
'Bandwidth:'
) >= 0
[unused, remainder] = strtok(line);
secondToken = strtok(remainder);
switch
str2double(strtok(secondToken))
case
40
OSR = 32;
case
20
OSR = 32;
case
10
OSR = 64;
case
5
OSR = 128;
case
1.25
OSR = 512;
case
625
OSR = 1024;
end
end
% look for Post-filter line
if
strfind(line,
'Final Bandwidth:'
) >= 0
[unused, firstToken] = strtok(line);
[unused, secondToken] = strtok(firstToken);
switch
strtok(secondToken)
case
'SR/2 (no filter)'
PF = 0.5;
case
'SR/8'
PF = 0.125;
case
'SR/10'
PF = 0.1;
case
'SR/20'
PF = 0.05;
end
end