- Timestamp:
- Apr 18, 2014, 7:26:31 AM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r738 r745 142 142 set(handles.ListCoord,'Data',[]) 143 143 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 145 145 if isfield(Heading,'Campaign')&& ischar(Heading.Campaign) 146 146 struct.Campaign=Heading.Campaign; … … 216 216 217 217 %% 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 229 235 end 230 236 … … 251 257 nbcalib=0; 252 258 for ilist=1:numel(OutPut.Experiment) 253 SubDirBase=regexprep(OutPut.D evice{1},'\..+$','');259 SubDirBase=regexprep(OutPut.DataSeries{1},'\..+$',''); 254 260 XmlName=fullfile(OutPut.Campaign,OutPut.Experiment{ilist},[SubDirBase '.xml']); 255 261 % copy the xml file from the old location if appropriate, then update with the calibration parameters … … 274 280 function [GeometryCalib,index]=calibrate(handles,hhuvmat) 275 281 %------------------------------------------------------------------------ 282 set(handles.CheckEnableMouse,'Value',0)% desactivate mouse (to avoid spurious creation of new points) 276 283 %% read the current calibration points 277 284 index=[]; -
trunk/src/phys_XYZ.m
r242 r745 12 12 test_refraction=0; 13 13 if 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]) 15 15 testangle=1; 16 16 om=norm(Calib.SliceAngle(Zindex,:));%norm of rotation angle in radians -
trunk/src/set_object.m
r738 r745 661 661 ProjMode=menu{value}; 662 662 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)']; 664 664 end 665 665 answer=msgbox_uvmat('INPUT_TXT',displ_txt,def); -
trunk/src/update_imadoc.m
r634 r745 71 71 %% save the output file 72 72 t=struct2xml(Struct,t,uid_calib); 73 try 73 74 save(t,outputfile); 75 catch ME 76 errormsg=['error in update_imadoc' ME.message]; 77 end -
trunk/src/uvmat.m
r740 r745 509 509 return 510 510 end 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)]) 511 fileinput=uigetfile_uvmat('pick an input file',fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1})); 512 hh=dir(fileinput); 513 if numel(hh)>1 514 msgbox_uvmat('ERROR','invalid input, probably a broken link'); 527 515 return 528 516 end 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 529 537 530 538 %% update the list of campaigns in the menubar … … 549 557 550 558 %% display the selected field and related information 551 display_file_name( handles,fullfile(DirName,FileName))552 559 %display_file_name( handles,fullfile(DirName,FileName)) 560 display_file_name( handles,fileinput) 553 561 set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0]) 554 562 … … 564 572 end 565 573 DirName=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 574 fileinput=uigetfile_uvmat('pick an input file',fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1})); 575 hh=dir(fileinput); 576 if numel(hh)>1 577 msgbox_uvmat('ERROR','invalid input, probably a broken link'); 578 return 579 end 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 596 display_file_name(handles,fileinput) 597 % end 583 598 set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0]) 584 599 … … 953 968 if isfield(XmlDataRead, 'GeometryCalib') && ~isempty(XmlDataRead.GeometryCalib) 954 969 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) 956 971 set (handles.slices,'String','volume') 957 972 end … … 1055 1070 set(handles.slices,'Value',1) 1056 1071 end 1057 if isfield(GeometryCalib,' VolumeScan') && isequal(GeometryCalib.VolumeScan,'y')1072 if isfield(GeometryCalib,'CheckVolumeScan') && isequal(GeometryCalib.CheckVolumeScan,1) 1058 1073 set(handles.num_NbSlice,'Visible','off') 1059 1074 else … … 4984 4999 if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'GeometryCalib')&& isfield(UvData.XmlData{1}.GeometryCalib,'SliceCoord') 4985 5000 GeometryCalib=UvData.XmlData{1}.GeometryCalib; 4986 SliceCoord=GeometryCalib.SliceCoord;4987 5001 else 4988 5002 msgbox_uvmat('ERROR','3D geometric calibration needed before defining slices') 4989 5003 return 4990 5004 end 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 5005 SliceCoord=GeometryCalib.SliceCoord; 5006 InterfaceCoord=min(SliceCoord(:,3)); 5007 if isfield(GeometryCalib,'InterfaceCoord') 5008 InterfaceCoord=GeometryCalib.InterfaceCoord(1,3); 5009 end 5010 NbSlice=size(SliceCoord,1); 5011 CheckVolumeScan=0; 5012 if isfield(GeometryCalib,'CheckVolumeScan') 5013 CheckVolumeScan=GeometryCalib.CheckVolumeScan; 5010 5014 end 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); 5015 RefractionIndex=1.33; 5016 if isfield(GeometryCalib,'RefractionIndex') 5017 RefractionIndex=GeometryCalib.RefractionIndex; 5018 end 5019 SliceAngle=[0 0 0]; 5020 if isfield(GeometryCalib,'SliceAngle') 5021 SliceAngle=GeometryCalib.SliceAngle; 5022 end 5023 5024 %% create the GUI set_slice 5025 set(0,'Unit','points') 5026 ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right 5027 Width=350;% fig width in points (1/72 inch) 5028 Height=min(0.8*ScreenSize(4),300); 5029 Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40 5030 Bottom=ScreenSize(4)-Height-40; %put fig at top right 5031 hfig=findobj(allchild(0),'Tag','set_slice'); 5032 if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI 5033 hfig=figure('name','set_slices','tag','set_slice','MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height],'UserData',GeometryCalib); 5034 BackgroundColor=get(hfig,'Color'); 5035 hh=0.14; % box height (relative) 5036 ii=0.01; % gap between uicontrols 5037 5038 ww=(1-5*ii)/4; % box width (relative) 5039 % first raw of the GUI 5040 uicontrol('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 5042 uicontrol('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 5044 uicontrol('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 5047 uicontrol('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 5049 uicontrol('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 5051 uicontrol('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 5053 uicontrol('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 5056 uicontrol('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 5058 uicontrol('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 5061 uicontrol('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 5063 uicontrol('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 5065 uicontrol('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 5068 uicontrol('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 5070 uicontrol('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 5073 uicontrol('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 5075 uicontrol('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 5077 uicontrol('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 5080 wwp=(1-4*ii)/3; %width of the push buttons 5081 uicontrol('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'); 5083 uicontrol('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'); 5085 uicontrol('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'); 5087 drawnow 5088 5089 %------------------------------------------------------------------------ 5090 % function called by pressing APPLY in the GUI set_slices 5091 function set_slice_APPLY_Callback(hObject,eventdata) 5092 %------------------------------------------------------------------------ 5093 5094 %% get the uvmat GUI data and read the current xml file 5095 huvmat=findobj(allchild(0),'Tag','uvmat'); 5096 hhuvmat=guidata(huvmat); 5097 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(hhuvmat); 5103 5098 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%name of the xml file for calibration 5104 5099 [RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(FileName); 5105 5100 XmlFile=find_imadoc(RootPath,SubDir,RootFile,FileExt); 5101 [s,errormsg]=imadoc2struct(XmlFile,'GeometryCalib'); 5102 if~isempty(errormsg) 5103 msgbox_uvmat('ERROR',errormsg) 5104 return 5105 end 5106 GeometryCalib=s.GeometryCalib; 5107 5108 %% read the content of the GUI set_slice 5109 SliceData=read_GUI(get(hObject,'parent')); 5110 GeometryCalib.NbSlice=SliceData.NbSlice; 5111 GeometryCalib.CheckVolumeScan=SliceData.CheckVolumeScan; 5112 Z_plane=linspace(SliceData.Z(1),SliceData.Z(2),SliceData.NbSlice); 5113 GeometryCalib.SliceCoord=Z_plane'*[0 0 1]; 5114 GeometryCalib.SliceAngle=zeros(GeometryCalib.NbSlice,3); 5115 GeometryCalib.SliceAngle(:,1)=SliceData.SliceAngle(1)*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise) 5116 GeometryCalib.SliceAngle(:,2)=SliceData.SliceAngle(2)*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise) 5117 GeometryCalib.SliceAngle(:,3)=0; 5118 GeometryCalib.InterfaceCoord=[0 0 SliceData.H]; 5119 GeometryCalib.RefractionIndex=SliceData.RefractionIndex; 5120 5121 %% store the result in the xml file used for calibration 5106 5122 errormsg=update_imadoc(GeometryCalib,XmlFile,'GeometryCalib');% introduce the calibration data in the xml file 5107 if ~strcmp(errormsg,'') 5123 if strcmp(errormsg,'') 5124 msgbox_uvmat('CONFIRMATION',['slice positions saved in ' XmlFile]); 5125 else 5108 5126 msgbox_uvmat('ERROR',errormsg); 5109 5127 end 5110 5128 5111 5129 %% 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 5130 set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image 5131 uvmat('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 5135 function set_slice_REPLICATE_Callback(hObject,eventdata) 5136 %------------------------------------------------------------------------ 5137 5138 %% read the GUI set_slice 5139 SliceData=read_GUI(get(hObject,'parent')); 5140 5141 %% get info on the GUI uvmat 5142 huvmat=findobj(allchild(0),'Tag','uvmat'); 5143 hhuvmat=guidata(huvmat); 5144 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(hhuvmat); 5145 5146 %% open the GUI browse_data 5147 answer=msgbox_uvmat('INPUT_TXT','Campaign to calibrate with slice position?',fileparts(RootPath)); 5148 if strcmp(answer,'Cancel') 5149 return 5150 end 5151 OutPut=browse_data(answer); 5152 nbcalib=0; 5153 for 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 5183 end 5184 msgbox_uvmat('CONFIMATION',[SubDirBase ' calibrated with slice positions for ' num2str(nbcalib) ' experiments']); 5185 5186 %------------------------------------------------------------------------ 5187 % function called by pressing Cancel in the GUI set_slices 5188 function set_slice_Cancel_Callback(hObject,eventdata) 5189 %------------------------------------------------------------------------ 5190 hfig=get(hObject,'parent'); 5191 delete(hfig) 5114 5192 5115 5193 %-----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.