Mercurial > hg > dcase2013_ed_vuegenetal
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/functions/funcsMobilab/read_annotation_develop.m Fri Oct 11 12:02:43 2013 +0100 @@ -0,0 +1,31 @@ +function [startStop labels] = read_annotation_develop(directory, fileID) +%% Open corresponding textfile +fid=fopen([directory filesep fileID], 'r'); +text = fread(fid, '*char'); +fclose(fid); +%% Preallocation +% Find rows (separated by enter) and is equal by the nr of Events +posEnter = strfind(text', char(10)); +nrEvents = length(posEnter); +% Preallocation for speed +startStop = zeros(nrEvents,2); +labels = cell(nrEvents,1); +%% Extract data from the script +%First event +subText = text(1:posEnter(1,1)-1)'; +%Find tab positions +tabs = strfind(subText, char(9)); +startStop(1,1) = str2num(subText(1:tabs(1)-1)); +startStop(1,2) = str2num(subText(tabs(1)+1:tabs(2)-1)); +labels{1,1} = subText(tabs(2)+1:length(subText)); + +%All remaining events +for(eventNr=2:nrEvents) + subText = text(posEnter(1,eventNr-1)+1:posEnter(1,eventNr)-1)'; + %Find tab positions + tabs = strfind(subText, char(9)); + startStop(eventNr,1) = str2num(subText(1:tabs(1)-1)); + startStop(eventNr,2) = str2num(subText(tabs(1)+1:tabs(2)-1)); + labels{eventNr,1} = subText(tabs(2)+1:length(subText)); +end, +end \ No newline at end of file