source: trunk/src/read_multimadoc.m @ 469

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

several bugs corrected
introductyion of functions find_imadoc and read_multimadoc which simplifiy the functions under series

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