- Timestamp:
- Nov 21, 2012, 12:48:54 PM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/imadoc2struct.m
r559 r560 13 13 % INPUT: 14 14 % ImaDoc: full name of the xml input file with head key ImaDoc 15 % option: ='GeometryCalib': read the data of GeometryCalib, including source point coordinates16 17 function [s,errormsg]=imadoc2struct(ImaDoc, option)15 % varargin: optional list of strings to restrict the reading to a selection of subtrees, for instance 'GeometryCalib' (save time) 16 17 function [s,errormsg]=imadoc2struct(ImaDoc,varargin) 18 18 %% default input and output 19 if ~exist('option','var')20 option='*';21 end22 19 errormsg=[];%default 23 20 s.Heading=[];%default … … 25 22 s.TimeUnit=[]; %default 26 23 s.GeometryCalib=[]; 27 tsai=[];%default24 % tsai=[];%default 28 25 29 26 %% opening the xml file 30 27 [tild,tild,FileExt]=fileparts(ImaDoc); 28 %% case of .civ files (obsolete) 31 29 if strcmp(FileExt,'.civ') 32 30 [errormsg,time,TimeUnit,mode,npx,npy,s.GeometryCalib]=read_imatext(ImaDoc); 33 31 return 34 32 end 35 try 36 t=xmltree(ImaDoc); 37 catch ME 38 errormsg={['error reading ' ImaDoc ': ']; ME.message}; 39 display(errormsg); 33 34 %% case of xml files 35 if nargin >1 36 [s,Heading]=xml2struct(ImaDoc,varargin);% convert the xml file in a structure s, keeping only the subtree defined in input 37 else 38 [s,Heading]=xml2struct(ImaDoc);% convert the whole xml file in a structure s 39 end 40 if ~strcmp(Heading,'ImaDoc') 41 errormsg='the input xml file is not ImaDoc'; 40 42 return 41 43 end 42 uid_root=find(t,'/ImaDoc'); 43 if isempty(uid_root), return; end;%not an ImaDoc .xml file 44 45 %% Heading 46 uid_Heading=find(t,'/ImaDoc/Heading'); 47 if ~isempty(uid_Heading), 48 uid_Campaign=find(t,'/ImaDoc/Heading/Campaign'); 49 uid_Exp=find(t,'/ImaDoc/Heading/Experiment'); 50 uid_Device=find(t,'/ImaDoc/Heading/Device'); 51 uid_Record=find(t,'/ImaDoc/Heading/Record'); 52 uid_FirstImage=find(t,'/ImaDoc/Heading/ImageName'); 53 s.Heading.Campaign=get(t,children(t,uid_Campaign),'value'); 54 s.Heading.Experiment=get(t,children(t,uid_Exp),'value'); 55 s.Heading.Device=get(t,children(t,uid_Device),'value'); 56 if ~isempty(uid_Record) 57 s.Heading.Record=get(t,children(t,uid_Record),'value'); 58 end 59 s.Heading.ImageName=get(t,children(t,uid_FirstImage),'value'); 60 end 44 %% reading timing 45 Timing=s.Camera.BurstTiming; 46 if ~iscell(Timing) 47 Timing={Timing}; 48 end 49 s.Time=[]; 50 for k=1:length(Timing) 51 Frequency=1; 52 if isfield(Timing{k},'Frequency') 53 Frequency=Timing{k}.FrameFrequency; 54 end 55 Dtj=[]; 56 if isfield(Timing{k},'Dtj') 57 Dtj=Timing{k}.Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's'); 58 end 59 NbDtj=1; 60 if isfield(Timing{k},'NbDtj') 61 NbDtj=Timing{k}.NbDtj; 62 end 63 Dti=[]; 64 if isfield(Timing{k},'Dti') 65 Dti=Timing{k}.Dti/Frequency;%Dti converted from frame unit to TimeUnit (e.g. 's'); 66 end 67 NbDti=1; 68 if isfield(Timing{k},'NbDti') 69 NbDti=Timing{k}.NbDti; 70 end 71 Time_val=Timing{k}.Time;%time in TimeUnit 72 if ~isempty(Dti) 73 Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times 74 Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals Dti 75 end 76 if ~isempty(Dtj) 77 Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dtj vector NbDtj times 78 Dtj=[0 Dtj]; 79 Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj 80 end 81 % reading Dtk 82 Dtk=[];%default 83 NbDtk=1;%default 84 if isfield(Timing,'Dtk') 85 Dtk=Timing{k}.Dtk; 86 end 87 if isfield(Timing,'NbDtk') 88 NbDtk=Timing{k}.NbDtk; 89 end 90 if isempty(Dtk) 91 s.Time=[s.Time;Time_val]; 92 else 93 for kblock=1:NbDtk+1 94 Time_val_k=Time_val+(kblock-1)*Dtk; 95 s.Time=[s.Time;Time_val_k]; 96 end 97 end 98 end 99 100 101 % try 102 % t=xmltree(ImaDoc); 103 % catch ME 104 % errormsg={['error reading ' ImaDoc ': ']; ME.message}; 105 % display(errormsg); 106 % return 107 % end 108 % uid_root=find(t,'/ImaDoc'); 109 % if isempty(uid_root), return; end;%not an ImaDoc .xml file 110 111 % %% Heading 112 % uid_Heading=find(t,'/ImaDoc/Heading'); 113 % if ~isempty(uid_Heading), 114 % uid_Campaign=find(t,'/ImaDoc/Heading/Campaign'); 115 % uid_Exp=find(t,'/ImaDoc/Heading/Experiment'); 116 % uid_Device=find(t,'/ImaDoc/Heading/Device'); 117 % uid_Record=find(t,'/ImaDoc/Heading/Record'); 118 % uid_FirstImage=find(t,'/ImaDoc/Heading/ImageName'); 119 % s.Heading.Campaign=get(t,children(t,uid_Campaign),'value'); 120 % s.Heading.Experiment=get(t,children(t,uid_Exp),'value'); 121 % s.Heading.Device=get(t,children(t,uid_Device),'value'); 122 % if ~isempty(uid_Record) 123 % s.Heading.Record=get(t,children(t,uid_Record),'value'); 124 % end 125 % s.Heading.ImageName=get(t,children(t,uid_FirstImage),'value'); 126 % end 61 127 62 128 %% Camera and timing 63 if strcmp(option,'*') || strcmp(option,'Camera')64 uid_Camera=find(t,'/ImaDoc/Camera');65 if ~isempty(uid_Camera)66 uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize');67 if ~isempty(uid_ImageSize);68 ImageSize=get(t,children(t,uid_ImageSize),'value');69 xindex=findstr(ImageSize,'x');70 if length(xindex)>=271 s.Npx=str2double(ImageSize(1:xindex(1)-1));72 s.Npy=str2double(ImageSize(xindex(1)+1:xindex(2)-1));73 end74 end75 uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit');76 if ~isempty(uid_TimeUnit)77 s.TimeUnit=get(t,children(t,uid_TimeUnit),'value');78 end79 uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming');80 if ~isempty(uid_BurstTiming)81 for k=1:length(uid_BurstTiming)82 subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming83 % reading Dtk84 Frequency=get_value(subt,'/BurstTiming/FrameFrequency',1);85 Dtj=get_value(subt,'/BurstTiming/Dtj',[]);86 Dtj=Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')87 NbDtj=get_value(subt,'/BurstTiming/NbDtj',1);88 Dti=get_value(subt,'/BurstTiming/Dti',[]);89 Dti=Dti/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')90 NbDti=get_value(subt,'/BurstTiming/NbDti',1);91 Time_val=get_value(subt,'/BurstTiming/Time',0);%time in TimeUnit92 if ~isempty(Dti)93 Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times94 Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals Dti95 end96 if ~isempty(Dtj)97 Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dtj vector NbDtj times98 Dtj=[0 Dtj];99 Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj100 end101 % reading Dtk102 Dtk=get_value(subt,'/BurstTiming/Dtk',[]);103 NbDtk=get_value(subt,'/BurstTiming/NbDtk',1);104 if isempty(Dtk)105 s.Time=[s.Time;Time_val];106 else107 for kblock=1:NbDtk+1108 Time_val_k=Time_val+(kblock-1)*Dtk;109 s.Time=[s.Time;Time_val_k];110 end111 end112 end113 end114 end115 end129 % if strcmp(option,'*') || strcmp(option,'Camera') 130 % uid_Camera=find(t,'/ImaDoc/Camera'); 131 % if ~isempty(uid_Camera) 132 % uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize'); 133 % if ~isempty(uid_ImageSize); 134 % ImageSize=get(t,children(t,uid_ImageSize),'value'); 135 % xindex=findstr(ImageSize,'x'); 136 % if length(xindex)>=2 137 % s.Npx=str2double(ImageSize(1:xindex(1)-1)); 138 % s.Npy=str2double(ImageSize(xindex(1)+1:xindex(2)-1)); 139 % end 140 % end 141 % uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit'); 142 % if ~isempty(uid_TimeUnit) 143 % s.TimeUnit=get(t,children(t,uid_TimeUnit),'value'); 144 % end 145 % uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming'); 146 % if ~isempty(uid_BurstTiming) 147 % for k=1:length(uid_BurstTiming) 148 % subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming 149 % % reading Dtk 150 % Frequency=get_value(subt,'/BurstTiming/FrameFrequency',1); 151 % Dtj=get_value(subt,'/BurstTiming/Dtj',[]); 152 % Dtj=Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's') 153 % NbDtj=get_value(subt,'/BurstTiming/NbDtj',1); 154 % Dti=get_value(subt,'/BurstTiming/Dti',[]); 155 % Dti=Dti/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's') 156 % NbDti=get_value(subt,'/BurstTiming/NbDti',1); 157 % Time_val=get_value(subt,'/BurstTiming/Time',0);%time in TimeUnit 158 % if ~isempty(Dti) 159 % Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times 160 % Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals Dti 161 % end 162 % if ~isempty(Dtj) 163 % Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dtj vector NbDtj times 164 % Dtj=[0 Dtj]; 165 % Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj 166 % end 167 % % reading Dtk 168 % Dtk=get_value(subt,'/BurstTiming/Dtk',[]); 169 % NbDtk=get_value(subt,'/BurstTiming/NbDtk',1); 170 % if isempty(Dtk) 171 % s.Time=[s.Time;Time_val]; 172 % else 173 % for kblock=1:NbDtk+1 174 % Time_val_k=Time_val+(kblock-1)*Dtk; 175 % s.Time=[s.Time;Time_val_k]; 176 % end 177 % end 178 % end 179 % end 180 % end 181 % end 116 182 117 183 %% motor 118 if strcmp(option,'*') || strcmp(option,'GeometryCalib')119 uid_subtree=find(t,'/ImaDoc/TranslationMotor');120 if length(uid_subtree)==1121 subt=branch(t,uid_subtree);%subtree under GeometryCalib122 [s.TranslationMotor,errormsg]=read_subtree(subt,{'Nbslice','ZStart','ZEnd'},[1 1 1],[1 1 1]);123 end124 end184 % if strcmp(option,'*') || strcmp(option,'GeometryCalib') 185 % uid_subtree=find(t,'/ImaDoc/TranslationMotor'); 186 % if length(uid_subtree)==1 187 % subt=branch(t,uid_subtree);%subtree under GeometryCalib 188 % [s.TranslationMotor,errormsg]=read_subtree(subt,{'Nbslice','ZStart','ZEnd'},[1 1 1],[1 1 1]); 189 % end 190 % end 125 191 %% geometric calibration 126 if strcmp(option,'*') || strcmp(option,'GeometryCalib')127 uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib');128 if ~isempty(uid_GeometryCalib)129 if length(uid_GeometryCalib)>1130 errormsg=['More than one GeometryCalib in ' filecivxml];131 return132 end133 subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib134 cont=get(subt,1,'contents');135 if ~isempty(cont)136 uid_CalibrationType=find(subt,'/GeometryCalib/CalibrationType');137 if isequal(length(uid_CalibrationType),1)138 tsai.CalibrationType=get(subt,children(subt,uid_CalibrationType),'value');139 end140 uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit');141 if isequal(length(uid_CoordUnit),1)142 tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value');143 end144 uid_fx_fy=find(subt,'/GeometryCalib/fx_fy');145 focal=[];%default fro old convention (Reg Wilson)146 if isequal(length(uid_fx_fy),1)147 tsai.fx_fy=str2num(get(subt,children(subt,uid_fx_fy),'value'));148 else %old convention (Reg Wilson)149 uid_focal=find(subt,'/GeometryCalib/focal');150 uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy');151 uid_sx=find(subt,'/GeometryCalib/sx');152 if ~isempty(uid_focal) && ~isempty(uid_dpx_dpy) && ~isempty(uid_sx)153 dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value'));154 sx=str2num(get(subt,children(subt,uid_sx),'value'));155 focal=str2num(get(subt,children(subt,uid_focal),'value'));156 tsai.fx_fy(1)=sx*focal/dpx_dpy(1);157 tsai.fx_fy(2)=focal/dpx_dpy(2);158 end159 end160 uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy');161 if ~isempty(uid_Cx_Cy)162 tsai.Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value'));163 end164 uid_kc=find(subt,'/GeometryCalib/kc');165 if ~isempty(uid_kc)166 tsai.kc=str2double(get(subt,children(subt,uid_kc),'value'));167 else %old convention (Reg Wilson)168 uid_kappa1=find(subt,'/GeometryCalib/kappa1');169 if ~isempty(uid_kappa1)&& ~isempty(focal)170 kappa1=str2double(get(subt,children(subt,uid_kappa1),'value'));171 tsai.kc=-kappa1*focal*focal;172 end173 end174 uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz');175 if ~isempty(uid_Tx_Ty_Tz)176 tsai.Tx_Ty_Tz=str2num(get(subt,children(subt,uid_Tx_Ty_Tz),'value'));177 end178 uid_R=find(subt,'/GeometryCalib/R');179 if ~isempty(uid_R)180 RR=get(subt,children(subt,uid_R),'value');181 if length(RR)==3182 tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})];183 end184 end185 186 %look for laser plane definitions187 uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');188 uid_Pos=find(subt,'/GeometryCalib/SliceCoord');189 if isempty(uid_Pos)190 uid_Pos=find(subt,'/GeometryCalib/PlanePos');%old convention191 end192 if ~isempty(uid_Angle)193 tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));194 end195 if ~isempty(uid_Pos)196 for j=1:length(uid_Pos)197 tsai.SliceCoord(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));198 end199 uid_DZ=find(subt,'/GeometryCalib/SliceDZ');200 uid_NbSlice=find(subt,'/GeometryCalib/NbSlice');201 if ~isempty(uid_DZ) && ~isempty(uid_NbSlice)202 DZ=str2double(get(subt,children(subt,uid_DZ),'value'));203 NbSlice=get(subt,children(subt,uid_NbSlice),'value');204 if isequal(NbSlice,'volume')205 tsai.NbSlice='volume';206 NbSlice=NbDtj+1;207 else208 tsai.NbSlice=str2double(NbSlice);209 end210 tsai.SliceCoord=ones(NbSlice,1)*tsai.SliceCoord+DZ*(0:NbSlice-1)'*[0 0 1];211 end212 end213 tsai.SliceAngle=get_value(subt,'/GeometryCalib/SliceAngle',[0 0 0]);214 tsai.VolumeScan=get_value(subt,'/GeometryCalib/VolumeScan','n');215 tsai.InterfaceCoord=get_value(subt,'/GeometryCalib/InterfaceCoord',[0 0 0]);216 tsai.RefractionIndex=get_value(subt,'/GeometryCalib/RefractionIndex',1);217 218 if strcmp(option,'GeometryCalib')219 tsai.PointCoord=get_value(subt,'/GeometryCalib/SourceCalib/PointCoord',[0 0 0 0 0]);220 end221 s.GeometryCalib=tsai;222 end223 end224 end192 % if strcmp(option,'*') || strcmp(option,'GeometryCalib') 193 % uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib'); 194 % if ~isempty(uid_GeometryCalib) 195 % if length(uid_GeometryCalib)>1 196 % errormsg=['More than one GeometryCalib in ' filecivxml]; 197 % return 198 % end 199 % subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib 200 % cont=get(subt,1,'contents'); 201 % if ~isempty(cont) 202 % uid_CalibrationType=find(subt,'/GeometryCalib/CalibrationType'); 203 % if isequal(length(uid_CalibrationType),1) 204 % tsai.CalibrationType=get(subt,children(subt,uid_CalibrationType),'value'); 205 % end 206 % uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit'); 207 % if isequal(length(uid_CoordUnit),1) 208 % tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value'); 209 % end 210 % uid_fx_fy=find(subt,'/GeometryCalib/fx_fy'); 211 % focal=[];%default fro old convention (Reg Wilson) 212 % if isequal(length(uid_fx_fy),1) 213 % tsai.fx_fy=str2num(get(subt,children(subt,uid_fx_fy),'value')); 214 % else %old convention (Reg Wilson) 215 % uid_focal=find(subt,'/GeometryCalib/focal'); 216 % uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy'); 217 % uid_sx=find(subt,'/GeometryCalib/sx'); 218 % if ~isempty(uid_focal) && ~isempty(uid_dpx_dpy) && ~isempty(uid_sx) 219 % dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value')); 220 % sx=str2num(get(subt,children(subt,uid_sx),'value')); 221 % focal=str2num(get(subt,children(subt,uid_focal),'value')); 222 % tsai.fx_fy(1)=sx*focal/dpx_dpy(1); 223 % tsai.fx_fy(2)=focal/dpx_dpy(2); 224 % end 225 % end 226 % uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy'); 227 % if ~isempty(uid_Cx_Cy) 228 % tsai.Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value')); 229 % end 230 % uid_kc=find(subt,'/GeometryCalib/kc'); 231 % if ~isempty(uid_kc) 232 % tsai.kc=str2double(get(subt,children(subt,uid_kc),'value')); 233 % else %old convention (Reg Wilson) 234 % uid_kappa1=find(subt,'/GeometryCalib/kappa1'); 235 % if ~isempty(uid_kappa1)&& ~isempty(focal) 236 % kappa1=str2double(get(subt,children(subt,uid_kappa1),'value')); 237 % tsai.kc=-kappa1*focal*focal; 238 % end 239 % end 240 % uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz'); 241 % if ~isempty(uid_Tx_Ty_Tz) 242 % tsai.Tx_Ty_Tz=str2num(get(subt,children(subt,uid_Tx_Ty_Tz),'value')); 243 % end 244 % uid_R=find(subt,'/GeometryCalib/R'); 245 % if ~isempty(uid_R) 246 % RR=get(subt,children(subt,uid_R),'value'); 247 % if length(RR)==3 248 % tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})]; 249 % end 250 % end 251 % 252 % %look for laser plane definitions 253 % uid_Angle=find(subt,'/GeometryCalib/PlaneAngle'); 254 % uid_Pos=find(subt,'/GeometryCalib/SliceCoord'); 255 % if isempty(uid_Pos) 256 % uid_Pos=find(subt,'/GeometryCalib/PlanePos');%old convention 257 % end 258 % if ~isempty(uid_Angle) 259 % tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value')); 260 % end 261 % if ~isempty(uid_Pos) 262 % for j=1:length(uid_Pos) 263 % tsai.SliceCoord(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value')); 264 % end 265 % uid_DZ=find(subt,'/GeometryCalib/SliceDZ'); 266 % uid_NbSlice=find(subt,'/GeometryCalib/NbSlice'); 267 % if ~isempty(uid_DZ) && ~isempty(uid_NbSlice) 268 % DZ=str2double(get(subt,children(subt,uid_DZ),'value')); 269 % NbSlice=get(subt,children(subt,uid_NbSlice),'value'); 270 % if isequal(NbSlice,'volume') 271 % tsai.NbSlice='volume'; 272 % NbSlice=NbDtj+1; 273 % else 274 % tsai.NbSlice=str2double(NbSlice); 275 % end 276 % tsai.SliceCoord=ones(NbSlice,1)*tsai.SliceCoord+DZ*(0:NbSlice-1)'*[0 0 1]; 277 % end 278 % end 279 % tsai.SliceAngle=get_value(subt,'/GeometryCalib/SliceAngle',[0 0 0]); 280 % tsai.VolumeScan=get_value(subt,'/GeometryCalib/VolumeScan','n'); 281 % tsai.InterfaceCoord=get_value(subt,'/GeometryCalib/InterfaceCoord',[0 0 0]); 282 % tsai.RefractionIndex=get_value(subt,'/GeometryCalib/RefractionIndex',1); 283 % 284 % if strcmp(option,'GeometryCalib') 285 % tsai.PointCoord=get_value(subt,'/GeometryCalib/SourceCalib/PointCoord',[0 0 0 0 0]); 286 % end 287 % s.GeometryCalib=tsai; 288 % end 289 % end 290 % end 225 291 226 292 %-------------------------------------------------- -
trunk/src/xml2struct.m
r477 r560 8 8 % INPUT: 9 9 % filename: name of the xml file 10 % varargin: optional list of strings to restrict the reading to a selection of subtrees, for instance 'GeometryCalib' (save time) 10 11 11 function [s,Heading]=xml2struct(filename )12 function [s,Heading]=xml2struct(filename,varargin) 12 13 t=xmltree(filename); 13 14 Heading=get(t,1,'name'); 14 ss=convert(t); 15 s=convert_string(ss); 15 if nargin>1 16 for isub=1:nargin-1 17 uid_sub=find(t,['/' Heading '/' varargin{isub}]); 18 tsub=branch(t,uid_sub); 19 ss=convert(tsub); 20 s.(varargin{isub})=convert_string(ss); 21 end 22 else 23 ss=convert(t); 24 s=convert_string(ss); 25 end 16 26 17 27
Note: See TracChangeset
for help on using the changeset viewer.