Changeset 745 for trunk


Ignore:
Timestamp:
Apr 18, 2014, 7:26:31 AM (7 years ago)
Author:
sommeria
Message:

set_slice installed

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r738 r745  
    142142    set(handles.ListCoord,'Data',[])
    143143    if exist(struct.XmlInputFile,'file')
    144         Heading=loadfile(handles,struct.XmlInputFile);% load data from the xml file
     144        Heading=loadfile(handles,struct.XmlInputFile);% load data from the xml file and fill the GUI
    145145        if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
    146146            struct.Campaign=Heading.Campaign;
     
    216216   
    217217    %% display image with new calibration in the currently opened uvmat interface
    218     set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image
    219     UserData=get(handles.geometry_calib,'UserData');
    220     UserData.XmlInputFile=outputfile;%save the current xml file name
    221     set(handles.geometry_calib,'UserData',UserData)
    222     uvmat('InputFileREFRESH_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
    223     PLOT_Callback(hObject, eventdata, handles)
    224     set(handles.CoordLine,'string',num2str(index))
    225     Coord=get(handles.ListCoord,'Data');
    226     update_calib_marker(Coord(index,:)); %indicate the point with max deviations from phys coord to calibration
    227     figure(handles.geometry_calib)% put the GUI geometry_calib in front
    228     set(handles.APPLY,'BackgroundColor',[1 0 0]) % set APPLY button to red color
     218    FieldList=get(hhuvmat.FieldName,'String');
     219    val=get(hhuvmat.FieldName,'Value');
     220    if strcmp(FieldList{val},'image')
     221        set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image
     222        UserData=get(handles.geometry_calib,'UserData');
     223        UserData.XmlInputFile=outputfile;%save the current xml file name
     224        set(handles.geometry_calib,'UserData',UserData)
     225        uvmat('InputFileREFRESH_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
     226        PLOT_Callback(hObject, eventdata, handles)
     227        set(handles.CoordLine,'string',num2str(index))
     228        Coord=get(handles.ListCoord,'Data');
     229        update_calib_marker(Coord(index,:)); %indicate the point with max deviations from phys coord to calibration
     230        figure(handles.geometry_calib)% put the GUI geometry_calib in front
     231        set(handles.APPLY,'BackgroundColor',[1 0 0]) % set APPLY button to red color
     232    else
     233        msgbox_uvmat('WARNING','open the image to see the effect of the new calibration')
     234    end
    229235end
    230236
     
    251257nbcalib=0;
    252258for ilist=1:numel(OutPut.Experiment)
    253     SubDirBase=regexprep(OutPut.Device{1},'\..+$','');
     259    SubDirBase=regexprep(OutPut.DataSeries{1},'\..+$','');
    254260    XmlName=fullfile(OutPut.Campaign,OutPut.Experiment{ilist},[SubDirBase '.xml']);
    255261    % copy the xml file from the old location if appropriate, then update with the calibration parameters
     
    274280function [GeometryCalib,index]=calibrate(handles,hhuvmat)
    275281%------------------------------------------------------------------------
     282set(handles.CheckEnableMouse,'Value',0)% desactivate mouse (to avoid spurious creation of new points)
    276283%% read the current calibration points
    277284index=[];
  • trunk/src/phys_XYZ.m

    r242 r745  
    1212test_refraction=0;
    1313if exist('Zindex','var')&& isequal(Zindex,round(Zindex))&& Zindex>0 && isfield(Calib,'SliceCoord')&&length(Calib.SliceCoord)>=Zindex
    14     if isfield(Calib, 'SliceAngle') && ~isequal(Calib.SliceAngle,[0 0 0])
     14    if isfield(Calib, 'SliceAngle') && ~isequal(Calib.SliceAngle,[0 0 0]) && ~isequal(Calib.SliceAngle(Zindex,:),[0 0 0])
    1515        testangle=1;
    1616        om=norm(Calib.SliceAngle(Zindex,:));%norm of rotation angle in radians
  • trunk/src/set_object.m

    r738 r745  
    661661    ProjMode=menu{value};
    662662    if strcmp(ProjMode,'mask_inside')||strcmp(ProjMode,'mask_outside')
    663         displ_txt={displ_txt; '(to create a mask image, use save_mask on the GUI uvmat upper menu)'};
     663        displ_txt=[displ_txt; '(note: to create a mask image, use ''Tools/make mask'' on the upper bar menu of uvmat)'];
    664664    end
    665665    answer=msgbox_uvmat('INPUT_TXT',displ_txt,def);
  • trunk/src/update_imadoc.m

    r634 r745  
    7171%% save the output file
    7272t=struct2xml(Struct,t,uid_calib);
     73try
    7374save(t,outputfile);
     75catch ME
     76    errormsg=['error in update_imadoc' ME.message];
     77end
  • trunk/src/uvmat.m

    r740 r745  
    509509    return
    510510end
    511 DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
    512 ListStruct=dir(DirName); %list files and the dir DataSeries
    513 % select the first appropriate file in the dir
    514 FileName='';
    515 for ilist=1:numel(ListStruct)
    516     if ~isequal(ListStruct(ilist).isdir,1)%look for files, not dir
    517         FileName=ListStruct(ilist).name;
    518         FileType=get_file_type(fullfile(DirName,FileName));
    519         switch FileType
    520             case {'image','multimage','civx','civdata','netcdf'}
    521                 break
    522         end
    523     end
    524 end
    525 if isempty(FileName)
    526     msgbox_uvmat('ERROR',['no appropriate input file in the DataSeries folder ' fullfile(DirName)])
     511fileinput=uigetfile_uvmat('pick an input file',fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1}));
     512hh=dir(fileinput);
     513if numel(hh)>1
     514    msgbox_uvmat('ERROR','invalid input, probably a broken link');
    527515    return
    528516end
     517
     518%
     519% DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
     520% ListStruct=dir(DirName); %list files and the dir DataSeries
     521% % select the first appropriate file in the dir
     522% FileName='';
     523% for ilist=1:numel(ListStruct)
     524%     if ~isequal(ListStruct(ilist).isdir,1)%look for files, not dir
     525%         FileName=ListStruct(ilist).name;
     526%         FileType=get_file_type(fullfile(DirName,FileName));
     527%         switch FileType
     528%             case {'image','multimage','civx','civdata','netcdf'}
     529%                 break
     530%         end
     531%     end
     532% end
     533% if isempty(FileName)
     534%     msgbox_uvmat('ERROR',['no appropriate input file in the DataSeries folder ' fullfile(DirName)])
     535%     return
     536% end
    529537
    530538%% update the list of campaigns in the menubar
     
    549557
    550558%% display the selected field and related information
    551 display_file_name( handles,fullfile(DirName,FileName))
    552 
     559%display_file_name( handles,fullfile(DirName,FileName))
     560display_file_name( handles,fileinput)
    553561set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
    554562
     
    564572end
    565573DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
    566 hdir=dir(DirName); %list files and dirs
    567 FileName='';
    568 for ilist=1:numel(hdir)
    569     if ~isequal(hdir(ilist).isdir,1)%look for files, not dir
    570         FileName=hdir(ilist).name;
    571         FileType=get_file_type(fullfile(DirName,FileName));
    572         switch FileType
    573             case {'image','multimage','civx','civdata','netcdf'}
    574             break
    575         end
    576     end
    577 end
    578 if isempty(FileName)
    579     msgbox_uvmat('ERROR','no valid input file in the selected directory')
    580 else
    581 display_file_name(handles,fullfile(DirName,FileName))
    582 end
     574fileinput=uigetfile_uvmat('pick an input file',fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1}));
     575hh=dir(fileinput);
     576if numel(hh)>1
     577    msgbox_uvmat('ERROR','invalid input, probably a broken link');
     578    return
     579end
     580%
     581% hdir=dir(DirName); %list files and dirs
     582% FileName='';
     583% for ilist=1:numel(hdir)
     584%     if ~isequal(hdir(ilist).isdir,1)%look for files, not dir
     585%         FileName=hdir(ilist).name;
     586%         FileType=get_file_type(fullfile(DirName,FileName));
     587%         switch FileType
     588%             case {'image','multimage','civx','civdata','netcdf'}
     589%             break
     590%         end
     591%     end
     592% end
     593% if isempty(FileName)
     594%     msgbox_uvmat('ERROR','no valid input file in the selected directory')
     595% else
     596display_file_name(handles,fileinput)
     597% end
    583598set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
    584599
     
    953968        if isfield(XmlDataRead, 'GeometryCalib') && ~isempty(XmlDataRead.GeometryCalib)
    954969            XmlData.GeometryCalib=XmlDataRead.GeometryCalib;
    955             if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y')
     970            if isfield(XmlData.GeometryCalib,'CheckVolumeScan') && isequal(XmlData.GeometryCalib.CheckVolumeScan,1)
    956971                set (handles.slices,'String','volume')
    957972            end
     
    10551070               set(handles.slices,'Value',1)
    10561071           end
    1057            if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y')
     1072           if isfield(GeometryCalib,'CheckVolumeScan') && isequal(GeometryCalib.CheckVolumeScan,1)
    10581073               set(handles.num_NbSlice,'Visible','off')
    10591074           else
     
    49844999if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'GeometryCalib')&& isfield(UvData.XmlData{1}.GeometryCalib,'SliceCoord')
    49855000    GeometryCalib=UvData.XmlData{1}.GeometryCalib;
    4986     SliceCoord=GeometryCalib.SliceCoord;
    49875001else
    49885002    msgbox_uvmat('ERROR','3D geometric calibration needed before defining slices')
    49895003    return
    49905004end   
    4991 NbSlice_j=1;%default
    4992 Z=SliceCoord(:,3);
    4993 % index=index(ind_dim);
    4994 %set the Z position of the reference plane used for calibration
    4995 if isequal(max(Z),min(Z))%Z constant
    4996     Z_plane=Z(1);
    4997     GeometryCalib.NbSlice=1;
    4998     GeometryCalib.SliceCoord=[0 0 Z_plane];
    4999 end
    5000 ZStart=SliceCoord(1,3);% first Z coordinate present in the calibration file
    5001 ZEnd=SliceCoord(end,3);% last Z coordinate present in the calibration file
    5002 volume_scan='n';
    5003 if isfield(UvData,'XmlData')
    5004     if isfield(UvData.XmlData{1},'TranslationMotor')
    5005         NbSlice_j=UvData.XmlData.TranslationMotor.Nbslice;
    5006         ZStart=UvData.XmlData.TranslationMotor.ZStart/10;
    5007         ZEnd=UvData.XmlData.TranslationMotor.ZEnd/10;
    5008         volume_scan='y';
    5009     end
     5005SliceCoord=GeometryCalib.SliceCoord;
     5006InterfaceCoord=min(SliceCoord(:,3));
     5007if isfield(GeometryCalib,'InterfaceCoord')
     5008    InterfaceCoord=GeometryCalib.InterfaceCoord(1,3);
     5009end
     5010NbSlice=size(SliceCoord,1);
     5011CheckVolumeScan=0;
     5012if isfield(GeometryCalib,'CheckVolumeScan')
     5013    CheckVolumeScan=GeometryCalib.CheckVolumeScan;
    50105014end     
    5011 
    5012 
    5013 % hfig=findobj(allchild(0),'tag','set_slices');
    5014 % if isempty(hfig)
    5015 %     set(0,'Unit','points')
    5016 %     ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
    5017 %     Width=350;% fig width in points (1/72 inch)
    5018 %     Height=min(0.8*ScreenSize(4),500);
    5019 %     Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40
    5020 %     Bottom=ScreenSize(4)-Height-40; %put fig at top right
    5021 %     hfig=figure('name','set_slices','tag','set_slices','MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height]);
    5022 %     BackgroundColor=get(hfig,'Color');
    5023 %     path_title=uicontrol('Style','text','Units','normalized', 'Position', [0.02 0.97 0.9 0.03],'BackgroundColor',BackgroundColor,'Tag','Path_title',...
    5024 %         'String','path:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');
    5025 %     htitlebox=uicontrol('Style','edit','Units','normalized', 'Position', [0.02 0.89 0.96 0.08],'tag','titlebox','Max',2,'BackgroundColor',[1 1 1],'Callback',@titlebox_Callback,...
    5026 %         'String',InputDir,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''titlebox'':current path');
    5027 %     uicontrol('Style','pushbutton','Tag','backward','Units','normalized','Position',[0.02 0.77 0.1 0.05],...
    5028 %         'String','<--','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@backward,'TooltipString','move backward');
    5029 %     home_button=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.14 0.77 0.2 0.05],...
    5030 %         'String','Work dir','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@home_dir,'TooltipString','reach the current Matlab working directory');
    5031 %     uicontrol('Style','pushbutton','Tag','refresh','Units','normalized','Position', [0.36 0.77 0.2 0.05],'Callback',@refresh_GUI,...
    5032 %         'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',12);
    5033 %     uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.75 0.74 0.23 0.05],'tag','sort_option','Callback',@refresh_GUI,'Visible','off',...
    5034 %         'String',{'sort name';'sort date'},'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''sort_option'': sort the files by names or dates');
    5035 %     uicontrol('Style','listbox','Units','normalized', 'Position',[0.02 0.08 0.96 0.66], 'Callback', @(src,event)list_Callback(option,FilterExt,src,event),'tag','list',...
    5036 %         'FontUnits','points','FontSize',12,'TooltipString','''list'':current list of directories, marked by +/, and files');
    5037 %     
    5038 %     OK_button=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.58 0.005 0.2 0.07],'BackgroundColor',[0 1 0],...
    5039 %         'String','OK','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@(src,event)OK_Callback(option,FilterExt,src,event));
    5040 %     close_button=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.78 0.005 0.2 0.07],'Callback',@(src,event)close(option,src,event),...
    5041 %         'FontWeight','bold','FontUnits','points','FontSize',12);
    5042 %     %set(hrefresh,'UserData',StatusData)
    5043 %     if strcmp(option,'status_display') %put a run advancement display
    5044 %         set(hfig,'DeleteFcn',@(src,event)close(option,src,event))
    5045 %         uicontrol('Style','frame','Units','normalized', 'Position', [0.02 0.85 0.9 0.04]);
    5046 %         uicontrol('Style','frame','Units','normalized', 'Position',[0.02 0.85 0.01 0.04],'BackgroundColor',[1 0 0],'tag','waitbar');
    5047 %         %             uicontrol('Style','text','Units','normalized', 'Position', [0.4 0.8 0.35 0.03],'BackgroundColor',BackgroundColor,...
    5048 %         %             'String','sort: ','FontUnits','points','FontSize',12,'FontWeight','bold','HorizontalAlignment','right');
    5049 %         delete(home_button)
    5050 %         set(OK_button,'String','Open')
    5051 %         set(close_button,'String','Close')
    5052 %     elseif strcmp(FilterExt,'uigetdir') %pick a  directory
    5053 %         set(path_title,'String',title); %show the input title for path (directory)
    5054 %         set(OK_button,'String','Select')
    5055 %         set(close_button,'String','Cancel')
    5056 %     else  %put a title and additional pushbuttons
    5057 %         uicontrol('Style','text','Units','normalized', 'Position', [0.02 0.74 0.6 0.03],'BackgroundColor',BackgroundColor,...
    5058 %             'String',title,'FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');
    5059 %         uicontrol('Style','togglebutton','Units','normalized', 'Position', [0.75 0.78 0.23 0.04],'tag','check_date','Callback',@dates_Callback,...
    5060 %             'String','show dates','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''check_date'':press button to display dates');
    5061 % %         uicontrol('Style','text','Units','normalized', 'Position', [0.37 0.8 0.35 0.03],'BackgroundColor',BackgroundColor,...
    5062 % %             'String','sort: ','FontUnits','points','FontSize',12,'FontWeight','bold','HorizontalAlignment','right');
    5063 %          set(OK_button,'String','Open')
    5064 %          set(close_button,'String','Cancel')   
    5065 %     end
    5066 %     drawnow
    5067 % end
    5068 % refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName,FilterExt)% refresh the list of content of the current dir
    5069 % if ~strcmp(option,'status_display')
    5070 %     uiwait(hfig)
    5071 %     if ishandle(hfig)
    5072 %         htitlebox=findobj(hfig,'Tag','titlebox');
    5073 %         fileinput=get(htitlebox,'String');% retrieve the input file selection
    5074 %         delete(hfig)
    5075 %     end
    5076 % end
    5077 
    5078 
    5079 input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'};
    5080 input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}];
    5081 answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on');
    5082 GeometryCalib.NbSlice=str2double(answer{5});
    5083 GeometryCalib.VolumeScan=answer{6};
    5084 if isempty(answer)
    5085     Z_plane=0; %default
    5086 else
    5087     Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice);
    5088 end
    5089 GeometryCalib.SliceCoord=Z_plane'*[0 0 1];
    5090 if str2double(answer{7})==0 && str2double(answer{8})==0
    5091     GeometryCalib.SliceAngle=[0 0 0];
    5092 else
    5093 GeometryCalib.SliceAngle=zeros(GeometryCalib.NbSlice,3);
    5094 GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise)
    5095 GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise)
    5096 GeometryCalib.SliceAngle(:,3)=0;
    5097 end
    5098 GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})];
    5099 GeometryCalib.RefractionIndex=str2double(answer{4});
    5100 
    5101 %% store the result in the xml file used for calibration
    5102 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     5015RefractionIndex=1.33;
     5016if isfield(GeometryCalib,'RefractionIndex')
     5017    RefractionIndex=GeometryCalib.RefractionIndex;
     5018end     
     5019SliceAngle=[0 0 0];
     5020if isfield(GeometryCalib,'SliceAngle')
     5021    SliceAngle=GeometryCalib.SliceAngle;
     5022end
     5023
     5024%% create the GUI set_slice
     5025set(0,'Unit','points')
     5026ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
     5027Width=350;% fig width in points (1/72 inch)
     5028Height=min(0.8*ScreenSize(4),300);
     5029Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40
     5030Bottom=ScreenSize(4)-Height-40; %put fig at top right
     5031hfig=findobj(allchild(0),'Tag','set_slice');
     5032if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI
     5033hfig=figure('name','set_slices','tag','set_slice','MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height],'UserData',GeometryCalib);
     5034BackgroundColor=get(hfig,'Color');
     5035hh=0.14; % box height (relative)
     5036ii=0.01; % gap between uicontrols
     5037
     5038ww=(1-5*ii)/4; % box width (relative)
     5039% first raw of the GUI
     5040uicontrol('Style','text','Units','normalized', 'Position', [2*ii+ww 0.95-ii-0.25*hh ww hh/2],'BackgroundColor',BackgroundColor,...
     5041    'String','first','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     5042uicontrol('Style','text','Units','normalized', 'Position', [3*ii+2*ww 0.95-ii-0.25*hh ww hh/2],'BackgroundColor',BackgroundColor,...
     5043    'String','last','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     5044uicontrol('Style','text','Units','normalized', 'Position', [4*ii+3*ww 0.95-ii-0.25*hh ww hh/2],'BackgroundColor',BackgroundColor,...
     5045    'String','surface','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     5046%  raw 2 of the GUI
     5047uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-2*ii-0.75*hh ww hh/2],'BackgroundColor',BackgroundColor,...
     5048    'String','Z','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title
     5049uicontrol('Style','edit','Units','normalized', 'Position', [2*ii+ww 0.95-2*ii-hh ww hh],'tag','num_Z_1','BackgroundColor',[1 1 1],...
     5050    'String',num2str(SliceCoord(1,3)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_Z_1'': z position of first slice');%edit box
     5051uicontrol('Style','edit','Units','normalized', 'Position', [3*ii+2*ww 0.95-2*ii-hh ww hh],'tag','num_Z_2','BackgroundColor',[1 1 1],...
     5052    'String',num2str(SliceCoord(end,3)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_Z_2'': z position of last slice');%edit box
     5053uicontrol('Style','edit','Units','normalized', 'Position', [4*ii+3*ww 0.95-2*ii-hh ww hh],'tag','num_H','BackgroundColor',[1 1 1],...
     5054    'String',num2str(InterfaceCoord),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_H'': z position of the water surface (=Z_1 in air)');%edit box
     5055%  raw 3 of the GUI
     5056uicontrol('Style','text','Units','normalized', 'Position', [2*ii+ww 0.95-3*ii-1.75*hh 2*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Refraction_title',...
     5057    'String','refraction index','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title
     5058uicontrol('Style','edit','Units','normalized', 'Position', [4*ii+3*ww 0.95-3*ii-2*hh ww hh],'tag','num_RefractionIndex','BackgroundColor',[1 1 1],...
     5059    'String',num2str(RefractionIndex),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_RefractionIndex'': refraction index of water');
     5060%  raw 4 of the GUI
     5061uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-4*ii-3.25*hh ww hh],'BackgroundColor',BackgroundColor,'Tag','NbSlice_title',...
     5062    'String','NbSlice','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title
     5063uicontrol('Style','edit','Units','normalized', 'Position', [2*ii+ww 0.95-4*ii-3*hh ww hh],'tag','num_NbSlice','BackgroundColor',[1 1 1],...
     5064    'String',num2str(NbSlice),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_NbSlice'':number of slices');%edit box
     5065uicontrol('Style','checkbox','Units','normalized', 'Position', [3*ii+2*ww 0.95-4*ii-3*hh 2*ww hh],'tag','CheckVolumeScan','BackgroundColor',BackgroundColor,...
     5066    'String','volume scan','Value',CheckVolumeScan,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''CheckVolumeScan'':=1 for volume scan (z varies with j index)');
     5067%  raw 5 of the GUI
     5068uicontrol('Style','text','Units','normalized', 'Position', [2*ii+2*ww 0.95-5*ii-4.2*hh ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_1',...
     5069    'String','x axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     5070uicontrol('Style','text','Units','normalized', 'Position', [3*ii+3*ww 0.95-5*ii-4.2*hh ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_2',...
     5071    'String','y axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title
     5072%  raw 6 of the GUI
     5073uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-5*ii-4.75*hh 2*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','NbSlice_title',...
     5074    'String','tilt angle','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title
     5075uicontrol('Style','edit','Units','normalized', 'Position', [3*ii+2*ww 0.95-5*ii-5*hh ww hh],'tag','num_SliceAngle_1','BackgroundColor',[1 1 1],...
     5076    'String',num2str(SliceAngle(1)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceAngle_1'':slice angle of inclination around the x axis');%edit box
     5077uicontrol('Style','edit','Units','normalized', 'Position', [4*ii+3*ww 0.95-5*ii-5*hh ww hh],'tag','num_SliceAngle_2','BackgroundColor',[1 1 1],...
     5078    'String',num2str(SliceAngle(2)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceAngle_1'':slice angle of inclination around the y axis');%edit box
     5079%  raw 7 of the GUI: pushbuttons
     5080wwp=(1-4*ii)/3; %width of the push buttons
     5081uicontrol('Style','pushbutton','Units','normalized', 'Position', [ii ii wwp hh],'BackgroundColor',[1 0 0],'String','APPLY','Callback',@(hObject,eventdata)set_slice_APPLY_Callback(hObject,eventdata),...
     5082    'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''APPLY'': apply the output to the current field series in uvmat');
     5083uicontrol('Style','pushbutton','Units','normalized', 'Position', [2*ii+wwp ii wwp hh],'BackgroundColor',[1 0 0],'String','REPLICATE','Callback',@(hObject,eventdata)set_slice_REPLICATE_Callback(hObject,eventdata),...
     5084    'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''REPLICATE'': replicate the output for a series of experiments');
     5085uicontrol('Style','pushbutton','Units','normalized', 'Position', [3*ii+2*wwp ii wwp hh],'Callback',@(hObject,eventdata)set_slice_Cancel_Callback(hObject,eventdata),...
     5086    'String','Cancel','FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''Cancel'': quit GUI without action');
     5087drawnow
     5088
     5089%------------------------------------------------------------------------
     5090% function called by pressing APPLY in the GUI  set_slices
     5091function set_slice_APPLY_Callback(hObject,eventdata)
     5092%------------------------------------------------------------------------   
     5093
     5094%% get the uvmat GUI data and read the current xml file
     5095huvmat=findobj(allchild(0),'Tag','uvmat');
     5096hhuvmat=guidata(huvmat);
     5097[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(hhuvmat);
    51035098FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%name of the xml file for calibration
    51045099[RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(FileName);
    51055100XmlFile=find_imadoc(RootPath,SubDir,RootFile,FileExt);
     5101[s,errormsg]=imadoc2struct(XmlFile,'GeometryCalib');
     5102if~isempty(errormsg)
     5103    msgbox_uvmat('ERROR',errormsg)
     5104    return
     5105end
     5106GeometryCalib=s.GeometryCalib;
     5107
     5108%% read the content of the GUI set_slice
     5109SliceData=read_GUI(get(hObject,'parent'));
     5110GeometryCalib.NbSlice=SliceData.NbSlice;
     5111GeometryCalib.CheckVolumeScan=SliceData.CheckVolumeScan;
     5112Z_plane=linspace(SliceData.Z(1),SliceData.Z(2),SliceData.NbSlice);
     5113GeometryCalib.SliceCoord=Z_plane'*[0 0 1];
     5114GeometryCalib.SliceAngle=zeros(GeometryCalib.NbSlice,3);
     5115GeometryCalib.SliceAngle(:,1)=SliceData.SliceAngle(1)*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise)
     5116GeometryCalib.SliceAngle(:,2)=SliceData.SliceAngle(2)*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise)
     5117GeometryCalib.SliceAngle(:,3)=0;
     5118GeometryCalib.InterfaceCoord=[0 0 SliceData.H];
     5119GeometryCalib.RefractionIndex=SliceData.RefractionIndex;
     5120
     5121%% store the result in the xml file used for calibration
    51065122errormsg=update_imadoc(GeometryCalib,XmlFile,'GeometryCalib');% introduce the calibration data in the xml file
    5107 if ~strcmp(errormsg,'')
     5123if strcmp(errormsg,'')
     5124    msgbox_uvmat('CONFIRMATION',['slice positions saved in ' XmlFile]);
     5125else
    51085126    msgbox_uvmat('ERROR',errormsg);
    51095127end
    51105128
    51115129%% display image with new calibration in the currently opened uvmat interface
    5112 set(handles.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image
    5113 InputFileREFRESH_Callback(hObject,eventdata,handles); %file input with xml reading  in uvmat, show the image in phys coordinates
     5130set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image
     5131uvmat('InputFileREFRESH_Callback',huvmat,[],hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
     5132
     5133%------------------------------------------------------------------------
     5134% function called by pressing REPLICATE in the GUI  set_slices
     5135function set_slice_REPLICATE_Callback(hObject,eventdata)
     5136%------------------------------------------------------------------------
     5137
     5138%% read the GUI set_slice
     5139SliceData=read_GUI(get(hObject,'parent'));
     5140
     5141%% get info on the GUI uvmat
     5142huvmat=findobj(allchild(0),'Tag','uvmat');
     5143hhuvmat=guidata(huvmat);
     5144[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(hhuvmat);
     5145
     5146%% open the GUI browse_data
     5147answer=msgbox_uvmat('INPUT_TXT','Campaign to calibrate with slice position?',fileparts(RootPath));
     5148if strcmp(answer,'Cancel')
     5149    return
     5150end
     5151OutPut=browse_data(answer);
     5152nbcalib=0;
     5153for ilist=1:numel(OutPut.Experiment)
     5154    SubDirBase=regexprep(OutPut.DataSeries{1},'\..+$','');
     5155    XmlFile=fullfile(OutPut.Campaign,OutPut.Experiment{ilist},[SubDirBase '.xml']);
     5156   
     5157    % read the current xml file
     5158    [s,errormsg]=imadoc2struct(XmlFile,'GeometryCalib');
     5159    if ~isempty(errormsg)
     5160        msgbox_uvmat('ERROR',['error in reading ' XmlFile ': ' errormsg])
     5161        return
     5162    end
     5163    GeometryCalib=s.GeometryCalib;
     5164    GeometryCalib.NbSlice=SliceData.NbSlice;
     5165    GeometryCalib.VolumeScan=SliceData.CheckVolumeScan;
     5166    Z_plane=linspace(SliceData.Z(1),SliceData.Z(2),SliceData.NbSlice);
     5167    GeometryCalib.SliceCoord=Z_plane'*[0 0 1];
     5168    GeometryCalib.SliceAngle=zeros(GeometryCalib.NbSlice,3);
     5169    GeometryCalib.SliceAngle(:,1)=SliceData.SliceAngle(1)*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise)
     5170    GeometryCalib.SliceAngle(:,2)=SliceData.SliceAngle(2)*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise)
     5171    GeometryCalib.SliceAngle(:,3)=0;
     5172    GeometryCalib.InterfaceCoord=[0 0 SliceData.H];
     5173    GeometryCalib.RefractionIndex=SliceData.RefractionIndex;
     5174   
     5175    % update the current xml file
     5176    errormsg=update_imadoc(GeometryCalib,XmlFile,'GeometryCalib');% introduce the calibration data in the xml file
     5177    if ~strcmp(errormsg,'')
     5178        msgbox_uvmat('ERROR',errormsg);
     5179    else
     5180        display([XmlFile ' updated with slice positions'])
     5181        nbcalib=nbcalib+1;
     5182    end
     5183end
     5184msgbox_uvmat('CONFIMATION',[SubDirBase ' calibrated with slice positions for ' num2str(nbcalib) ' experiments']);
     5185
     5186%------------------------------------------------------------------------
     5187% function called by pressing Cancel in the GUI  set_slices
     5188function set_slice_Cancel_Callback(hObject,eventdata)
     5189%------------------------------------------------------------------------
     5190hfig=get(hObject,'parent');
     5191delete(hfig)
    51145192
    51155193%-----------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.