forked from alexander-pastukhov/edfImport
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedfSelectSampleFields.m
33 lines (28 loc) · 1.28 KB
/
edfSelectSampleFields.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [FieldFlags]= edfSelectSampleFields(FieldNames)
%% edfImport library v1.0
% Alexander Pastukhov
% kobi.nat.uni-magdeburg.de/edfImport
% email: pastukhov.alexander@gmail.com
%
% Converts list of space-separated names of FSAMPLE structure
% fields into a boolean array of flags, later passed to
% edfMexImport function. Used by edfImport.
%% Names of fields from FSAMPLE structure
SampleFields= {'time', 'flags', 'px', 'py', 'hx', 'hy', 'pa', 'gx', 'gy', 'rx', 'ry', 'status', 'input', 'buttons', 'htype', 'hdata', 'errors', 'gxvel', 'gyvel', 'hxvel', 'hyvel', 'rxvel', 'ryvel', 'fgxvel', 'fgyvel', 'fhxvel', 'fhyvel', 'frxvel', 'fryvel'};
FieldFlags= zeros(1, 29);
%% getting read of extra spaces
FieldNames= strtrim(FieldNames);
%% locating all words in-between spaces
[iStart, iEnd]= regexp(FieldNames, '[ ]*');
iWordStart= [1 iEnd+1];
iWordEnd= [iStart-1 length(FieldNames)];
%% looping through words in-between spaces
for iS= 1:length(iWordStart),
CurrentName= FieldNames(iWordStart(iS):iWordEnd(iS));
iField= find(strcmp(SampleFields, CurrentName));
if (~isempty(iField))
FieldFlags(iField)= 1;
elseif (length(CurrentName)>0)
throw(MException('edfMATLAB:edfSelectSampleFields:BadFieldName', 'Unknown FSAMPLE structure field "%s"', CurrentName));
end;
end;