Carrying on from the above that just diddled with the file format to be able to get the data; the following seems to work:
filename = 'Imagine_simple-1-1.txt';
onsets={'Tune.OnsetTime';'ImagineMelody.OnsetTime';'WaitForScanner.OnsetTime'};
imaginefile = 'ImagineMelody.OnsetTime.txt';
tunefile = 'Tune.OnsetTime.txt';
txt=importdata(filename);
txt=strrep(txt,char(0),'');
txt=strrep(txt,char(255:-1:254),'');
fnGrabNum=@(t) (str2double(extractAfter(txt(contains(txt,t)),':'))/1000);
times=cellfun(fnGrabNum,onsets,'UniformOutput',0);
elapsedtimes=seconds(cell2mat(cellfun(@(t) t-times{3},times(1:2),'UniformOutput',0).'));
Results in:
>> elapsedtimes
elapsedtimes =
20×2 duration array
3.233 sec 16.232 sec
55.402 sec 42.23 sec
81.644 sec 94.642 sec
133.88 sec 120.64 sec
160.07 sec 173.07 sec
212.27 sec 199.07 sec
238.45 sec 251.46 sec
290.68 sec 277.46 sec
316.91 sec 329.91 sec
369.07 sec 355.9 sec
395.25 sec 408.25 sec
447.46 sec 434.25 sec
473.69 sec 486.69 sec
525.86 sec 512.69 sec
552.03 sec 565.04 sec
604.22 sec 591.03 sec
630.4 sec 643.41 sec
682.6 sec 669.41 sec
708.79 sec 721.79 sec
761.16 sec 747.79 sec
>>
Best Answer