Mercurial > hg > dcase2013_ed_vuegenetal
comparison functions/funcsMobilab/read_annotation_develop.m @ 0:2fadb31a9d55 tip
Import code by Vuegen et al
author | Dan Stowell <dan.stowell@elec.qmul.ac.uk> |
---|---|
date | Fri, 11 Oct 2013 12:02:43 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2fadb31a9d55 |
---|---|
1 function [startStop labels] = read_annotation_develop(directory, fileID) | |
2 %% Open corresponding textfile | |
3 fid=fopen([directory filesep fileID], 'r'); | |
4 text = fread(fid, '*char'); | |
5 fclose(fid); | |
6 %% Preallocation | |
7 % Find rows (separated by enter) and is equal by the nr of Events | |
8 posEnter = strfind(text', char(10)); | |
9 nrEvents = length(posEnter); | |
10 % Preallocation for speed | |
11 startStop = zeros(nrEvents,2); | |
12 labels = cell(nrEvents,1); | |
13 %% Extract data from the script | |
14 %First event | |
15 subText = text(1:posEnter(1,1)-1)'; | |
16 %Find tab positions | |
17 tabs = strfind(subText, char(9)); | |
18 startStop(1,1) = str2num(subText(1:tabs(1)-1)); | |
19 startStop(1,2) = str2num(subText(tabs(1)+1:tabs(2)-1)); | |
20 labels{1,1} = subText(tabs(2)+1:length(subText)); | |
21 | |
22 %All remaining events | |
23 for(eventNr=2:nrEvents) | |
24 subText = text(posEnter(1,eventNr-1)+1:posEnter(1,eventNr)-1)'; | |
25 %Find tab positions | |
26 tabs = strfind(subText, char(9)); | |
27 startStop(eventNr,1) = str2num(subText(1:tabs(1)-1)); | |
28 startStop(eventNr,2) = str2num(subText(tabs(1)+1:tabs(2)-1)); | |
29 labels{eventNr,1} = subText(tabs(2)+1:length(subText)); | |
30 end, | |
31 end |