Ignore:
Timestamp:
Apr 17, 2019, 6:22:25 PM (5 years ago)
Author:
sommeria
Message:

geometric calibration corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r1062 r1063  
    255255    ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels'];
    256256    [num2str(numel(ind_removed)) ' points removed']});
     257SliceCoord_ref=[0 0 0]; %default reference plane
    257258if strcmp(answer,'Yes') %store the calibration data
    258259    if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration
     
    268269    %%%%% use of the option 'replicate'
    269270    if get(handles.Replicate,'Value')% if the option replicate is activated
     271        nbcalib=0;
    270272        %% open the GUI browse_data
    271273        hbrowse=findobj(allchild(0),'Tag','browse_data');
     
    276278            ListValues=get(BrowseHandles.ListExperiments,'Value');
    277279            ListExperiments=ListExperiments(ListValues);
    278             ListDevices=get(BrowseHandles.ListDevices,'String');
    279             Val=get(BrowseHandles.ListDevices,'Value');
    280             DataFolder=ListDevices{Val};
    281             nbcalib=0;
     280            DataSeries=get(BrowseHandles.DataSeries,'String');
     281            Val=get(BrowseHandles.DataSeries,'Value');
     282            DataFolder=DataSeries{Val};
    282283            for ilist=1:numel(ListExperiments)
    283284                SubDirBase=regexprep(DataFolder,'+/','');
    284285                ListExperiments{ilist}=regexprep(ListExperiments{ilist},'+/','');
    285286                XmlName=fullfile(SourceDir,ListExperiments{ilist},[SubDirBase '.xml']);
    286                 % copy the xml file from the old location if appropriate, then update with the calibration parameters
    287                 %                 if ~exist(XmlName,'file') && ~isempty(SubDirBase)
    288                 %                     oldxml=fullfile(OutPut.Campaign,OutPut.Experiment{ilist},SubDirBase,[get(hhuvmat.RootFile,'String') '.xml']);
    289                 GeometryCalib.SliceCoord=SliceCoord_ref;%default input
    290                 if exist(XmlName,'file')
    291                     %[success,message]=copyfile(oldxml,XmlName);%copy the old xml file to a new one with the new convention
    292                     dispmesGeometryCalib=UvData.XmlData{1}.GeometryCalib;
     287                errormsg=update_imadoc(GeometryCalib,XmlName,'GeometryCalib');% introduce the calibration data in the xml file
     288                if ~strcmp(errormsg,'')
     289                    msgbox_uvmat('ERROR',errormsg);
    293290                else
    294                     msgbox_uvmat('ERROR','3D geometric calibration needed before defining slices')
    295                     return
    296                 end
    297                 SliceCoord=GeometryCalib.SliceCoord;
    298                 InterfaceCoord=min(SliceCoord(:,3));
    299                 if isfield(GeometryCalib,'InterfaceCoord')
    300                     InterfaceCoord=GeometryCalib.InterfaceCoord(1,3);
    301                 end
    302                 NbSlice=size(SliceCoord,1);
    303                 CheckVolumeScan=0;
    304                 if isfield(GeometryCalib,'CheckVolumeScan')
    305                     CheckVolumeScan=GeometryCalib.CheckVolumeScan;
    306                 end
    307                 RefractionIndex=1.33;
    308                 CheckRefraction=0;% default value of the check box refraction
    309                 if isfield(GeometryCalib,'RefractionIndex')
    310                     RefractionIndex=GeometryCalib.RefractionIndex;
    311                     CheckRefraction=1;
    312                 end
    313                 SliceAngle=[0 0 0];
    314                 if isfield(GeometryCalib,'SliceAngle')
    315                     SliceAngle=GeometryCalib.SliceAngle;
    316                 end
    317                 dispmessage=' updated with calibration parameters';
    318                 %                         if ~strcmp(answer,'yes')
    319                 [XmlDataOld,warntext]=imadoc2struct(XmlName);
    320                 if isfield(XmlDataOld,'GeometryCalib')
    321                     if isfield(XmlDataOld.GeometryCalib,'SliceAngle')
    322                         GeometryCalib.SliceAngle=XmlDataOld.GeometryCalib.SliceAngle;
    323                     end
    324                     if isfield(XmlDataOld.GeometryCalib,'CheckRefraction')
    325                         GeometryCalib.SliceAngle=XmlDataOld.GeometryCalib.CheckRefraction;
    326                     end
    327                     if isfield(XmlDataOld.GeometryCalib,'RefractionIndex')
    328                         GeometryCalib.SliceAngle=XmlDataOld.GeometryCalib.RefractionIndex;
    329                     end
    330                     if isfield(XmlDataOld.GeometryCalib,'InterfaceCoord')
    331                         GeometryCalib.SliceAngle=XmlDataOld.GeometryCalib.InterfaceCoord;
    332                     end
     291                    display([XmlName ' updated with calibration parameters'])
     292                    nbcalib=nbcalib+1;
    333293                end
    334294            end
    335 
    336         else % in case the GUI 'replicate'is not found
    337             dispmessage=' created with calibration parameters';
    338295        end
    339         errormsg=update_imadoc(GeometryCalib,XmlName,'GeometryCalib');% introduce the calibration data in the xml file
     296        msgbox_uvmat('CONFIMATION',[SubDirBase ' calibrated for ' num2str(nbcalib) ' experiments']); 
     297    else
     298        %% copy the xml file from the old location if appropriate, then update with the calibration parameters
     299        if ~exist(outputfile,'file') && ~isempty(SubDirBase)
     300            oldxml=[fullfile(RootPath,SubDirBase,get(hhuvmat.RootFile,'String')) '.xml'];
     301            if exist(oldxml,'file')
     302                [success,message]=copyfile(oldxml,outputfile);%copy the old xml file to a new one with the new convention
     303            end
     304        end
     305        errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file
    340306        if ~strcmp(errormsg,'')
    341307            msgbox_uvmat('ERROR',errormsg);
     308        end
     309       
     310        %% display image with new calibration in the currently opened uvmat interface
     311        FieldList=get(hhuvmat.FieldName,'String');
     312        val=get(hhuvmat.FieldName,'Value');
     313        if strcmp(FieldList{val},'image')
     314            set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image
     315            UserData=get(handles.geometry_calib,'UserData');
     316            UserData.XmlInputFile=outputfile;%save the current xml file name
     317            set(handles.geometry_calib,'UserData',UserData)
     318            uvmat('InputFileREFRESH_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
     319            PLOT_Callback(hObject, eventdata, handles)
     320            set(handles.CoordLine,'string',num2str(index))
     321            Coord=get(handles.ListCoord,'Data');
     322            update_calib_marker(Coord(index,:)); %indicate the point with max deviations from phys coord to calibration
     323            figure(handles.geometry_calib)% put the GUI geometry_calib in front
    342324        else
    343             display([XmlName dispmessage])
    344             nbcalib=nbcalib+1;
     325            msgbox_uvmat('WARNING','open the image to see the effect of the new calibration')
    345326        end
    346327    end
    347     % Use of the option replicate
    348 end
    349 msgbox_uvmat('CONFIMATION',[SubDirBase ' calibrated for ' num2str(nbcalib) ' experiments']);
    350 
    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')
    380328end
    381329
    382330set(handles.APPLY,'BackgroundColor',[1 0 0]) % set APPLY button to red color
    383                    
     331
    384332%------------------------------------------------------------------------
    385333% --- Executes on button press in Replicate
    386 function Replicate_Callback(hObject, eventdata, handles)
    387 % %------------------------------------------------------------------------
    388 set(handles.CheckEnableMouse,'Value',0)% desactivate mouse (to avoid spurious creation of new points)
    389 
    390 if get(handles.Replicate,'Value') %open the GUI browse_data
    391     % look for the GUI uvmat and check for an image as input
    392     huvmat=findobj(allchild(0),'Name','uvmat');
    393     hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
    394     RootPath=get(hhuvmat.RootPath,'String');
    395     SubDir=get(hhuvmat.SubDir,'String');
    396     browse_data(fullfile(RootPath,SubDir))
    397 else
    398     hbrowse=findobj(allchild(0),'Tag','browse_data');
    399     if ~isempty(hbrowse)
    400         delete(hbrowse)
    401     end
    402 end
     334    function Replicate_Callback(hObject, eventdata, handles)
     335        % %------------------------------------------------------------------------
     336        set(handles.CheckEnableMouse,'Value',0)% desactivate mouse (to avoid spurious creation of new points)
     337       
     338        if get(handles.Replicate,'Value') %open the GUI browse_data
     339            % look for the GUI uvmat and check for an image as input
     340            huvmat=findobj(allchild(0),'Name','uvmat');
     341            hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
     342            RootPath=get(hhuvmat.RootPath,'String');
     343            SubDir=get(hhuvmat.SubDir,'String');
     344            browse_data(fullfile(RootPath,SubDir))
     345        else
     346            hbrowse=findobj(allchild(0),'Tag','browse_data');
     347            if ~isempty(hbrowse)
     348                delete(hbrowse)
     349            end
     350        end
    403351%------------------------------------------------------------------------
    404352% --- activate calibration and store parameters in ouputfile .
Note: See TracChangeset for help on using the changeset viewer.