source: trunk/src/read_multimadoc.m @ 537

Last change on this file since 537 was 537, checked in by sommeria, 12 years ago

various bugs fixed. Use of the free pair option '*-*' in series.

File size: 2.9 KB
Line 
1%'read_multimadoc': read a set of Imadoc files and compare their timing of different file series
2%------------------------------------------------------------------------
3% [XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series)
4%
5% OUTPUT:
6%
7%
8% INPUT:
9%
10function [XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series)
11errormsg='';
12nbview=numel(RootPath);
13XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing)
14NbSlice_calib=cell(1,nbview);
15timecell=cell(1,nbview);
16for iview=1:nbview%Loop on views
17    XmlFileName=find_imadoc(RootPath{iview},SubDir{iview},RootFile{iview},FileExt{iview});
18    if ~isempty(XmlFileName)
19        [XmlData{iview},errormsg]=imadoc2struct(XmlFileName);% read the ImaDoc xml file
20        if ~isempty(errormsg)
21            return
22        end
23    end
24    if isfield(XmlData{iview},'Time')
25        timecell{iview}=XmlData{iview}.Time;
26    end
27    if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord')
28        NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform
29        if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
30            msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
31        end
32    end
33end
34
35%% check coincidence in time for several input file series
36if isempty(timecell)
37    time=[];
38else
39    time=get_time(timecell{1},i1_series{1},i2_series{1},j1_series{1},j2_series{1});
40end
41if nbview>1
42    time=shiftdim(time,-1); % add a singleton dimension for nbview
43    for icell=2:nbview
44        if isequal(size(timecell{icell}),size(timecell{1}))
45            time_line=get_time(timecell{icell},i1_series{icell},i2_series{icell},j1_series{icell},j2_series{icell});
46            time=cat(1,time,shiftdim(time_line,-1));
47        else
48            msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used')
49            time=cat(1,time,time(icell-1,:,:));
50            break
51        end
52    end
53end
54
55function time=get_time(timeimadoc,i1_series,i2_series,j1_series,j2_series)
56if isempty(i2_series)||size(timeimadoc,1) < i2_series(end) ||( ~isempty(j2_series) && size(timeimadoc,2) < j2_series(end))% time array absent or too short in ImaDoc xml file'
57    time=[];
58else
59    timevect=timeimadoc';
60    if ~isempty(j1_series)
61        vect_index=reshape(j1_series+(i1_series-1)*size(timevect,1),1,[]);
62        time=timevect(vect_index);
63        if ~isempty(j2_series)
64            vect_index=reshape(j2_series+(i1_series-1)*size(timevect,1),1,[]);
65            time=(time+timevect(vect_index))/2;
66        end
67    else
68        time=timevect(i1_series);
69        if ~isempty(i2_series)
70            time=(time+timevect(i2_series))/2;
71        end
72    end
73end
Note: See TracBrowser for help on using the repository browser.