Changeset 675 for trunk/src/imadoc2struct.m
- Timestamp:
- Aug 27, 2013, 11:25:21 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/imadoc2struct.m
r611 r675 47 47 %% reading timing 48 48 if isfield(s,'Camera') 49 if isfield(s.Camera,'TimeUnit') 50 s.TimeUnit=s.Camera.TimeUnit; 51 end 49 52 Timing=s.Camera.BurstTiming; 50 53 if ~iscell(Timing) … … 105 108 end 106 109 107 % try108 % t=xmltree(ImaDoc);109 % catch ME110 % errormsg={['error reading ' ImaDoc ': ']; ME.message};111 % display(errormsg);112 % return113 % end114 % uid_root=find(t,'/ImaDoc');115 % if isempty(uid_root), return; end;%not an ImaDoc .xml file116 117 % %% Heading118 % uid_Heading=find(t,'/ImaDoc/Heading');119 % if ~isempty(uid_Heading),120 % uid_Campaign=find(t,'/ImaDoc/Heading/Campaign');121 % uid_Exp=find(t,'/ImaDoc/Heading/Experiment');122 % uid_Device=find(t,'/ImaDoc/Heading/Device');123 % uid_Record=find(t,'/ImaDoc/Heading/Record');124 % uid_FirstImage=find(t,'/ImaDoc/Heading/ImageName');125 % s.Heading.Campaign=get(t,children(t,uid_Campaign),'value');126 % s.Heading.Experiment=get(t,children(t,uid_Exp),'value');127 % s.Heading.Device=get(t,children(t,uid_Device),'value');128 % if ~isempty(uid_Record)129 % s.Heading.Record=get(t,children(t,uid_Record),'value');130 % end131 % s.Heading.ImageName=get(t,children(t,uid_FirstImage),'value');132 % end133 134 %% Camera and timing135 % if strcmp(option,'*') || strcmp(option,'Camera')136 % uid_Camera=find(t,'/ImaDoc/Camera');137 % if ~isempty(uid_Camera)138 % uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize');139 % if ~isempty(uid_ImageSize);140 % ImageSize=get(t,children(t,uid_ImageSize),'value');141 % xindex=findstr(ImageSize,'x');142 % if length(xindex)>=2143 % s.Npx=str2double(ImageSize(1:xindex(1)-1));144 % s.Npy=str2double(ImageSize(xindex(1)+1:xindex(2)-1));145 % end146 % end147 % uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit');148 % if ~isempty(uid_TimeUnit)149 % s.TimeUnit=get(t,children(t,uid_TimeUnit),'value');150 % end151 % uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming');152 % if ~isempty(uid_BurstTiming)153 % for k=1:length(uid_BurstTiming)154 % subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming155 % % reading Dtk156 % Frequency=get_value(subt,'/BurstTiming/FrameFrequency',1);157 % Dtj=get_value(subt,'/BurstTiming/Dtj',[]);158 % Dtj=Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')159 % NbDtj=get_value(subt,'/BurstTiming/NbDtj',1);160 % Dti=get_value(subt,'/BurstTiming/Dti',[]);161 % Dti=Dti/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')162 % NbDti=get_value(subt,'/BurstTiming/NbDti',1);163 % Time_val=get_value(subt,'/BurstTiming/Time',0);%time in TimeUnit164 % if ~isempty(Dti)165 % Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times166 % Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals Dti167 % end168 % if ~isempty(Dtj)169 % Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dtj vector NbDtj times170 % Dtj=[0 Dtj];171 % Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj172 % end173 % % reading Dtk174 % Dtk=get_value(subt,'/BurstTiming/Dtk',[]);175 % NbDtk=get_value(subt,'/BurstTiming/NbDtk',1);176 % if isempty(Dtk)177 % s.Time=[s.Time;Time_val];178 % else179 % for kblock=1:NbDtk+1180 % Time_val_k=Time_val+(kblock-1)*Dtk;181 % s.Time=[s.Time;Time_val_k];182 % end183 % end184 % end185 % end186 % end187 % end188 189 %% motor190 % if strcmp(option,'*') || strcmp(option,'GeometryCalib')191 % uid_subtree=find(t,'/ImaDoc/TranslationMotor');192 % if length(uid_subtree)==1193 % subt=branch(t,uid_subtree);%subtree under GeometryCalib194 % [s.TranslationMotor,errormsg]=read_subtree(subt,{'Nbslice','ZStart','ZEnd'},[1 1 1],[1 1 1]);195 % end196 % end197 %% geometric calibration198 % if strcmp(option,'*') || strcmp(option,'GeometryCalib')199 % uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib');200 % if ~isempty(uid_GeometryCalib)201 % if length(uid_GeometryCalib)>1202 % errormsg=['More than one GeometryCalib in ' filecivxml];203 % return204 % end205 % subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib206 % cont=get(subt,1,'contents');207 % if ~isempty(cont)208 % uid_CalibrationType=find(subt,'/GeometryCalib/CalibrationType');209 % if isequal(length(uid_CalibrationType),1)210 % tsai.CalibrationType=get(subt,children(subt,uid_CalibrationType),'value');211 % end212 % uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit');213 % if isequal(length(uid_CoordUnit),1)214 % tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value');215 % end216 % uid_fx_fy=find(subt,'/GeometryCalib/fx_fy');217 % focal=[];%default fro old convention (Reg Wilson)218 % if isequal(length(uid_fx_fy),1)219 % tsai.fx_fy=str2num(get(subt,children(subt,uid_fx_fy),'value'));220 % else %old convention (Reg Wilson)221 % uid_focal=find(subt,'/GeometryCalib/focal');222 % uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy');223 % uid_sx=find(subt,'/GeometryCalib/sx');224 % if ~isempty(uid_focal) && ~isempty(uid_dpx_dpy) && ~isempty(uid_sx)225 % dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value'));226 % sx=str2num(get(subt,children(subt,uid_sx),'value'));227 % focal=str2num(get(subt,children(subt,uid_focal),'value'));228 % tsai.fx_fy(1)=sx*focal/dpx_dpy(1);229 % tsai.fx_fy(2)=focal/dpx_dpy(2);230 % end231 % end232 % uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy');233 % if ~isempty(uid_Cx_Cy)234 % tsai.Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value'));235 % end236 % uid_kc=find(subt,'/GeometryCalib/kc');237 % if ~isempty(uid_kc)238 % tsai.kc=str2double(get(subt,children(subt,uid_kc),'value'));239 % else %old convention (Reg Wilson)240 % uid_kappa1=find(subt,'/GeometryCalib/kappa1');241 % if ~isempty(uid_kappa1)&& ~isempty(focal)242 % kappa1=str2double(get(subt,children(subt,uid_kappa1),'value'));243 % tsai.kc=-kappa1*focal*focal;244 % end245 % end246 % uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz');247 % if ~isempty(uid_Tx_Ty_Tz)248 % tsai.Tx_Ty_Tz=str2num(get(subt,children(subt,uid_Tx_Ty_Tz),'value'));249 % end250 % uid_R=find(subt,'/GeometryCalib/R');251 % if ~isempty(uid_R)252 % RR=get(subt,children(subt,uid_R),'value');253 % if length(RR)==3254 % tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})];255 % end256 % end257 %258 % %look for laser plane definitions259 % uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');260 % uid_Pos=find(subt,'/GeometryCalib/SliceCoord');261 % if isempty(uid_Pos)262 % uid_Pos=find(subt,'/GeometryCalib/PlanePos');%old convention263 % end264 % if ~isempty(uid_Angle)265 % tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));266 % end267 % if ~isempty(uid_Pos)268 % for j=1:length(uid_Pos)269 % tsai.SliceCoord(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));270 % end271 % uid_DZ=find(subt,'/GeometryCalib/SliceDZ');272 % uid_NbSlice=find(subt,'/GeometryCalib/NbSlice');273 % if ~isempty(uid_DZ) && ~isempty(uid_NbSlice)274 % DZ=str2double(get(subt,children(subt,uid_DZ),'value'));275 % NbSlice=get(subt,children(subt,uid_NbSlice),'value');276 % if isequal(NbSlice,'volume')277 % tsai.NbSlice='volume';278 % NbSlice=NbDtj+1;279 % else280 % tsai.NbSlice=str2double(NbSlice);281 % end282 % tsai.SliceCoord=ones(NbSlice,1)*tsai.SliceCoord+DZ*(0:NbSlice-1)'*[0 0 1];283 % end284 % end285 % tsai.SliceAngle=get_value(subt,'/GeometryCalib/SliceAngle',[0 0 0]);286 % tsai.VolumeScan=get_value(subt,'/GeometryCalib/VolumeScan','n');287 % tsai.InterfaceCoord=get_value(subt,'/GeometryCalib/InterfaceCoord',[0 0 0]);288 % tsai.RefractionIndex=get_value(subt,'/GeometryCalib/RefractionIndex',1);289 %290 % if strcmp(option,'GeometryCalib')291 % tsai.PointCoord=get_value(subt,'/GeometryCalib/SourceCalib/PointCoord',[0 0 0 0 0]);292 % end293 % s.GeometryCalib=tsai;294 % end295 % end296 % end297 298 %--------------------------------------------------299 % read a subtree300 % INPUT:301 % t: xltree302 % head_element: head elelemnt of the subtree303 % Data, structure containing304 % .Key: element name305 % .Type: type of element ('charg', 'float'....)306 % .NbOccur: nbre of occurrence, NaN for un specified number307 110 function [s,errormsg]=read_subtree(subt,Data,NbOccur,NumTest) 308 111 %--------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.