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 | % if the time is not consistent in all series, the time from the first series is chosen |
---|
10 | % warnmsg: warning message, ='' if OK |
---|
11 | % |
---|
12 | % INPUT: |
---|
13 | % RootPath,SubDir,RootFile,FileExt: cell arrays characterizing the input file series |
---|
14 | % i1_series,i2_series,j1_series,j2_series: cell arrays of file index arrays, as given by the fct uvmat/get_file_series |
---|
15 | |
---|
16 | %======================================================================= |
---|
17 | % Copyright 2008-2016, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
18 | % http://www.legi.grenoble-inp.fr |
---|
19 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
20 | % |
---|
21 | % This file is part of the toolbox UVMAT. |
---|
22 | % |
---|
23 | % UVMAT is free software; you can redistribute it and/or modify |
---|
24 | % it under the terms of the GNU General Public License as published |
---|
25 | % by the Free Software Foundation; either version 2 of the license, |
---|
26 | % or (at your option) any later version. |
---|
27 | % |
---|
28 | % UVMAT is distributed in the hope that it will be useful, |
---|
29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
31 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
32 | %======================================================================= |
---|
33 | |
---|
34 | function [XmlData,NbSlice_calib,Time,warnmsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series) |
---|
35 | warnmsg=''; |
---|
36 | if ischar(RootPath) |
---|
37 | RootPath={RootPath};SubDir={SubDir};RootFile={RootFile};FileExt={FileExt}; |
---|
38 | end |
---|
39 | nbview=numel(RootPath); |
---|
40 | XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing) |
---|
41 | NbSlice_calib=cell(1,nbview); |
---|
42 | timecell=cell(1,nbview); |
---|
43 | for iview=1:nbview%Loop on views |
---|
44 | XmlFileName=find_imadoc(RootPath{iview},SubDir{iview},RootFile{iview},FileExt{iview}); |
---|
45 | if ~isempty(XmlFileName) |
---|
46 | [XmlData{iview},warnmsg]=imadoc2struct(XmlFileName);% read the ImaDoc xml file |
---|
47 | end |
---|
48 | if isfield(XmlData{iview},'Time') |
---|
49 | timecell{iview}=XmlData{iview}.Time; |
---|
50 | end |
---|
51 | if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') |
---|
52 | NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform |
---|
53 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
54 | warnmsg='inconsistent number of Z indices in field series'; |
---|
55 | end |
---|
56 | end |
---|
57 | end |
---|
58 | |
---|
59 | %% check coincidence in time for several input file series |
---|
60 | if isempty(timecell) |
---|
61 | Time=[]; |
---|
62 | else |
---|
63 | Time=get_time(timecell{1},i1_series{1},i2_series{1},j1_series{1},j2_series{1}); |
---|
64 | end |
---|
65 | if nbview>1 |
---|
66 | Time=shiftdim(Time,-1); % add a singleton dimension for nbview |
---|
67 | for icell=2:nbview |
---|
68 | if isequal(size(timecell{icell}),size(timecell{1})) |
---|
69 | time_line=get_time(timecell{icell},i1_series{icell},i2_series{icell},j1_series{icell},j2_series{icell}); |
---|
70 | Time=cat(1,Time,shiftdim(time_line,-1)); |
---|
71 | else |
---|
72 | warnmsg='inconsistent time array dimensions in ImaDoc fields, the time for the first series is used'; |
---|
73 | Time=cat(1,Time,Time(1,:,:));% copy times of the first line |
---|
74 | break |
---|
75 | end |
---|
76 | end |
---|
77 | end |
---|
78 | |
---|
79 | function time=get_time(timeimadoc,i1_series,i2_series,j1_series,j2_series) |
---|
80 | time=[]; |
---|
81 | 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' |
---|
82 | if isempty(j1_series) |
---|
83 | j1_series=1; |
---|
84 | end |
---|
85 | time=timeimadoc(i1_series+1,j1_series+1); |
---|
86 | if ~isempty(j2_series) |
---|
87 | time=[time timeimadoc(i1_series+1,j2_series+1)]; |
---|
88 | end |
---|
89 | if ~isempty(i2_series) |
---|
90 | time=[time timeimadoc(i2_series+1,j1_series+1)]; |
---|
91 | if ~isempty(j2_series) |
---|
92 | time=[time timeimadoc(i2_series+1,j2_series+1)]; |
---|
93 | end |
---|
94 | end |
---|
95 | time=mean(time,2); |
---|
96 | time=time'; |
---|
97 | end |
---|