Changeset 38 for trunk/src/uvmat.m


Ignore:
Timestamp:
Mar 7, 2010, 6:30:11 PM (14 years ago)
Author:
sommeria
Message:

field transforms put in subdir transform_field. cleaning of obsolete functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r36 r38  
    1212%
    1313%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.
    1515%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    1616%     This open is part of the toolbox UVMAT.
     
    199199handles.output = hObject;
    200200
    201 % %group handles for input file in a structure handles.InputFile
    202 % 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_1
    207 % 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 
    211201% Update handles structure
    212202guidata(hObject, handles);
     
    271261%check the path of menu_coord transform
    272262%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)
    278268
    279269%case of an input argument for uvmat
     
    283273if exist('input','var')
    284274    if ~isempty(errormsg)
    285         warndlg_uvmat(errormsg,'WARNING')
     275        msgbox_uvmat('WARNING',errormsg)
    286276    end
    287277    if ishandle(handles.UVMAT_title)
     
    298288        sizinput=size(input);
    299289        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')
    301291            return
    302292        end
     
    354344    end
    355345end
     346
     347%TRANSFORM menu: loads the information stored in prefdir to initiate the browser and the list of functions
     348menu_str={'';'phys';'px';'phys_polar'};
     349nb_builtin=numel(menu_str); %number of functions
     350[path_uvmat,name,ext]=fileparts(which('uvmat'));
     351addpath(fullfile(path_uvmat,'transform_field'))
     352fct_handle{1,1}=[];
     353testexist(1)=1;
     354for 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;
     362end
     363rmpath(fullfile(path_uvmat,'transform_field'))
     364% read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir
     365dir_perso=prefdir;
     366profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     367if 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
     386end
     387menu_str=menu_str(find(testexist));
     388fct_handle=fct_handle(find(testexist));
     389menu_str=[menu_str;{'more...'}];
     390set(handles.menu_coord,'String',menu_str)
     391set(handles.menu_coord,'UserData',fct_handle)% store the list of path in UserData of ACTION
     392
    356393set_vec_col_bar(handles)
    357394
     
    408445testblank=findstr(fileinput,' ');%look for blanks
    409446if ~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'])
    411448    return
    412449end
     
    906943testblank=findstr(fileinput_1,' ');%look for blanks
    907944if ~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'])
    909946    return
    910947end
     
    10081045%         set(handles.FileIndex,'UserData',NomType_1);
    10091046    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')
    10111048        return
    10121049end
     
    10151052if nbfield_1 >1 %case of image with multiple frames
    10161053    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')
    10181055        return
    10191056    else
     
    10371074        indices=''; %default
    10381075        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')
    10401077            return
    10411078        end
     
    11951232end   
    11961233if ~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')
    11981235end
    11991236       
     
    12181255set(handles.last_j,'String',last_j_cell);
    12191256if ~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')
    12211258end
    12221259
     
    12441281
    12451282if ~isequal(warntext,'')
    1246     warndlg_uvmat(warntext,'WARNING')
     1283    msgbox_uvmat('WARNING',warntext)
    12471284end
    12481285
     
    14791516        end
    14801517        %px to phys or other transform on field
    1481         menu_transform=get(handles.menu_coord,'String');
     1518         menu_transform=get(handles.menu_coord,'String');
    14821519        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')
    14851524            if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
    14861525                Calib=UvData.XmlData.GeometryCalib;
    1487                 Mask=feval(transform,Mask,UvData.XmlData);
     1526                Mask=transform(Mask,UvData.XmlData);
    14881527            end
    14891528        end
     
    16751714    UvData=get(huvmat,'UserData');
    16761715else
    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')
    16781717    return
    16791718end
     
    16861725    [imaname_1,idetect]=name_generator(filebase,num_i1,num_j2,Ext,NomType);
    16871726    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']);
    16891728        return
    16901729    end
     
    16941733    [imaname_1,idetect]=name_generator(filebase,num_i2,num_j1,Ext,NomType);
    16951734    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']);
    16971736        return
    16981737    end
    16991738else   
    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')
    17011740    return
    17021741end
     
    17041743%read the second image
    17051744Field.AName='image';
    1706 % Field.ListDimName={'AY','AX'}; %A FAIRE
    1707 % Field.DimValue=[];
    1708 % Field.ListVarName={'A'};
    17091745Field.AX=UvData.Field.AX;
    17101746Field.AY=UvData.Field.AY;
     
    17161752menu_transform=get(handles.menu_coord,'String');
    17171753choice_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')
     1754transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'menu_coord'
     1755transform_list=get(handles.menu_coord,'UserData');
     1756transform=transform_list{choice_value};
     1757if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
    17201758    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);
    17221760    end
    17231761end
     
    19962034            [Field{2},var_detect]=nc2struct(filename_1,SubField.ListVarName); %read the corresponding input data               
    19972035            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                 end
    2005             end
     2036%             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
    20062044
    20072045            %update the display on get_field
     
    21352173menu_transform=get(handles.menu_coord,'String');
    21362174choice_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'
     2176transform_list=get(handles.menu_coord,'UserData')
     2177transform=transform_list{choice_value}%selected function handles
    21382178
    21392179% z index
     
    21422182end
    21432183%px to phys or other transform on field
    2144 if  ~isequal(transform,'')
     2184if  ~isempty(transform)
    21452185    if length(Field)>=2
    21462186        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);
    21482188        if isempty(Field{2})
    21492189            Field(2)=[];
    21502190        end
    21512191    else
    2152         Field{1}=feval(transform,Field{1},XmlData);
     2192        'TESTrun'
     2193        Field{1}=transform(Field{1},XmlData);
     2194         Field{1}
    21532195    end
    21542196end
     
    26122654nc=netcdf(filename,'write'); %open netcdf file
    26132655result=redef(nc);
    2614 if isempty(result), warndlg_uvmat('##Bad redef operation.','ERROR'),end
     2656if isempty(result), msgbox_uvmat('ERROR','##Bad redef operation.'),end
    26152657test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
    26162658if ~test_civ2
     
    37083750imflag=flipdim(imflag,1);
    37093751% imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
    3710 warndlg_uvmat([mask_name ' saved'],'CONFIRMATION')
     3752msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
    37113753imwrite(imflag,mask_name,'BitDepth',8);
    37123754
     
    39684010ind_coord=get(handles.menu_coord,'Value');
    39694011coord_option=menu{ind_coord};
    3970 list_path=get(handles.menu_coord,'UserData');
     4012list_transform=get(handles.menu_coord,'UserData');
    39714013   
    39724014if isequal(coord_option,'more...');
     
    39954037           msgbox_uvmat('ERROR',['image procesing fct ' coord_fct ' not found'])
    39964038    else
    3997        transform=FileName(1:end-2);%
     4039       [ppp,transform]=fileparts(FileName);% removes extension .m
    39984040       menu=update_menu(handles.menu_coord,transform);%add the selected fct to the menu
    39994041       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)
    40024046       if exist(profil_perso,'file')
    40034047            save (profil_perso,'coord_fct','-append'); %store the root name for future opening of uvmat
     
    40074051
    40084052%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
     4053func=functions(list_transform{ind_coord})
     4054set(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
    40174062set(handles.FixedLimits,'Value',0)
    40184063set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
Note: See TracChangeset for help on using the changeset viewer.