source: trunk/src/read_multimadoc.m @ 617

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

minor cleaning. Option 'double -click' on mouse selection introduced on browser but commented.

File size: 3.4 KB
Line 
1%'read_multimadoc': read a set of Imadoc files and compare their timing of different file series
2%------------------------------------------------------------------------
3% [XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series)
4%
5% OUTPUT:
6% XmlData: cell array of structure representing the contents of the xml files
7% NbSlice_calib: nbre of slices detected in the geometric calibration data
8% mtrix of times
9% errormsg: error message, ='' if reading 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
14% arrays, as given by the fct uvmat/get_file_series
15%
16function [XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series)
17errormsg='';
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},errormsg]=imadoc2struct(XmlFileName);% read the ImaDoc xml file
29        if ~isempty(errormsg)
30            return
31        end
32    end
33    if isfield(XmlData{iview},'Time')
34        timecell{iview}=XmlData{iview}.Time;
35    end
36    if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord')
37        NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform
38        if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
39            msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
40        end
41    end
42end
43
44%% check coincidence in time for several input file series
45if isempty(timecell)
46    time=[];
47else
48    time=get_time(timecell{1},i1_series{1},i2_series{1},j1_series{1},j2_series{1});
49end
50if nbview>1
51    time=shiftdim(time,-1); % add a singleton dimension for nbview
52    for icell=2:nbview
53        if isequal(size(timecell{icell}),size(timecell{1}))
54            time_line=get_time(timecell{icell},i1_series{icell},i2_series{icell},j1_series{icell},j2_series{icell});
55            time=cat(1,time,shiftdim(time_line,-1));
56        else
57            msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used')
58            time=cat(1,time,time(icell-1,:,:));
59            break
60        end
61    end
62end
63
64function time=get_time(timeimadoc,i1_series,i2_series,j1_series,j2_series)
65if 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'
66    time=[];
67else
68    timevect=timeimadoc';
69    if ~isempty(j1_series)
70        vect_index=reshape(j1_series+(i1_series-1)*size(timevect,1),1,[]);
71        time=timevect(vect_index);
72        if ~isempty(j2_series)
73            vect_index=reshape(j2_series+(i1_series-1)*size(timevect,1),1,[]);
74            time=(time+timevect(vect_index))/2;
75        end
76    else
77        time=timevect(i1_series);
78        if ~isempty(i2_series)
79            time=(time+timevect(i2_series))/2;
80        end
81    end
82end
Note: See TracBrowser for help on using the repository browser.