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