comparison evaluationtools/merge_repeats.m @ 1:8973548174c1 tip

adding tools to repo
author christopherh
date Mon, 06 May 2013 14:43:47 +0100
parents
children
comparison
equal deleted inserted replaced
0:0a4ad3e72e75 1:8973548174c1
1
2 % merge contiguous repeated chord labels in a labfile
3
4 function [t1,t2,s] = merge_repeats(labfile, outputlabfile)
5
6 writefile = 1;
7
8 if nargin<2
9 % if no output labfile name is given then don't write output to a file
10 writefile=0;
11 end
12
13 t1 = [];
14 t2 = [];
15 s = {};
16
17 [in_t1,in_t2,in_s] = labread(labfile);
18
19 current = in_s{1};
20 temp1 = in_t1(1);
21
22 for i=1:length(in_s)-1
23
24 next = in_s{i+1};
25
26 % if current is the same as next
27 if ~strcmp(current,next)
28 t1 = [t1; temp1];
29 t2 = [t2; in_t2(i)];
30 s = [s; {current}];
31 current = next;
32 temp1 = in_t1(i+1);
33 end
34
35 if i==length(in_s)-1
36 t1 = [t1; temp1];
37 t2 = [t2; in_t2(i+1)];
38 s = [s; {current}];
39 end
40
41 end
42
43 if writefile
44
45 labwrite(t1,t2,s,outputlabfile);
46 end