source: trunk/src/read_multimadoc.m @ 758

Last change on this file since 758 was 696, checked in by sommeria, 11 years ago

bugs corrected

File size: 3.5 KB
RevLine 
[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
[609]15%
[620]16function [XmlData,NbSlice_calib,Time,warnmsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series)
17warnmsg='';
[617]18if ischar(RootPath)
19    RootPath={RootPath};SubDir={SubDir};RootFile={RootFile};FileExt={FileExt};
20end
[469]21nbview=numel(RootPath);
[477]22XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing)
[469]23NbSlice_calib=cell(1,nbview);
24timecell=cell(1,nbview);
25for iview=1:nbview%Loop on views
26    XmlFileName=find_imadoc(RootPath{iview},SubDir{iview},RootFile{iview},FileExt{iview});
27    if ~isempty(XmlFileName)
[620]28        [XmlData{iview},warnmsg]=imadoc2struct(XmlFileName);% read the ImaDoc xml file
[469]29    end
30    if isfield(XmlData{iview},'Time')
31        timecell{iview}=XmlData{iview}.Time;
32    end
33    if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord')
34        NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform
35        if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
[620]36            warnmsg='inconsistent number of Z indices in field series';
[469]37        end
38    end
39end
40
41%% check coincidence in time for several input file series
42if isempty(timecell)
[620]43    Time=[];
[469]44else
[620]45    Time=get_time(timecell{1},i1_series{1},i2_series{1},j1_series{1},j2_series{1});
[469]46end
47if nbview>1
[620]48    Time=shiftdim(Time,-1); % add a singleton dimension for nbview
[469]49    for icell=2:nbview
50        if isequal(size(timecell{icell}),size(timecell{1}))
51            time_line=get_time(timecell{icell},i1_series{icell},i2_series{icell},j1_series{icell},j2_series{icell});
[620]52            Time=cat(1,Time,shiftdim(time_line,-1));
[469]53        else
54            msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used')
[620]55            Time=cat(1,Time,Time(1,:,:));% copy times of the first line
[469]56            break
57        end
58    end
59end
60
61function time=get_time(timeimadoc,i1_series,i2_series,j1_series,j2_series)
[675]62 time=[];
63 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'
64     if isempty(j1_series)
65         j1_series=1;
66     end
67     time=timeimadoc(i1_series+1,j1_series+1);
68     if ~isempty(j2_series)
69         time=[time timeimadoc(i1_series+1,j2_series+1)];
70     end
71     if ~isempty(i2_series)
72         time=[time timeimadoc(i2_series+1,j1_series+1)];
73         if ~isempty(j2_series)
74             time=[time timeimadoc(i2_series+1,j2_series+1)];
75         end
76     end
[696]77    time=mean(time,2);
78     time=time';
[675]79 end
Note: See TracBrowser for help on using the repository browser.