1 | function [XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series) |
---|
2 | nbview=numel(RootPath); |
---|
3 | NbSlice_calib=cell(1,nbview); |
---|
4 | timecell=cell(1,nbview); |
---|
5 | XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing) |
---|
6 | for 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 |
---|
23 | end |
---|
24 | |
---|
25 | %% check coincidence in time for several input file series |
---|
26 | if isempty(timecell) |
---|
27 | time=[]; |
---|
28 | else |
---|
29 | time=get_time(timecell{1},i1_series{1},i2_series{1},j1_series{1},j2_series{1}); |
---|
30 | end |
---|
31 | if 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 |
---|
43 | end |
---|
44 | |
---|
45 | function time=get_time(timeimadoc,i1_series,i2_series,j1_series,j2_series) |
---|
46 | if 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=[]; |
---|
48 | else |
---|
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 |
---|
63 | end |
---|