-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathISBI_LoadSubchallenge1Description.m
More file actions
64 lines (59 loc) · 2.23 KB
/
ISBI_LoadSubchallenge1Description.m
File metadata and controls
64 lines (59 loc) · 2.23 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
% Code used for the preparation and evaluation of the MEMENTO challenge
% organized by Kurt Schilling, Andrada Ianus and Alberto De Luca
% Code author: Alberto De Luca (a.deluca-2@umcutrecht.nl)
% This function can be used to read the acquisition settings corresponding to the
% provided signals
function data = ISBI_LoadSubchallenge1Description(protocol_description_file,acquisition_description_file)
% Read protocol description file
fields = {};
if(exist(protocol_description_file,'file') < 1)
error(['File ' protocol_description_file ' not found']);
end
fin = fopen(protocol_description_file,'rt');
while(~feof(fin))
line = fgetl(fin);
% if the first character is a number this is an entry
line = strtrim(line);
fc = str2double(line(1));
if(fc >= 0 && fc <= 9)
parts = strsplit(line,'-');
fields{end+1} = {str2double(parts{1}),parts{2},parts{3}};
end
end
fclose(fin);
% read the acquisition description file
if(exist(acquisition_description_file,'file') < 1)
error(['File ' acquisition_description_file ' not found']);
end
nfields = length(fields);
for field_id = 1:length(fields)
eval(['data.' fields{field_id}{2} ' = [];']);
end
fin = fopen(acquisition_description_file,'rt');
while(~feof(fin))
line = fgetl(fin);
parts = strsplit(line);
gparts = true(length(parts),1);
for part_id=1:length(parts)
if(isempty(parts{part_id}))
gparts(part_id) = false;
end
end
parts(~gparts) = [];
if(length(parts) ~= nfields)
error('The number of entries in the protocol description and in the acquistion file do not match');
end
for field_id=1:length(fields)
eval(['data.' strtrim(fields{field_id}{2}) '(end+1) = ' (parts{field_id}) ';']);
end
end
fclose(fin);
for field_id=1:length(fields)
eval(['data.' strtrim(fields{field_id}{2}) ' = ascolumn(' 'data.' strtrim(fields{field_id}{2}) ');']);
end
end
function S = ascolumn(S)
if(size(S,2) > size(S,1))
S = S';
end
end