Changeset 1063 for trunk/src


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

geometric calibration corrected

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/browse_data.m

    r1061 r1063  
    2424function varargout = browse_data(varargin)
    2525
    26 % Last Modified by GUIDE v2.5 08-Sep-2018 19:03:40
     26% Last Modified by GUIDE v2.5 17-Apr-2019 18:15:24
    2727
    2828% Begin initialization code - DO NOT EDIT
     
    7575set(hObject, 'Units', OldUnits);
    7676if exist('MultiDevices','var') && strcmp(MultiDevices,'on')
    77     set(handles.ListDevices,'Max',2)
    78 else
    79     set(handles.ListDevices,'Max',1)
     77    set(handles.DataSeries,'Max',2)
     78else
     79    set(handles.DataSeries,'Max',1)
    8080end
    8181if exist('EnableMirror','var') && strcmp(EnableMirror,'on')
     
    212212% List the experiments in a campaign, filling the menu ListExperiments
    213213%------------------------------------------------------------------------
    214 function errormsg=scan_campaign(handles,Campaign,Experiment,DataSeries)
     214function errormsg=scan_campaign(handles,Campaign,Experiment,DataInput)
    215215%------------------------------------------------------------------------
    216216errormsg='';
     
    233233    set(handles.ListExperiments,'Value',index)% initialise the menu selection with the folder defined by the input
    234234    ListExperiments_Callback([],[], handles)
    235     ListDevices=get(handles.ListDevices,'String');
    236     index=find(strcmp(['+/' DataSeries],ListDevices));
     235    DataSeries=get(handles.DataSeries,'String');
     236    index=find(strcmp(['+/' DataInput],DataSeries));
    237237    if isempty(index)
    238         index=find(strcmp(['~/' DataSeries],ListDevices));
     238        index=find(strcmp(['~/' DataInput],DataSeries));
    239239    end
    240240    if ~isempty(index)
    241           set(handles.ListDevices,'Value',index)
     241          set(handles.DataSeries,'Value',index)
    242242    end
    243243else
     
    270270 function list_dataseries(handles,ListExperiments,MirrorPath)
    271271
    272 ListDevices={};
     272DataSeries={};
    273273for iexp=1:numel(ListExperiments)
    274274    if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory
     
    295295                        ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list
    296296                    end
    297                     if isempty(find(strcmp(ListFiles{ilist},ListDevices), 1))% if the item is not already in ListDevices
    298                         ListDevices=[ListDevices;ListFiles{ilist}]; %append the item to the list
     297                    if isempty(find(strcmp(ListFiles{ilist},DataSeries), 1))% if the item is not already in DataSeries
     298                        DataSeries=[DataSeries;ListFiles{ilist}]; %append the item to the list
    299299                    end                   
    300300                end
     
    303303    end
    304304end
    305 set(handles.ListDevices,'Value',1)
    306 set(handles.ListDevices,'String',sort(ListDevices))
     305set(handles.DataSeries,'Value',1)
     306set(handles.DataSeries,'String',sort(DataSeries))
    307307
    308308%------------------------------------------------------------------------
     
    311311 function update_experiments(handles,ListExperiments,CampaignPath,MirrorPath)
    312312
    313 ListDevices={};
     313DataSeries={};
    314314for iexp=1:numel(ListExperiments)
    315315    if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory
     
    350350                        system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder                     
    351351                    end
    352                     if isempty(find(strcmp(ListFiles{ilist},ListDevices), 1))% if the item is not already in ListDevices
     352                    if isempty(find(strcmp(ListFiles{ilist},DataSeries), 1))% if the item is not already in DataSeries
    353353                        if check_dir(ilist)
    354354                            ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list
    355355                        end
    356                         ListDevices=[ListDevices;ListFiles{ilist}]; %append the item to the list
     356                        DataSeries=[DataSeries;ListFiles{ilist}]; %append the item to the list
    357357                    end
    358358                end
     
    361361    end
    362362end
    363 set(handles.ListDevices,'String',sort(ListDevices))
     363set(handles.DataSeries,'String',sort(DataSeries))
    364364
    365365%------------------------------------------------------------------------
     
    464464end
    465465Experiment=regexprep(Experiment,'^\+/','');% remove the +/ used to mark dir
    466 Device=get(handles.ListDevices,'String');
    467 Value=get(handles.ListDevices,'Value');
     466Device=get(handles.DataSeries,'String');
     467Value=get(handles.DataSeries,'Value');
    468468Device=Device(Value);
    469469Device=regexprep(Device,'^\+/','');% remove the +/ used to mark dir
     
    553553function Up_Callback(hObject, eventdata, handles)
    554554SourceDir=get(handles.SourceDir,'String');
    555 % Device=ListDevices{get(handles.ListDevices,'Value')};
     555% Device=DataSeries{get(handles.DataSeries,'Value')};
    556556% DataSeries=uigetfile_uvmat('open a data folder',Device,'uigetdir');
    557557% uiresume(handles.browse_data);
     
    566566SourceFolder=regexprep(ListExperiments{list_val(1)},'+','');
    567567set(handles.SourceDir,'String',fullfile(SourceDir,SourceFolder))
    568 ListDevices=get(handles.ListDevices,'String');
    569 ValueDevice=get(handles.ListDevices,'Value');
    570 set(handles.ListExperiments,'String',ListDevices)
     568DataSeries=get(handles.DataSeries,'String');
     569ValueDevice=get(handles.DataSeries,'Value');
     570set(handles.ListExperiments,'String',DataSeries)
    571571set(handles.ListExperiments,'Value',ValueDevice)
    572572ListExperiments_Callback(hObject, [], handles)
    573 % Device=regexprep(ListDevices{get(handles.ListDevices,'Value')},'+','');
     573% Device=regexprep(DataSeries{get(handles.DataSeries,'Value')},'+','');
    574574% Device=regexprep(Device,'~','');
    575575% PathDevice=fullfile(SourceDir,SourceFolder,Device);
     
    578578% % uiresume(handles.browse_data);
    579579% browse_data(fullfile(PathDevice,NewDevice))
     580
     581
     582% --- Executes on selection change in DataSeries.
     583function DataSeries_Callback(hObject, eventdata, handles)
     584% hObject    handle to DataSeries (see GCBO)
     585% eventdata  reserved - to be defined in a future version of MATLAB
     586% handles    structure with handles and user data (see GUIDATA)
     587
     588% Hints: contents = cellstr(get(hObject,'String')) returns DataSeries contents as cell array
     589%        contents{get(hObject,'Value')} returns selected item from DataSeries
     590
     591
     592% --- Executes on button press in CheckDevices.
     593function CheckDevices_Callback(hObject, eventdata, handles)
     594if get(handles.CheckDevices,'Value')
     595    set(handles.ListDevices,'Visible','on')
     596else
     597    set(handles.ListDevices,'Visible','off')
     598end
  • 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 .
  • trunk/src/set_object.m

    r1062 r1063  
    340340        set(handles.num_RangeX_2,'Visible','on')
    341341        set(handles.num_RangeY_1,'Visible','on')
    342         %set(handles.num_RangeY_2,'Visible','on')
     342        set(handles.num_RangeY_2,'Visible','on')
    343343        set(handles.num_RangeZ_2,'TooltipString','num_ZMax: range of projection normal to the plane')
    344344        if test3D
Note: See TracChangeset for help on using the changeset viewer.