source: trunk/src/read_multimadoc.m @ 756

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

bugs corrected

File size: 3.5 KB
Line 
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%
16function [XmlData,NbSlice_calib,Time,warnmsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series)
17warnmsg='';
18if ischar(RootPath)
19    RootPath={RootPath};SubDir={SubDir};RootFile={RootFile};FileExt={FileExt};
20end
21nbview=numel(RootPath);
22XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing)
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)
28        [XmlData{iview},warnmsg]=imadoc2struct(XmlFileName);% read the ImaDoc xml file
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})
36            warnmsg='inconsistent number of Z indices in field series';
37        end
38    end
39end
40
41%% check coincidence in time for several input file series
42if isempty(timecell)
43    Time=[];
44else
45    Time=get_time(timecell{1},i1_series{1},i2_series{1},j1_series{1},j2_series{1});
46end
47if nbview>1
48    Time=shiftdim(Time,-1); % add a singleton dimension for nbview
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});
52            Time=cat(1,Time,shiftdim(time_line,-1));
53        else
54            msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used')
55            Time=cat(1,Time,Time(1,:,:));% copy times of the first line
56            break
57        end
58    end
59end
60
61function time=get_time(timeimadoc,i1_series,i2_series,j1_series,j2_series)
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
77    time=mean(time,2);
78     time=time';
79 end
Note: See TracBrowser for help on using the repository browser.