Changeset 38 for trunk/src/uvmat.m
- Timestamp:
- Mar 7, 2010, 6:30:11 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r36 r38 12 12 % 13 13 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 14 % Copyright Joel Sommeria, Louis Gostiaux, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.14 % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr. 15 15 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 16 16 % This open is part of the toolbox UVMAT. … … 199 199 handles.output = hObject; 200 200 201 % %group handles for input file in a structure handles.InputFile202 % handlesInputFile={handles.RootPath,handles.SubDir,handles.RootFile,handles.FileIndex,handles.FileExt};203 % TagsInputFile={'RootPath','SubDir','RootFile','FileIndex','FileExt'};204 % handles.InputFile=cell2struct(handlesInputFile,TagsInputFile,2);205 %206 % %group handles for the second input file in a structure handles.InputFile_1207 % handlesInputFile={handles.RootPath_1,handles.SubDir_1,handles.RootFile_1,handles.FileIndex_1,handles.FileExt_1};208 % TagsInputFile={'RootPath','SubDir','RootFile','FileIndex','FileExt'};209 % handles.InputFile_1=cell2struct(handlesInputFile,TagsInputFile,2);210 211 201 % Update handles structure 212 202 guidata(hObject, handles); … … 271 261 %check the path of menu_coord transform 272 262 %set(handles.menu_coord,'String',{'';'phys';'px';'more...'}) 273 path_fct{1}='';274 path_fct{2}=fileparts(path_to_uvmat);275 path_fct{3}=fileparts(path_to_uvmat);276 path_fct{4}=fileparts(path_to_uvmat);277 set(handles.menu_coord,'UserData',path_fct)263 % path_fct{1}=''; 264 % path_fct{2}=fileparts(path_to_uvmat); 265 % path_fct{3}=fileparts(path_to_uvmat); 266 % path_fct{4}=fileparts(path_to_uvmat); 267 % set(handles.menu_coord,'UserData',path_fct) 278 268 279 269 %case of an input argument for uvmat … … 283 273 if exist('input','var') 284 274 if ~isempty(errormsg) 285 warndlg_uvmat(errormsg,'WARNING')275 msgbox_uvmat('WARNING',errormsg) 286 276 end 287 277 if ishandle(handles.UVMAT_title) … … 298 288 sizinput=size(input); 299 289 if sizinput(1)<=1 || sizinput(2)<=1 300 warndlg_uvmat('bad input for uvmat: file name, structure or numerical matrix accepted','ERROR')290 msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted') 301 291 return 302 292 end … … 354 344 end 355 345 end 346 347 %TRANSFORM menu: loads the information stored in prefdir to initiate the browser and the list of functions 348 menu_str={'';'phys';'px';'phys_polar'}; 349 nb_builtin=numel(menu_str); %number of functions 350 [path_uvmat,name,ext]=fileparts(which('uvmat')); 351 addpath(fullfile(path_uvmat,'transform_field')) 352 fct_handle{1,1}=[]; 353 testexist(1)=1; 354 for ilist=2:length(menu_str) 355 if exist(menu_str{ilist},'file') 356 fct_handle{ilist,1}=str2func(menu_str{ilist}); 357 testexist(ilist)=1; 358 else 359 testexist(ilist)=0; 360 end 361 % fct_handle{ilist,1}=fullfile(path_uvmat,'transform_field');%path to the transform functions path_transform; 362 end 363 rmpath(fullfile(path_uvmat,'transform_field')) 364 % read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir 365 dir_perso=prefdir; 366 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 367 if exist(profil_perso,'file') 368 h=load (profil_perso); 369 if isfield(h,'transform_fct') && iscell(h.transform_fct) 370 for ilist=1:length(h.transform_fct) 371 [path,file]=fileparts(h.transform{ilist}); 372 addpath(path) 373 if exist(file,'file') 374 h_func=str2func(path); 375 testexist=[testexist 1]; 376 else 377 h_func=[]; 378 testexist=[testexist 0]; 379 end 380 fct_handle=[fct_handle; {h_func}];%concatene the list of paths 381 rmpath(path) 382 % fct_path=[fct_path; {path}];%concatene the list of paths 383 menu_str=[menu_str; {file}]; 384 end 385 end 386 end 387 menu_str=menu_str(find(testexist)); 388 fct_handle=fct_handle(find(testexist)); 389 menu_str=[menu_str;{'more...'}]; 390 set(handles.menu_coord,'String',menu_str) 391 set(handles.menu_coord,'UserData',fct_handle)% store the list of path in UserData of ACTION 392 356 393 set_vec_col_bar(handles) 357 394 … … 408 445 testblank=findstr(fileinput,' ');%look for blanks 409 446 if ~isempty(testblank) 410 warndlg_uvmat(['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'],'ERROR')447 msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name']) 411 448 return 412 449 end … … 906 943 testblank=findstr(fileinput_1,' ');%look for blanks 907 944 if ~isempty(testblank) 908 warndlg_uvmat(['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'],'ERROR')945 msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name']) 909 946 return 910 947 end … … 1008 1045 % set(handles.FileIndex,'UserData',NomType_1); 1009 1046 otherwise 1010 warndlg_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')1047 msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR') 1011 1048 return 1012 1049 end … … 1015 1052 if nbfield_1 >1 %case of image with multiple frames 1016 1053 if nbfield_1 < num_i1 1017 warndlg_uvmat('current frame index beyond the input movie length','ERROR')1054 msgbox_uvmat('ERROR','current frame index beyond the input movie length') 1018 1055 return 1019 1056 else … … 1037 1074 indices=''; %default 1038 1075 if ~idetect 1039 warndlg_uvmat('second input file with indices corresponding to the first one does not exist','ERROR')1076 msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist') 1040 1077 return 1041 1078 end … … 1195 1232 end 1196 1233 if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit) 1197 warndlg_uvmat('the time units for the second series differs from the first one','WARNING')1234 msgbox_uvmat('WARNING','the time units for the second series differs from the first one') 1198 1235 end 1199 1236 … … 1218 1255 set(handles.last_j,'String',last_j_cell); 1219 1256 if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2}) 1220 warndlg_uvmat('the numbers of input file of the second series differs from the first one','WARNING')1257 msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one') 1221 1258 end 1222 1259 … … 1244 1281 1245 1282 if ~isequal(warntext,'') 1246 warndlg_uvmat(warntext,'WARNING')1283 msgbox_uvmat('WARNING',warntext) 1247 1284 end 1248 1285 … … 1479 1516 end 1480 1517 %px to phys or other transform on field 1481 menu_transform=get(handles.menu_coord,'String');1518 menu_transform=get(handles.menu_coord,'String'); 1482 1519 choice_value=get(handles.menu_coord,'Value'); 1483 transform=menu_transform{choice_value};%name of the transform fct given by the menu 'menu_coord' 1484 if ~isequal(transform,'') && ~isequal(transform,'px') 1520 transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'menu_coord' 1521 transform_list=get(handles.menu_coord,'UserData'); 1522 transform=transform_list{choice_value}; 1523 if ~isequal(transform_name,'') && ~isequal(transform_name,'px') 1485 1524 if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority 1486 1525 Calib=UvData.XmlData.GeometryCalib; 1487 Mask= feval(transform,Mask,UvData.XmlData);1526 Mask=transform(Mask,UvData.XmlData); 1488 1527 end 1489 1528 end … … 1675 1714 UvData=get(huvmat,'UserData'); 1676 1715 else 1677 warndlg_uvmat('an image or movie must be first introduced as input','ERROR')1716 msgbox_uvmat('ERROR','an image or movie must be first introduced as input') 1678 1717 return 1679 1718 end … … 1686 1725 [imaname_1,idetect]=name_generator(filebase,num_i1,num_j2,Ext,NomType); 1687 1726 if idetect==0 1688 warndlg_uvmat(['second input open (-) ' imaname_1 ' not found'],'ERROR');1727 msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); 1689 1728 return 1690 1729 end … … 1694 1733 [imaname_1,idetect]=name_generator(filebase,num_i2,num_j1,Ext,NomType); 1695 1734 if idetect==0 1696 warndlg_uvmat(['second input open (-) ' imaname_1 ' not found'],'ERROR');1735 msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); 1697 1736 return 1698 1737 end 1699 1738 else 1700 warndlg_uvmat('a second image index i2 or j2 is needed to show the pair as a movie','ERROR')1739 msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie') 1701 1740 return 1702 1741 end … … 1704 1743 %read the second image 1705 1744 Field.AName='image'; 1706 % Field.ListDimName={'AY','AX'}; %A FAIRE1707 % Field.DimValue=[];1708 % Field.ListVarName={'A'};1709 1745 Field.AX=UvData.Field.AX; 1710 1746 Field.AY=UvData.Field.AY; … … 1716 1752 menu_transform=get(handles.menu_coord,'String'); 1717 1753 choice_value=get(handles.menu_coord,'Value'); 1718 transform=menu_transform{choice_value};%name of the transform fct given by the menu 'menu_coord' 1719 if ~isequal(transform,'') && ~isequal(transform,'px') 1754 transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'menu_coord' 1755 transform_list=get(handles.menu_coord,'UserData'); 1756 transform=transform_list{choice_value}; 1757 if ~isequal(transform_name,'') && ~isequal(transform_name,'px') 1720 1758 if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority 1721 Field= feval(transform,Field,UvData.XmlData);1759 Field=transform(Field,UvData.XmlData); 1722 1760 end 1723 1761 end … … 1996 2034 [Field{2},var_detect]=nc2struct(filename_1,SubField.ListVarName); %read the corresponding input data 1997 2035 Field{2}.VarAttribute=SubField.VarAttribute; 1998 if isequal(get(hhget_field.menu_coord,'Visible'),'on')1999 list_transform=get(hhget_field.menu_coord,'String');2000 val_list=get(hhget_field.menu_coord,'Value');2001 transf=list_transform{val_list};2002 if ~isempty(transf)2003 Field{2}=feval(transf,Field{2});2004 end2005 end2036 % if isequal(get(hhget_field.menu_coord,'Visible'),'on') 2037 % list_transform=get(hhget_field.menu_coord,'String'); 2038 % val_list=get(hhget_field.menu_coord,'Value'); 2039 % transf=list_transform{val_list}; 2040 % if ~isempty(transf) 2041 % Field{2}=feval(transf,Field{2}); 2042 % end 2043 % end 2006 2044 2007 2045 %update the display on get_field … … 2135 2173 menu_transform=get(handles.menu_coord,'String'); 2136 2174 choice_value=get(handles.menu_coord,'Value'); 2137 transform=menu_transform{choice_value};%name of the transform fct given by the menu 'menu_coord' 2175 %transform=menu_transform{choice_value};%name of the transform fct given by the menu 'menu_coord' 2176 transform_list=get(handles.menu_coord,'UserData') 2177 transform=transform_list{choice_value}%selected function handles 2138 2178 2139 2179 % z index … … 2142 2182 end 2143 2183 %px to phys or other transform on field 2144 if ~ise qual(transform,'')2184 if ~isempty(transform) 2145 2185 if length(Field)>=2 2146 2186 Field{2}.ZIndex=mod(num_i1-1,nbslice)+1; 2147 [Field{1},Field{2}]= feval(transform,Field{1},XmlData,Field{2},XmlData_1);2187 [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1); 2148 2188 if isempty(Field{2}) 2149 2189 Field(2)=[]; 2150 2190 end 2151 2191 else 2152 Field{1}=feval(transform,Field{1},XmlData); 2192 'TESTrun' 2193 Field{1}=transform(Field{1},XmlData); 2194 Field{1} 2153 2195 end 2154 2196 end … … 2612 2654 nc=netcdf(filename,'write'); %open netcdf file 2613 2655 result=redef(nc); 2614 if isempty(result), warndlg_uvmat('##Bad redef operation.','ERROR'),end2656 if isempty(result), msgbox_uvmat('ERROR','##Bad redef operation.'),end 2615 2657 test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); 2616 2658 if ~test_civ2 … … 3708 3750 imflag=flipdim(imflag,1); 3709 3751 % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200) 3710 warndlg_uvmat([mask_name ' saved'],'CONFIRMATION')3752 msgbox_uvmat('CONFIRMATION',[mask_name ' saved']) 3711 3753 imwrite(imflag,mask_name,'BitDepth',8); 3712 3754 … … 3968 4010 ind_coord=get(handles.menu_coord,'Value'); 3969 4011 coord_option=menu{ind_coord}; 3970 list_ path=get(handles.menu_coord,'UserData');4012 list_transform=get(handles.menu_coord,'UserData'); 3971 4013 3972 4014 if isequal(coord_option,'more...'); … … 3995 4037 msgbox_uvmat('ERROR',['image procesing fct ' coord_fct ' not found']) 3996 4038 else 3997 transform=FileName(1:end-2);%4039 [ppp,transform]=fileparts(FileName);% removes extension .m 3998 4040 menu=update_menu(handles.menu_coord,transform);%add the selected fct to the menu 3999 4041 ind_coord=get(handles.menu_coord,'Value'); 4000 list_path{ind_coord}=PathName; 4001 set(handles.menu_coord,'UserData',list_path) 4042 addpath(PathName) 4043 list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function 4044 set(handles.menu_coord,'UserData',list_transform) 4045 rmpath(PathName) 4002 4046 if exist(profil_perso,'file') 4003 4047 save (profil_perso,'coord_fct','-append'); %store the root name for future opening of uvmat … … 4007 4051 4008 4052 %check the current path to the selected function 4009 PathName=list_path{ind_coord}; 4010 CurrentPath=fileparts(which(coord_option)); 4011 if ~isequal(PathName,CurrentPath)&&~isequal(CurrentPath,fullfile(PathName,'private')) 4012 addpath(PathName) 4013 errormsg=check_functions; 4014 msgbox_uvmat('WARNING',[['path ' PathName ' added to the current Matlab pathes'];errormsg]) 4015 end 4016 set(handles.path_transform,'String',fullfile(PathName,' ')); %show the path to the senlected function 4053 func=functions(list_transform{ind_coord}) 4054 set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function 4055 %CurrentPath=fileparts(which(coord_option)); 4056 % if ~isequal(PathName,CurrentPath) 4057 % addpath(PathName) 4058 % errormsg=check_functions; 4059 % msgbox_uvmat('WARNING',[['path ' PathName ' added to the current Matlab pathes'];errormsg]) 4060 % end 4061 %set(handles.path_transform,'String',fullfile(PathName,' ')); %show the path to the senlected function 4017 4062 set(handles.FixedLimits,'Value',0) 4018 4063 set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
Note: See TracChangeset
for help on using the changeset viewer.