comparison nonExposed/loadEventsList.m @ 14:b1901e8d8f5f

initial commit
author Mathieu Lagrange <mathieu.lagrange@cnrs.fr>
date Tue, 17 Mar 2015 09:34:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 14:b1901e8d8f5f
1 function [onset,offset,classNames] = loadEventsList(filename)
2
3 % This program was written by Mathias Rossignol & Grégoire Lafay
4 % is Copyright (C) 2015 IRCAM <http://www.ircam.fr>
5 %
6 % This program is free software: you can redistribute it and/or modify it
7 % under the terms of the GNU General Public License as published by the Free
8 % Software Foundation, either version 3 of the License, or (at your option)
9 % any later version.
10 %
11 % This program is distributed in the hope that it will be useful, but
12 % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 % for more details.
15 %
16 % You should have received a copy of the GNU General Public License along
17 % with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 % Open raw file
20 fid = fopen(filename,'r+');
21
22 % Read 1st line
23 tline = fgetl(fid);
24 onset_offset(:,1) = sscanf(tline, '%f\t%f\t%*s');
25 classNames{1} = char(sscanf(tline, '%*f\t%*f\t%s')');
26
27 % Read rest of the lines
28 i=1;
29 while ischar(tline)
30 i = i+1;
31 tline = fgetl(fid);
32 if (ischar(tline))
33 onset_offset(:,i) = sscanf(tline, '%f\t%f\t%*s');
34 classNames{i} = char(sscanf(tline, '%*f\t%*f\t%s')');
35 end;
36 end
37
38 % Split onset_offset
39 onset = onset_offset(1,:)';
40 offset = onset_offset(2,:)';
41
42 % Close file
43 fclose(fid);