[620] | 1 | %'read_multimadoc': read a set of Imadoc files for different file series and compare their timing |
---|
[477] | 2 | %------------------------------------------------------------------------ |
---|
[620] | 3 | % [XmlData,NbSlice_calib,time,warnmsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series) |
---|
[477] | 4 | % |
---|
| 5 | % OUTPUT: |
---|
[620] | 6 | % XmlData(iview): cell array of structures representing the contents of the xml files, iview =index of the input file series |
---|
[609] | 7 | % NbSlice_calib: nbre of slices detected in the geometric calibration data |
---|
[620] | 8 | % Time(iview,i,j): matrix of times, iview =index of the series, i,j=file indices within the series |
---|
[675] | 9 | % if the time is not consistent in all series, the time from the first series is chosen |
---|
[620] | 10 | % warnmsg: warning message, ='' if OK |
---|
[477] | 11 | % |
---|
| 12 | % INPUT: |
---|
[609] | 13 | % RootPath,SubDir,RootFile,FileExt: cell arrays characterizing the input file series |
---|
[620] | 14 | % i1_series,i2_series,j1_series,j2_series: cell arrays of file index arrays, as given by the fct uvmat/get_file_series |
---|
[809] | 15 | |
---|
| 16 | %======================================================================= |
---|
| 17 | % Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France |
---|
| 18 | % http://www.legi.grenoble-inp.fr |
---|
| 19 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
[609] | 20 | % |
---|
[809] | 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 | |
---|
[620] | 34 | function [XmlData,NbSlice_calib,Time,warnmsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series) |
---|
| 35 | warnmsg=''; |
---|
[617] | 36 | if ischar(RootPath) |
---|
| 37 | RootPath={RootPath};SubDir={SubDir};RootFile={RootFile};FileExt={FileExt}; |
---|
| 38 | end |
---|
[469] | 39 | nbview=numel(RootPath); |
---|
[477] | 40 | XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing) |
---|
[469] | 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) |
---|
[620] | 46 | [XmlData{iview},warnmsg]=imadoc2struct(XmlFileName);% read the ImaDoc xml file |
---|
[469] | 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}) |
---|
[620] | 54 | warnmsg='inconsistent number of Z indices in field series'; |
---|
[469] | 55 | end |
---|
| 56 | end |
---|
| 57 | end |
---|
| 58 | |
---|
| 59 | %% check coincidence in time for several input file series |
---|
| 60 | if isempty(timecell) |
---|
[620] | 61 | Time=[]; |
---|
[469] | 62 | else |
---|
[620] | 63 | Time=get_time(timecell{1},i1_series{1},i2_series{1},j1_series{1},j2_series{1}); |
---|
[469] | 64 | end |
---|
| 65 | if nbview>1 |
---|
[620] | 66 | Time=shiftdim(Time,-1); % add a singleton dimension for nbview |
---|
[469] | 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}); |
---|
[620] | 70 | Time=cat(1,Time,shiftdim(time_line,-1)); |
---|
[469] | 71 | else |
---|
| 72 | msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used') |
---|
[620] | 73 | Time=cat(1,Time,Time(1,:,:));% copy times of the first line |
---|
[469] | 74 | break |
---|
| 75 | end |
---|
| 76 | end |
---|
| 77 | end |
---|
| 78 | |
---|
| 79 | function time=get_time(timeimadoc,i1_series,i2_series,j1_series,j2_series) |
---|
[675] | 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 |
---|
[696] | 95 | time=mean(time,2); |
---|
| 96 | time=time'; |
---|
[809] | 97 | end |
---|