1 | %'read_multimadoc': read a set of Imadoc files for different file series and compare their timing |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % [XmlData,NbSlice_calib,time,warnmsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series) |
---|
4 | % |
---|
5 | % OUTPUT: |
---|
6 | % XmlData(iview): cell array of structures representing the contents of the xml files, iview =index of the input file series |
---|
7 | % NbSlice_calib: nbre of slices detected in the geometric calibration data |
---|
8 | % Time(iview,i,j): matrix of times, iview =index of the series, i,j=file indices within the series |
---|
9 | % warnmsg: warning message, ='' if OK |
---|
10 | % |
---|
11 | % INPUT: |
---|
12 | % RootPath,SubDir,RootFile,FileExt: cell arrays characterizing the input file series |
---|
13 | % i1_series,i2_series,j1_series,j2_series: cell arrays of file index arrays, as given by the fct uvmat/get_file_series |
---|
14 | % |
---|
15 | function [XmlData,NbSlice_calib,Time,warnmsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series) |
---|
16 | warnmsg=''; |
---|
17 | if ischar(RootPath) |
---|
18 | RootPath={RootPath};SubDir={SubDir};RootFile={RootFile};FileExt={FileExt}; |
---|
19 | end |
---|
20 | nbview=numel(RootPath); |
---|
21 | XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing) |
---|
22 | NbSlice_calib=cell(1,nbview); |
---|
23 | timecell=cell(1,nbview); |
---|
24 | for iview=1:nbview%Loop on views |
---|
25 | XmlFileName=find_imadoc(RootPath{iview},SubDir{iview},RootFile{iview},FileExt{iview}); |
---|
26 | if ~isempty(XmlFileName) |
---|
27 | [XmlData{iview},warnmsg]=imadoc2struct(XmlFileName);% read the ImaDoc xml file |
---|
28 | end |
---|
29 | if isfield(XmlData{iview},'Time') |
---|
30 | timecell{iview}=XmlData{iview}.Time; |
---|
31 | end |
---|
32 | if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') |
---|
33 | NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform |
---|
34 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
35 | warnmsg='inconsistent number of Z indices in field series'; |
---|
36 | end |
---|
37 | end |
---|
38 | end |
---|
39 | |
---|
40 | %% check coincidence in time for several input file series |
---|
41 | if isempty(timecell) |
---|
42 | Time=[]; |
---|
43 | else |
---|
44 | Time=get_time(timecell{1},i1_series{1},i2_series{1},j1_series{1},j2_series{1}); |
---|
45 | end |
---|
46 | if nbview>1 |
---|
47 | Time=shiftdim(Time,-1); % add a singleton dimension for nbview |
---|
48 | for icell=2:nbview |
---|
49 | if isequal(size(timecell{icell}),size(timecell{1})) |
---|
50 | time_line=get_time(timecell{icell},i1_series{icell},i2_series{icell},j1_series{icell},j2_series{icell}); |
---|
51 | Time=cat(1,Time,shiftdim(time_line,-1)); |
---|
52 | else |
---|
53 | msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used') |
---|
54 | Time=cat(1,Time,Time(1,:,:));% copy times of the first line |
---|
55 | break |
---|
56 | end |
---|
57 | end |
---|
58 | end |
---|
59 | |
---|
60 | function time=get_time(timeimadoc,i1_series,i2_series,j1_series,j2_series) |
---|
61 | if 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' |
---|
62 | time=[]; |
---|
63 | else |
---|
64 | timevect=timeimadoc'; |
---|
65 | if ~isempty(j1_series) |
---|
66 | vect_index=reshape(j1_series+(i1_series-1)*size(timevect,1),1,[]); |
---|
67 | time=timevect(vect_index); |
---|
68 | if ~isempty(j2_series) |
---|
69 | vect_index=reshape(j2_series+(i1_series-1)*size(timevect,1),1,[]); |
---|
70 | time=(time+timevect(vect_index))/2; |
---|
71 | end |
---|
72 | else |
---|
73 | time=timevect(i1_series); |
---|
74 | if ~isempty(i2_series) |
---|
75 | time=(time+timevect(i2_series))/2; |
---|
76 | end |
---|
77 | end |
---|
78 | end |
---|