source: trunk/src/imadoc2struct.m @ 1184

Last change on this file since 1184 was 1184, checked in by sommeria, 5 weeks ago

bed-scan updated and many updates

File size: 2.9 KB
RevLine 
[8]1%'imadoc2struct': reads the xml file for image documentation
[89]2%------------------------------------------------------------------------
[109]3% function [s,errormsg]=imadoc2struct(ImaDoc,option)
[8]4%
5% OUTPUT:
6% s: structure representing ImaDoc
7%   s.Heading: information about the data hierarchical structure
[611]8%   s.Time: matrix of times, note that s.Time(i+1,j+1) is the time for file indices i and j (in order to deal with index 0)
[8]9%   s.TimeUnit
10%  s.GeometryCalib: substructure containing the parameters for geometric calibration
11% errormsg: error message
12%
13% INPUT:
14% ImaDoc: full name of the xml input file with head key ImaDoc
[560]15% varargin: optional list of strings to restrict the reading to a selection of subtrees, for instance 'GeometryCalib' (save time)
[89]16
[809]17%=======================================================================
[1126]18% Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
[809]19%   http://www.legi.grenoble-inp.fr
[1127]20%   Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
[809]21%
22%     This file is part of the toolbox UVMAT.
23%
24%     UVMAT is free software; you can redistribute it and/or modify
25%     it under the terms of the GNU General Public License as published
26%     by the Free Software Foundation; either version 2 of the license,
27%     or (at your option) any later version.
28%
29%     UVMAT is distributed in the hope that it will be useful,
30%     but WITHOUT ANY WARRANTY; without even the implied warranty of
31%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32%     GNU General Public License (see LICENSE.txt) for more details.
33%=======================================================================
34
[560]35function [s,errormsg]=imadoc2struct(ImaDoc,varargin)
[8]36
[1184]37s=[]; %default output
38
[156]39%% opening the xml file
[1183]40if nargin ==1% no additional input variable beyond 'ImaDoc'
[685]41    [s,Heading,errormsg]=xml2struct(ImaDoc);% convert the whole xml file in a structure s
[1183]42elseif nargin ==2 %one additional input variable beyond 'ImaDoc'specifying the subtree to read
[685]43    [s,Heading,errormsg]=xml2struct(ImaDoc,varargin{1});% convert the xml file in a structure s, keeping only the subtree defined in input
[1183]44else % case of two subtrees, TODO: deal with more than two subtrees?
[685]45    [s,Heading,errormsg]=xml2struct(ImaDoc,varargin{1},varargin{2});% convert the xml file in a structure s, keeping only the subtree defined in input
[560]46end
[685]47if ~isempty(errormsg)
[687]48    errormsg=['error in reading ImaDoc xml file: ' errormsg];
[685]49    return
50end
[560]51if ~strcmp(Heading,'ImaDoc')
[685]52    errormsg='imadoc2struct/the input xml file is not ImaDoc';
[8]53    return
54end
[1184]55
[560]56%% reading timing
[565]57if isfield(s,'Camera')
[675]58    if isfield(s.Camera,'TimeUnit')
59        s.TimeUnit=s.Camera.TimeUnit;
60    end
[1149]61    if ~isfield(s.Camera,'FirstFrameIndexI')
62        s.Camera.FirstFrameIndexI=1; %first index assumed equl to 1 by default
63    end
[1150]64    s.Time=xmlburst2time(s.Camera.BurstTiming,s.Camera.FirstFrameIndexI);
[8]65end
66
Note: See TracBrowser for help on using the repository browser.