Changeset 1059 for trunk/src/geometry_calib.m
- Timestamp:
- Nov 29, 2018, 5:44:44 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r1027 r1059 52 52 % Edit the above text to modify the response to help geometry_calib 53 53 54 % Last Modified by GUIDE v2.5 16-Apr-2015 17:29:0254 % Last Modified by GUIDE v2.5 20-Sep-2018 19:04:30 55 55 56 56 % Begin initialization code - DO NOT edit … … 108 108 set(handles.calib_type,'Position',[1 Height-40 194 30])% rank 1 109 109 set(handles.APPLY,'Position',[197 Height-40 110 30])% rank 1 110 set(handles.R EPLICATE,'Position',[309 Height-40 110 30])% rank 1110 set(handles.Replicate,'Position',[309 Height-40 110 30])% rank 1 111 111 set(handles.Intrinsic,'Position',[1 Height-40-2-92 418 92])% rank 2 112 112 set(handles.Extrinsic,'Position',[1 Height-40-4-92-75 418 75])% rank 3 … … 167 167 %------------------------------------------------------------------------ 168 168 % --- Executes on button press APPLY (used to launch the calibration). 169 function APPLY_Callback(hObject, eventdata, handles) 169 function APPLY_Callback(hObject, eventdata, handles) 170 set(handles.CheckEnableMouse,'Value',0)% desactivate mouse (to avoid spurious creation of new points) 171 172 %------------------------------------------------------------------------ 173 %% look for the GUI uvmat and check for an image as input 174 set(handles.APPLY,'BackgroundColor',[1 1 0])% paint APPLY button in yellow to show activation 175 huvmat=findobj(allchild(0),'Name','uvmat');% look for the GUI uvmat 176 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat 177 if ~strcmp(get(hhuvmat.Scalar,'Visible'),'on') 178 msgbox_uvmat('ERROR','An image needs to be opened in uvmat for calibration') 179 return 180 end 181 182 RootPath=''; 183 if ~isempty(hhuvmat.RootPath)&& ~isempty(hhuvmat.RootFile) 184 RootPath=get(hhuvmat.RootPath,'String');% path to the currently displayed image 185 SubDirBase=regexprep(get(hhuvmat.SubDir,'String'),'\..+$',''); 186 outputfile=[fullfile(RootPath,SubDirBase) '.xml'];%xml file associated with the currently displayed image 187 else 188 question={'save the calibration data and point coordinates in'}; 189 def={fullfile(RootPath,'ObjectCalib.xml')}; 190 options.Resize='on'; 191 answer=inputdlg(question,'',1,def,options); 192 outputfile=answer{1}; 193 end 194 195 %% read coordinates of the calibration poinnts: Coord(:,1-3) in phys, Coord(:,4-5) image 196 Coord=get(handles.ListCoord,'Data'); 197 198 199 %% read the type of calibration 200 calib_cell=get(handles.calib_type,'String'); 201 val=get(handles.calib_type,'Value'); 202 CalibFcn=['calib_' calib_cell{val}]; 203 204 %% read the intrinsic parameters 205 Intrinsic.Npx=str2num(get(hhuvmat.num_Npx,'String')); 206 Intrinsic.Npy=str2num(get(hhuvmat.num_Npy,'String')); 207 Intrinsic.coord_files=get(handles.ListCoordFiles,'String'); 208 Intrinsic.fx=str2num(get(handles.fx,'String')); 209 Intrinsic.fy=str2num(get(handles.fy,'String')); 210 Intrinsic.kc=str2num(get(handles.kc,'String')); 211 Intrinsic.Cx=str2num(get(handles.Cx,'String')); 212 Intrinsic.Cy=str2num(get(handles.Cy,'String')); 213 if isempty(Intrinsic.kc) 214 Intrinsic.kc=0; 215 end 216 if isempty(Intrinsic.Cx)||isempty(Intrinsic.Cy) 217 Intrinsic.Cx=Intrinsic.Npx/2; 218 Intrinsic.Cy=Intrinsic.Npy/2; 219 end 220 221 %% apply to cropped images if requested 222 if get(handles.Replicate,'Value') 223 answer=msgbox_uvmat('INPUT_Y-N','apply to full images (not cropped)?'); 224 if strcmp(answer,'No') 225 prompt = {'npy_lower'}; 226 dlg_title = 'remove image the npy_lower image lines (removal of the upper line does not change calibration)'; 227 num_lines= 1; 228 def = {'0'}; 229 answer = inputdlg(prompt,dlg_title,num_lines,def); 230 npy_crop=str2num(answer{1}); 231 Intrinsic.Npy=Intrinsic.Npy-npy_crop; %size of the filtering window 232 Coord(:,5)=Coord(:,5)-npy_crop;% shift the image ordinates of the calibration points by removing the lower band 233 end 234 end 235 236 %% Apply calibration 237 [GeometryCalib,index,ind_removed,Z_plane]=calibrate(Coord,CalibFcn,Intrinsic);% apply calibration 238 239 %% record the coordinate unit 240 unitlist=get(handles.CoordUnit,'String'); 241 unit=unitlist{get(handles.CoordUnit,'value')}; 242 GeometryCalib.CoordUnit=unit; 243 244 %% record the coordinates of the calibration points 245 GeometryCalib.SourceCalib.PointCoord=Coord; 246 247 %% display calibration results on the GUI geometry_calib 248 display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters 249 display_extrinsic(GeometryCalib,handles)%display calibration extrinsic parameters 250 % (rotation and translation of camera with respect to the phys coordinates) 251 252 %% set the defqult plane and display the calibration data errors for validation 253 answer=msgbox_uvmat('INPUT_Y-N',{'store calibration data';... 254 ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];... 255 ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']; 256 [num2str(numel(ind_removed)) ' points removed']}); 257 if strcmp(answer,'Yes') %store the calibration data 258 if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration 259 answer=msgbox_uvmat('INPUT_Y-N',{['Assume that the current image is in the plane of the calib points z=' num2str(Z_plane) ] ; 'can be later modified by MenuSetSlice in the upper bar menu of uvmat'}); 260 SliceCoord_ref=Z_plane'*[0 0 1]; 261 end 262 else 263 GeometryCalib=[]; 264 index=1; 265 end 266 267 if ~isempty(GeometryCalib) % if calibration is not cancelled 268 if get(handles.Replicate,'Value') 269 %% open the GUI browse_data 270 hbrowse=findobj(allchild(0),'Tag','browse_data'); 271 if ~isempty(hbrowse) 272 BrowseHandles=guidata(hbrowse); 273 SourceDir=get(BrowseHandles.SourceDir,'String'); 274 ListExperiments=get(BrowseHandles.ListExperiments,'String'); 275 ListValues=get(BrowseHandles.ListExperiments,'Value'); 276 ListExperiments=ListExperiments(ListValues); 277 ListDevices=get(BrowseHandles.ListDevices,'String'); 278 Val=get(BrowseHandles.ListDevices,'Value'); 279 DataFolder=ListDevices{Val}; 280 nbcalib=0; 281 for ilist=1:numel(ListExperiments) 282 SubDirBase=regexprep(DataFolder,'+/',''); 283 ListExperiments{ilist}=regexprep(ListExperiments{ilist},'+/',''); 284 XmlName=fullfile(SourceDir,ListExperiments{ilist},[SubDirBase '.xml']); 285 % copy the xml file from the old location if appropriate, then update with the calibration parameters 286 % if ~exist(XmlName,'file') && ~isempty(SubDirBase) 287 % oldxml=fullfile(OutPut.Campaign,OutPut.Experiment{ilist},SubDirBase,[get(hhuvmat.RootFile,'String') '.xml']); 288 GeometryCalib.SliceCoord=SliceCoord_ref;%default input 289 if exist(XmlName,'file') 290 %[success,message]=copyfile(oldxml,XmlName);%copy the old xml file to a new one with the new convention 291 dispmesGeometryCalib=UvData.XmlData{1}.GeometryCalib; 292 else 293 msgbox_uvmat('ERROR','3D geometric calibration needed before defining slices') 294 return 295 end 296 SliceCoord=GeometryCalib.SliceCoord; 297 InterfaceCoord=min(SliceCoord(:,3)); 298 if isfield(GeometryCalib,'InterfaceCoord') 299 InterfaceCoord=GeometryCalib.InterfaceCoord(1,3); 300 end 301 NbSlice=size(SliceCoord,1); 302 CheckVolumeScan=0; 303 if isfield(GeometryCalib,'CheckVolumeScan') 304 CheckVolumeScan=GeometryCalib.CheckVolumeScan; 305 end 306 RefractionIndex=1.33; 307 CheckRefraction=0;% default value of the check box refraction 308 if isfield(GeometryCalib,'RefractionIndex') 309 RefractionIndex=GeometryCalib.RefractionIndex; 310 CheckRefraction=1; 311 end 312 SliceAngle=[0 0 0]; 313 if isfield(GeometryCalib,'SliceAngle') 314 SliceAngle=GeometryCalib.SliceAngle; 315 end 316 dispmessage=' updated with calibration parameters'; 317 % if ~strcmp(answer,'yes') 318 [XmlDataOld,warntext]=imadoc2struct(XmlName); 319 if isfield(XmlDataOld,'GeometryCalib') 320 if isfield(XmlDataOld.GeometryCalib,'SliceAngle') 321 GeometryCalib.SliceAngle=XmlDataOld.GeometryCalib.SliceAngle; 322 end 323 if isfield(XmlDataOld.GeometryCalib,'CheckRefraction') 324 GeometryCalib.SliceAngle=XmlDataOld.GeometryCalib.CheckRefraction; 325 end 326 if isfield(XmlDataOld.GeometryCalib,'RefractionIndex') 327 GeometryCalib.SliceAngle=XmlDataOld.GeometryCalib.RefractionIndex; 328 end 329 if isfield(XmlDataOld.GeometryCalib,'InterfaceCoord') 330 GeometryCalib.SliceAngle=XmlDataOld.GeometryCalib.InterfaceCoord; 331 end 332 end 333 334 end 335 336 else 337 dispmessage=' created with calibration parameters'; 338 end 339 errormsg=update_imadoc(GeometryCalib,XmlName,'GeometryCalib');% introduce the calibration data in the xml file 340 if ~strcmp(errormsg,'') 341 msgbox_uvmat('ERROR',errormsg); 342 else 343 display([XmlName dispmessage]) 344 nbcalib=nbcalib+1; 345 end 346 end 347 348 end 349 msgbox_uvmat('CONFIMATION',[SubDirBase ' calibrated for ' num2str(nbcalib) ' experiments']); 350 else 351 352 %% copy the xml file from the old location if appropriate, then update with the calibration parameters 353 if ~exist(outputfile,'file') && ~isempty(SubDirBase) 354 oldxml=[fullfile(RootPath,SubDirBase,get(hhuvmat.RootFile,'String')) '.xml']; 355 if exist(oldxml,'file') 356 [success,message]=copyfile(oldxml,outputfile);%copy the old xml file to a new one with the new convention 357 end 358 end 359 errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file 360 if ~strcmp(errormsg,'') 361 msgbox_uvmat('ERROR',errormsg); 362 end 363 364 %% display image with new calibration in the currently opened uvmat interface 365 FieldList=get(hhuvmat.FieldName,'String'); 366 val=get(hhuvmat.FieldName,'Value'); 367 if strcmp(FieldList{val},'image') 368 set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image 369 UserData=get(handles.geometry_calib,'UserData'); 370 UserData.XmlInputFile=outputfile;%save the current xml file name 371 set(handles.geometry_calib,'UserData',UserData) 372 uvmat('InputFileREFRESH_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat, show the image in phys coordinates 373 PLOT_Callback(hObject, eventdata, handles) 374 set(handles.CoordLine,'string',num2str(index)) 375 Coord=get(handles.ListCoord,'Data'); 376 update_calib_marker(Coord(index,:)); %indicate the point with max deviations from phys coord to calibration 377 figure(handles.geometry_calib)% put the GUI geometry_calib in front 378 else 379 msgbox_uvmat('WARNING','open the image to see the effect of the new calibration') 380 end 381 end 382 end 383 set(handles.APPLY,'BackgroundColor',[1 0 0]) % set APPLY button to red color 384 385 %------------------------------------------------------------------------ 386 % --- Executes on button press in Replicate 387 function Replicate_Callback(hObject, eventdata, handles) 388 % %------------------------------------------------------------------------ 170 389 set(handles.CheckEnableMouse,'Value',0)% desactivate mouse (to avoid spurious creation of new points) 171 390 172 %------------------------------------------------------------------------ 173 %% look for the GUI uvmat and check for an image as input 174 set(handles.APPLY,'BackgroundColor',[1 1 0])% paint APPLY button in yellow to show activation 175 huvmat=findobj(allchild(0),'Name','uvmat');% look for the GUI uvmat 176 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat 177 if ~strcmp(get(hhuvmat.Scalar,'Visible'),'on') 178 msgbox_uvmat('ERROR','An image needs to be opened in uvmat for calibration') 179 return 180 end 181 182 RootPath=''; 183 if ~isempty(hhuvmat.RootPath)&& ~isempty(hhuvmat.RootFile) 184 RootPath=get(hhuvmat.RootPath,'String');% path to the currently displayed image 185 SubDirBase=regexprep(get(hhuvmat.SubDir,'String'),'\..+$',''); 186 outputfile=[fullfile(RootPath,SubDirBase) '.xml'];%xml file associated with the currently displayed image 391 if get(handles.Replicate,'Value') %open the GUI browse_data 392 % look for the GUI uvmat and check for an image as input 393 huvmat=findobj(allchild(0),'Name','uvmat'); 394 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat 395 RootPath=get(hhuvmat.RootPath,'String'); 396 SubDir=get(hhuvmat.SubDir,'String'); 397 browse_data(fullfile(RootPath,SubDir)) 187 398 else 188 question={'save the calibration data and point coordinates in'}; 189 def={fullfile(RootPath,'ObjectCalib.xml')}; 190 options.Resize='on'; 191 answer=inputdlg(question,'',1,def,options); 192 outputfile=answer{1}; 193 end 194 195 %% read coordinates of the calibration poinnts: Coord(:,1-3) in phys, Coord(:,4-5) image 196 Coord=get(handles.ListCoord,'Data'); 197 198 199 %% read the type of calibration 200 calib_cell=get(handles.calib_type,'String'); 201 val=get(handles.calib_type,'Value'); 202 CalibFcn=['calib_' calib_cell{val}]; 203 204 %% read the intrinsic parameters 205 Intrinsic.Npx=str2num(get(hhuvmat.num_Npx,'String')); 206 Intrinsic.Npy=str2num(get(hhuvmat.num_Npy,'String')); 207 Intrinsic.coord_files=get(handles.ListCoordFiles,'String'); 208 Intrinsic.fx=str2num(get(handles.fx,'String')); 209 Intrinsic.fy=str2num(get(handles.fy,'String')); 210 Intrinsic.kc=str2num(get(handles.kc,'String')); 211 Intrinsic.Cx=str2num(get(handles.Cx,'String')); 212 Intrinsic.Cy=str2num(get(handles.Cy,'String')); 213 if isempty(Intrinsic.kc) 214 Intrinsic.kc=0; 215 end 216 if isempty(Intrinsic.Cx)||isempty(Intrinsic.Cy) 217 Intrinsic.Cx=Intrinsic.Npx/2; 218 Intrinsic.Cy=Intrinsic.Npy/2; 219 end 220 221 %% Apply calibration 222 [GeometryCalib,index,ind_removed,Z_plane]=calibrate(Coord,CalibFcn,Intrinsic);% apply calibration 223 224 %% record the coordinate unit 225 unitlist=get(handles.CoordUnit,'String'); 226 unit=unitlist{get(handles.CoordUnit,'value')}; 227 GeometryCalib.CoordUnit=unit; 228 229 %% record the coordinates of the calibration points 230 GeometryCalib.SourceCalib.PointCoord=Coord; 231 232 %% display calibration results on the GUI geometry_calib 233 display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters 234 display_extrinsic(GeometryCalib,handles)%display calibration extrinsic parameters 235 % (rotation and translation of camera with respect to the phys coordinates) 236 237 %% store the calibration data, by default in the xml file of the currently displayed image 238 answer=msgbox_uvmat('INPUT_Y-N',{'store calibration data';... 239 ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];... 240 ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']; 241 [num2str(numel(ind_removed)) ' points removed']}); 242 if strcmp(answer,'Yes') %store the calibration data 243 if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration 244 msgbox_uvmat('CONFIRMATION',{['The current image series is assumed by default in the plane of the calib points z=' num2str(Z_plane) ] ; 'can be modified by MenuSetSlice in the upper bar menu of uvmat'}) 245 GeometryCalib.SliceCoord=Z_plane'*[0 0 1]; 246 end 247 else 248 GeometryCalib=[]; 249 index=1; 250 end 251 252 if isempty(GeometryCalib) % if calibration cancelled 253 set(handles.APPLY,'BackgroundColor',[1 0 1]) 254 else % if calibration confirmed 255 256 %% copy the xml file from the old location if appropriate, then update with the calibration parameters 257 if ~exist(outputfile,'file') && ~isempty(SubDirBase) 258 oldxml=[fullfile(RootPath,SubDirBase,get(hhuvmat.RootFile,'String')) '.xml']; 259 if exist(oldxml,'file') 260 [success,message]=copyfile(oldxml,outputfile);%copy the old xml file to a new one with the new convention 261 end 262 end 263 errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file 264 if ~strcmp(errormsg,'') 265 msgbox_uvmat('ERROR',errormsg); 266 end 267 268 %% display image with new calibration in the currently opened uvmat interface 269 FieldList=get(hhuvmat.FieldName,'String'); 270 val=get(hhuvmat.FieldName,'Value'); 271 if strcmp(FieldList{val},'image') 272 set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image 273 UserData=get(handles.geometry_calib,'UserData'); 274 UserData.XmlInputFile=outputfile;%save the current xml file name 275 set(handles.geometry_calib,'UserData',UserData) 276 uvmat('InputFileREFRESH_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat, show the image in phys coordinates 277 PLOT_Callback(hObject, eventdata, handles) 278 set(handles.CoordLine,'string',num2str(index)) 279 Coord=get(handles.ListCoord,'Data'); 280 update_calib_marker(Coord(index,:)); %indicate the point with max deviations from phys coord to calibration 281 figure(handles.geometry_calib)% put the GUI geometry_calib in front 282 set(handles.APPLY,'BackgroundColor',[1 0 0]) % set APPLY button to red color 283 else 284 msgbox_uvmat('WARNING','open the image to see the effect of the new calibration') 285 end 286 end 287 288 %------------------------------------------------------------------------ 289 % --- Executes on button press in REPLICATE 290 function REPLICATE_Callback(hObject, eventdata, handles) 291 %------------------------------------------------------------------------ 292 set(handles.CheckEnableMouse,'Value',0)% desactivate mouse (to avoid spurious creation of new points) 293 294 %% look for the GUI uvmat and check for an image as input 295 huvmat=findobj(allchild(0),'Name','uvmat'); 296 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat 297 298 %% read coordinates of the calibration poinnts: Coord(:,1-3) in phys, Coord(:,4-5) image 299 Coord=get(handles.ListCoord,'Data'); 300 301 %% read the type of calibration 302 calib_cell=get(handles.calib_type,'String'); 303 val=get(handles.calib_type,'Value'); 304 CalibFcn=['calib_' calib_cell{val}]; 305 306 %% read the intrinsic parameters 307 Intrinsic.Npx=str2num(get(hhuvmat.num_Npx,'String')); 308 Intrinsic.Npy=str2num(get(hhuvmat.num_Npy,'String')); 309 Intrinsic.coord_files=get(handles.ListCoordFiles,'String'); 310 Intrinsic.fx=str2num(get(handles.fx,'String')); 311 Intrinsic.fy=str2num(get(handles.fy,'String')); 312 Intrinsic.kc=str2num(get(handles.kc,'String')); 313 Intrinsic.Cx=str2num(get(handles.Cx,'String')); 314 Intrinsic.Cy=str2num(get(handles.Cy,'String')); 315 if isempty(Intrinsic.kc) 316 Intrinsic.kc=0; 317 end 318 if isempty(Intrinsic.Cx)||isempty(Intrinsic.Cy) 319 Intrinsic.Cx=Intrinsic.Npx/2; 320 Intrinsic.Cy=Intrinsic.Npy/2; 321 end 322 323 %% apply to cropped images if requested 324 answer=msgbox_uvmat('INPUT_Y-N','apply to cropped images?'); 325 if strcmp(answer,'Yes') 326 prompt = {'npy_lower'}; 327 dlg_title = 'remove image the npy_lower image lines (removal of the upper linedoes not change calibration)'; 328 num_lines= 1; 329 def = {'0'}; 330 answer = inputdlg(prompt,dlg_title,num_lines,def); 331 npy_crop=str2num(answer{1}); 332 Intrinsic.Npy=Intrinsic.Npy-npy_crop; %size of the filtering window 333 Coord(:,5)=Coord(:,5)-npy_crop;% shift the image ordinates of the calibration points by removing the lower band 334 end 335 336 %% Apply calibration 337 [GeometryCalib,index,ind_removed,Z_plane]=calibrate(Coord,CalibFcn,Intrinsic);% apply calibration 338 339 340 %% record the coordinate unit 341 unitlist=get(handles.CoordUnit,'String'); 342 unit=unitlist{get(handles.CoordUnit,'value')}; 343 GeometryCalib.CoordUnit=unit; 344 345 %% record the coordinates of the calibration points 346 GeometryCalib.SourceCalib.PointCoord=Coord; 347 348 %% display calibration results on the GUI geometry_calib 349 display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters 350 display_extrinsic(GeometryCalib,handles)%display calibration extrinsic parameters 351 % (rotation and translation of camera with respect to the phys coordinates) 352 353 %% store the calibration data, by default in the xml file of the currently displayed image 354 answer=msgbox_uvmat('INPUT_Y-N',{'store calibration data';... 355 ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];... 356 ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels'];... 357 [num2str(numel(ind_removed)) ' points removed']}); 358 if strcmp(answer,'Yes') %store the calibration data 359 if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration 360 msgbox_uvmat('CONFIRMATION',{['The current image series is assumed by default in the plane of the calib points z=' num2str(Z_plane) ] ; 'can be modified by MenuSetSlice in the upper bar menu of uvmat'}) 361 GeometryCalib.SliceCoord=Z_plane'*[0 0 1]; 362 end 363 else 364 GeometryCalib=[]; 365 index=1; 366 end 367 368 %% open the GUI browse_data 369 CalibData=get(handles.geometry_calib,'UserData');%read the calibration image source on the interface userdata 370 if isfield(CalibData,'XmlInputFile') 371 InputDir=fileparts(fileparts(CalibData.XmlInputFile)); 372 end 373 DataSeries=uigetfile_uvmat('open a folder of images to calibrate',InputDir,'uigetdir'); 374 %SubProject=uigetfile_uvmat('open folder of subproject to calibrate',InputDir,'uigetdir'); 375 OutPut=browse_data(DataSeries); 376 nbcalib=0; 377 for ilist=1:numel(OutPut.Experiment) 378 SubDirBase=regexprep(OutPut.DataSeries{1},'\..+$',''); 379 XmlName=fullfile(OutPut.Campaign,OutPut.Experiment{ilist},[SubDirBase '.xml']); 380 dispmessage=' created with calibration parameters'; 381 % copy the xml file from the old location if appropriate, then update with the calibration parameters 382 if ~exist(XmlName,'file') && ~isempty(SubDirBase) 383 oldxml=fullfile(OutPut.Campaign,OutPut.Experiment{ilist},SubDirBase,[get(hhuvmat.RootFile,'String') '.xml']); 384 if exist(oldxml,'file') 385 [success,message]=copyfile(oldxml,XmlName);%copy the old xml file to a new one with the new convention 386 dispmessage=' updated with calibration parameters'; 387 end 388 end 389 errormsg=update_imadoc(GeometryCalib,XmlName,'GeometryCalib');% introduce the calibration data in the xml file 390 if ~strcmp(errormsg,'') 391 msgbox_uvmat('ERROR',errormsg); 392 else 393 display([XmlName dispmessage]) 394 nbcalib=nbcalib+1; 395 end 396 end 397 msgbox_uvmat('CONFIMATION',[SubDirBase ' calibrated for ' num2str(nbcalib) ' experiments']); 398 399 hbrowse=findobj(allchild(0),'Tag','browse_data'); 400 if ~isempty(hbrowse) 401 delete(hbrowse) 402 end 403 end 399 404 %------------------------------------------------------------------------ 400 405 % --- activate calibration and store parameters in ouputfile .
Note: See TracChangeset
for help on using the changeset viewer.