source: trunk/src/xmlburst2time.m @ 1149

Last change on this file since 1149 was 1149, checked in by sommeria, 3 months ago

extract_rdvision improved by automatic production of the xml file from timestamps

File size: 2.2 KB
Line 
1function TimeMatrix=xmlburst2time(BurstTiming,FirstFrameIndexI)
2if ~exist('FirstFrameIndexI','var')
3    FirstFrameIndexI=1;
4end
5if ~iscell(BurstTiming)
6    BurstTiming={BurstTiming};
7    BurstTiming{1}.Time=0;%time origin set to zero by default
8end
9TimeMatrix=[];
10for k=1:length(BurstTiming)
11    Frequency=1;
12    if isfield(BurstTiming{k},'FrameFrequency')
13        Frequency=BurstTiming{k}.FrameFrequency;
14    end
15    Dtj=[];
16    if isfield(BurstTiming{k},'Dtj')
17        Dtj=BurstTiming{k}.Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's');
18    end
19    NbDtj=1;
20    if isfield(BurstTiming{k},'NbDtj')&&~isempty(BurstTiming{k}.NbDtj)
21        NbDtj=BurstTiming{k}.NbDtj;
22    end
23    Dti=[];
24    if isfield(BurstTiming{k},'Dti')
25        Dti=BurstTiming{k}.Dti/Frequency;%Dti converted from frame unit to TimeUnit (e.g. 's');
26    end
27    NbDti=1;
28    if isfield(BurstTiming{k},'NbDti')&&~isempty(BurstTiming{k}.NbDti)
29        NbDti=BurstTiming{k}.NbDti;
30    end
31    Time_val=BurstTiming{k}.Time;%time in TimeUnit
32    if ~isempty(Dti)
33        Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times
34        Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals  Dti
35    end
36    if ~isempty(Dtj)
37        Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dtj vector NbDtj times
38        Dtj=[0 Dtj];
39        Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj
40    end
41    % reading Dtk
42    Dtk=[];%default
43    NbDtk=1;%default
44    if isfield(BurstTiming{k},'Dtk')
45        Dtk=BurstTiming{k}.Dtk;
46    end
47    if isfield(BurstTiming{k},'NbDtk')&&~isempty(BurstTiming{k}.NbDtk)
48        NbDtk=BurstTiming{k}.NbDtk;
49    end
50    if isempty(Dtk)
51        TimeMatrix=[TimeMatrix;Time_val];
52    else
53        for kblock=1:NbDtk+1
54            Time_val_k=Time_val+(kblock-1)*Dtk;
55            TimeMatrix=[TimeMatrix;Time_val_k];
56        end
57    end
58end
59TimeMatrix=[zeros(size(TimeMatrix,1),1) TimeMatrix]; %insert a vertical line of zeros (to deal with zero file indices)
60    if FirstFrameIndexI~=0
61    TimeMatrix=[zeros(FirstFrameIndexI,size(TimeMatrix,2)); TimeMatrix]; %insert a horizontal line of zeros
62    end
Note: See TracBrowser for help on using the repository browser.