Changeset 39


Ignore:
Timestamp:
Mar 9, 2010, 5:46:24 PM (11 years ago)
Author:
sommeria
Message:

civ: bug corrected for civ in batch
series and uvmat: further improvement and debugging for the menu of field transforms

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r36 r39  
    9191end
    9292
    93 if exist('ext','var') && length(ext)>1 && (~isempty(imformats(ext([2:end])))|...
    94                        isequal(ext,'.avi')||isequal(ext,'.AVI'));%if an image file has been opened by uvmat
     93if exist('ext','var') && length(ext)>1 && (~isempty(imformats(ext(2:end)))||...
     94                       isequal(lower(ext),'.avi'));%if an image file has been opened by uvmat
    9595        set(handles.ext_ima,'String',ext)
    9696        if exist('nom_type_read','var')
     
    259259filebase=get(handles.displ_filebase,'String');
    260260oldfile=''; %default
    261 if isempty(filebase)|isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box
     261if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box
    262262     dir_perso=prefdir;
    263263     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     
    448448field_count=1;%default
    449449nom_type_nc=[];
    450 npx=[];%default
    451 npy=[];
     450% npx=[];%default
     451% npy=[];
    452452time=[];
    453453TimeUnit=[]; %default
     
    478478end
    479479first_j=str2num(get(handles.first_j,'String'));
    480 if isempty(first_j)| first_j < 1
     480if isempty(first_j)|| first_j < 1
    481481    first_j=1; %default first_j
    482482end
    483483last_j=str2num(get(handles.last_j,'String'));
    484 if isempty(last_j)| last_j < first_j
     484if isempty(last_j)|| last_j < first_j
    485485    last_j=first_j; %default last_j
    486486end
    487487incr_i=str2num(get(handles.incr_i,'String'));
    488 if isempty(incr_i) | incr_i < 1;
     488if isempty(incr_i) || incr_i < 1;
    489489    set(handles.incr_i,'String','1') %default incr_i
    490490end
    491491incr_j=str2num(get(handles.incr_j,'String'));
    492 if isempty(incr_j) | incr_j < 1;
     492if isempty(incr_j) || incr_j < 1;
    493493    set(handles.incr_j,'String','1') %default incr_j
    494494end
     
    554554    if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
    555555        [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
    556         fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName) %full name (including path) of the first image defined by the xmle file,
     556        fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file,
    557557        if exist(fullname,'file')
    558558            testima_xml=1;
     
    13181318last_i=str2num(get(handles.last_i,'String'));%last index i
    13191319incr=str2num(get(handles.incr_i,'String'));% increment
    1320 num1=[first_i:incr:last_i];% list of i indices (reference values for each pair)
     1320num_i=[first_i:incr:last_i];% list of i indices (reference values for each pair)
    13211321if isequal(get(handles.first_j,'Visible'),'on')
    13221322    first_j=str2num(get(handles.first_j,'String'));%first index j
     
    13311331list_civ1=get(handles.list_pair_civ1,'String');
    13321332index_civ1=get(handles.list_pair_civ1,'Value');
     1333[num_i,num_j]=meshgrid(num_i,num_j);
    13331334str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1
    13341335if isempty(str_civ1)||isequal(str_civ1,'')
     
    13451346if isempty(first_i)||isempty(first_j), msgbox_uvmat('ERROR','first field number not defined'),...
    13461347    return,end;
    1347 if isequal(last_i,[])| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),...
     1348if isequal(last_i,[])|| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),...
    13481349    return,end;
    1349 if isequal(incr,[])| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),...
     1350if isequal(incr,[])|| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),...
    13501351    return,end;
    1351 if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
     1352if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
    13521353    return,end;
    13531354if isequal (mode,'series(Di)')
     
    13621363        d2=str2num(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1]));
    13631364    end   
    1364     num1_civ1=num1-d1;% set of first image numbers
    1365     num2_civ1=num1+d2;
     1365    num1_civ1=num_i-d1;% set of first image numbers
     1366    num2_civ1=num_i+d2;
    13661367    num_a_civ1=num_j;
    13671368    num_b_civ1=num_j;
     
    13781379    end   
    13791380    if isempty(d1)
    1380         num1_civ2=num1;
     1381        num1_civ2=num_i;
    13811382    else
    1382         num1_civ2=num1-d1;% set of first image numbers
     1383        num1_civ2=num_i-d1;% set of first image numbers
    13831384    end
    13841385    if isempty(d2)
    1385         num2_civ2=num1;
     1386        num2_civ2=num_i;
    13861387    else
    1387         num2_civ2=num1+d2;
     1388        num2_civ2=num_i+d2;
    13881389    end
    13891390    num_a_civ2=num_j;
     
    14001401        firstind=indsel(1);
    14011402        lastind=indsel(end);
    1402         set(handles.first_i,'String',num2str(num1(firstind)))%update the display of first and last fields
    1403         set(handles.last_i,'String',num2str(num1(lastind)))
    1404         num1=num1(indsel);
     1403        set(handles.first_i,'String',num2str(num_i(firstind)))%update the display of first and last fields
     1404        set(handles.last_i,'String',num2str(num_i(lastind)))
     1405        num_i=num_i(indsel);
    14051406        num1_civ1=num1_civ1(indsel);
    14061407        num1_civ2=num1_civ2(indsel);
     
    14101411elseif isequal (mode,'series(Dj)')
    14111412    lastfield_j=str2num(get(handles.nb_field2,'String'));
    1412     num1_civ1=num1;% set of first image numbers
    1413     num2_civ1=num1;
     1413    num1_civ1=num_i;% set of first image numbers
     1414    num2_civ1=num_i;
    14141415    num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j));
    14151416    num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j));
    1416     num1_civ2=num1;
    1417     num2_civ2=num1;
     1417    num1_civ2=num_i;
     1418    num2_civ2=num_i;
    14181419    num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j));
    14191420    num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j));
     
    14361437    end
    14371438elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D)
    1438     num1_civ1=num1;
    1439     num1_civ2=num1;
     1439    num1_civ1=num_i;
     1440    num1_civ2=num_i;
    14401441    displ_num=get(handles.list_pair_civ1,'UserData');
    1441     num2_civ1=num1;
     1442    num2_civ1=num_i;
    14421443    num_a_civ1=displ_num(1,index_civ1);
    14431444    num_b_civ1=displ_num(2,index_civ1);
    1444     num2_civ2=num1;
     1445    num2_civ2=num_i;
    14451446    num_a_civ2=displ_num(1,index_civ2);
    14461447    num_b_civ2=displ_num(2,index_civ2);
    14471448elseif isequal(mode,'displacement')
    1448     num1_civ1=num1;
    1449     num2_civ1=num1;
     1449    num1_civ1=num_i;
     1450    num2_civ1=num_i;
    14501451    num_a_civ1=num_j;
    14511452    num_b_civ1=num_j;
    1452     num1_civ2=num1;
    1453     num2_civ2=num1;
     1453    num1_civ2=num_i;
     1454    num2_civ2=num_i;
    14541455    num_a_civ2=num_j;
    14551456    num_b_civ2=num_j;
    14561457end
    1457 'TESTfind'
    1458 num1_civ1
    1459 num2_civ1
    1460 num_a_civ1
    1461 num_b_civ1
    14621458
    14631459%------------------------------------------------------------------------
     
    16641660[filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
    16651661       set_civ_filenames(handles,compare,box_test);
    1666    'TESTnbre_RUN'
    1667 nbfield=size(num1_civ1,2)
    1668 nbslice=size(num1_civ1,1)
     1662nbfield=size(num1_civ1,2);
     1663nbslice=size(num1_civ1,1);
    16691664
    16701665if isempty(filecell)
     
    21852180       set_civ_filenames(handles,compare,box_test);
    21862181display('files OK, processing...') 
    2187 'TESTnbre'
    2188 nbfield=size(num1_civ1,2)
    2189 nbslice=size(num1_civ1,1)
     2182nbfield=size(num1_civ1,2);
     2183nbslice=size(num1_civ1,1);
    21902184
    21912185%GET PARAMETERS:
     
    26782672            cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]});
    26792673        end
    2680 
    26812674      % create the .bat file:
    26822675        if sge
     
    26882681        filename_bat(end-2:end)='bat';
    26892682        fid=fopen(filename_bat,'w');
    2690         fprintf(fid,cmd)
    2691         fclose(fid)
     2683        fprintf(fid,cmd);
     2684        fclose(fid);
    26922685        %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat
    26932686        if sge
     
    27722765[num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
    27732766    find_pair_indices(handles,mode);
    2774 
    27752767%determine the new filebase for 'displacement' mode (comparison of two series)
    27762768filebase_B=filebase;% root name of the second field series for stereo
     
    34583450        term_b=num2stra(num_b(j),nom_type_nc);%
    34593451        if test_grid && ~isempty(nbslice_grid)       
    3460              num1_grid=mod(num1(ifile)-1,nbslice_grid)+1
     3452             num1_grid=mod(num1(ifile)-1,nbslice_grid)+1;
    34613453            gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
    34623454            if ~exist(gridname,'file')
     
    36523644        filename_nc1([end-2:end])=[]; % remove '.nc'     
    36533645        if test_grid && ~isempty(nbslice_grid)       
    3654             num1_grid=mod(num1(ifile)-1,nbslice_grid)+1
     3646            num1_grid=mod(num1(ifile)-1,nbslice_grid)+1;
    36553647            gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
    36563648            if ~exist(gridname,'file')
     
    42144206if value
    42154207        filebase=get(handles.displ_filebase,'String');
    4216     [nbslice, flag_grid]=get_grid(filebase,handles)
     4208    [nbslice, flag_grid]=get_grid(filebase,handles);
    42174209    if isequal(flag_grid,1)
    42184210       filegrid=[num2str(nbslice) 'grid'];
     
    42644256if value
    42654257        filebase=get(handles.displ_filebase,'String');
    4266     [nbslice, flag_grid]=get_grid(filebase,handles)
     4258    [nbslice, flag_grid]=get_grid(filebase,handles);
    42674259    if isequal(flag_grid,1)
    42684260        mask_displ=[num2str(nbslice) 'grid'];
  • trunk/src/series.m

    r38 r39  
    66%INPUT
    77% param: structure with input parameters (link with the GUI uvmat)
    8 %      .menu_coord_str: string for the CoordType (menu for coordinate transforms)
    9 %      .menu_coord_val: value for CoordType (menu for coordinate transforms)
     8%      .menu_coord_str: string for the transform_fct (menu for coordinate transforms)
     9%      .menu_coord_val: value for transform_fct (menu for coordinate transforms)
    1010%      .FileName: input file name
    1111%      .FileName_1: second input file name
     
    9696%file name and browser initialisation
    9797if isfield(param,'menu_coord_str')
    98     set(handles.CoordType,'String',param.menu_coord_str)
     98    set(handles.transform_fct,'String',param.menu_coord_str)
    9999end
    100100if isfield(param,'menu_coord_val')
    101     set(handles.CoordType,'Value',param.menu_coord_val);
    102 else
    103      set(handles.CoordType,'Value',1);%default
     101    set(handles.transform_fct,'Value',param.menu_coord_val);
     102else
     103     set(handles.transform_fct,'Value',1);%default
    104104end
    105105
     
    132132NomType_Callback(hObject, eventdata, handles)
    133133
    134 %loads the information stored in prefdir to initiate the browser and the list of functions
     134%loads the information stored in prefdir to initiate  the list of ACTION functions
    135135fct_menu={'check_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'};
    136136transform_menu={'';'phys';'px';'phys_polar'};
     
    139139[path_series,name,ext]=fileparts(which('series'));
    140140path_series=fullfile(path_series,'series');%path of the function 'series'
    141 path_transform=fullfile(path_series,'transform_field');%path of the function 'series'
     141path_transform=fullfile(path_series,'transform_field');%path of the field transform functions
    142142for ilist=1:length(fct_menu)
    143143    fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m'
    144144end
    145 for ilist=1:length(transform_menu)
    146     transform_path{ilist,1}=path_transform;
    147 end
     145
     146%TRANSFORM menu: loads the information stored in prefdir to initiate  the list of field transform functions
     147menu_str={'';'phys';'px';'phys_polar'};
     148nb_builtin=numel(menu_str); %number of functions
     149[path_uvmat,name,ext]=fileparts(which('uvmat'));
     150addpath(fullfile(path_uvmat,'transform_field'))
     151fct_handle{1,1}=[];
     152testexist(1)=1;
     153for ilist=2:length(menu_str)
     154    if exist(menu_str{ilist},'file')
     155        fct_handle{ilist,1}=str2func(menu_str{ilist});
     156        testexist(ilist)=1;
     157    else
     158        testexist(ilist)=0;
     159    end
     160end
     161rmpath(fullfile(path_uvmat,'transform_field'))
     162
    148163% read the list of functions stored in the personal file 'uvmat_perso.mat' in prefdir
    149164dir_perso=prefdir;
     
    159174    end
    160175    if isfield(h,'transform_fct') && iscell(h.transform_fct)
    161          for ilist=1:length(h.transform_fct)
     176        for ilist=1:length(h.transform_fct);
    162177             [path,file]=fileparts(h.transform_fct{ilist});
    163              transform_path=[transform_path; {path}];%concatene the list of paths
    164              transform_menu=[transform_menu;{file}];
    165          end
     178             addpath(path)
     179             if exist(file,'file')
     180                h_func=str2func(file);
     181                testexist=[testexist 1];
     182             else
     183                h_func=[];
     184                testexist=[testexist 0];
     185             end
     186             fct_handle=[fct_handle; {h_func}];%concatene the list of paths
     187             rmpath(path)
     188             menu_str=[menu_str; {file}];
     189        end
    166190    end
    167191end
     
    169193set(handles.ACTION,'String',fct_menu)
    170194set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION
    171 transform_menu=[transform_menu;{'more...'}];
    172 set(handles.CoordType,'String',transform_menu)
    173 set(handles.CoordType,'UserData',transform_path)% store the list of path in UserData of ACTION
     195
     196menu_str=menu_str(find(testexist));
     197fct_handle=fct_handle(find(testexist));
     198menu_str=[menu_str;{'more...'}];
     199set(handles.transform_fct,'String',menu_str)
     200set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
    174201
    175202% display the GUI for the default action 'check_files'
     
    544571testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on');
    545572testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on');
    546 testtransform=isequal(get(handles.CoordType,'Enable'),'on');
     573testtransform=isequal(get(handles.transform_fct,'Enable'),'on');
    547574testnc=0;
    548575testnc_1=0;
     
    962989function view_TRANSFORM(handles,state)
    963990set(handles.TRANSFORM_frame,'Visible',state)
    964 set(handles.CoordType,'Visible',state);
     991set(handles.transform_fct,'Visible',state);
    965992set(handles.TRANSFORM_title,'Visible',state)
    966993
     
    13281355    Series.Field=FieldMenu(FieldValue);
    13291356end
    1330 menu_coord_state=get(handles.CoordType,'Visible');
     1357menu_coord_state=get(handles.transform_fct,'Visible');
    13311358Series.CoordType='';%default
    13321359if isequal(menu_coord_state,'on')
    1333     menu_coord=get(handles.CoordType,'String');
    1334     menu_index=get(handles.CoordType,'Value');
     1360    menu_coord=get(handles.transform_fct,'String');
     1361    menu_index=get(handles.transform_fct,'Value');
    13351362    Series.CoordType=menu_coord{menu_index};
    13361363end
     
    15931620path_series=which('series');%path to series.m
    15941621list_path=get(handles.ACTION,'UserData');%list of recorded paths to functions of the list ACTION
    1595 
     1622default_file=fullfile(list_path{end},ACTION);
    15961623% add a new function to the menu if the selected item is 'more...'
    15971624if isequal(ACTION,'more...')
    15981625    pathfct=fileparts(path_series);
    1599 %     browse_name=fullfile(path_series,'series');%go to UVMAT/series by default
    1600 %     if length(list_path)>nb_builtin
    1601 %         browse_name=list_path{end};% initialize browser with  the path of the last introduced function
    1602 %      end
    16031626    [FileName, PathName, filterindex] = uigetfile( ...
    16041627       {'*.m', ' (*.m)';
    16051628        '*.m',  '.m files '; ...
    16061629        '*.*', 'All Files (*.*)'}, ...
    1607         'Pick a file',list_path{end});
     1630        'Pick a file',default_file);
    16081631    if length(FileName)<2
    16091632        return
     
    16851708set(handles.FieldMenu_1,'Enable','off')
    16861709set(handles.VelTypeMenu_1,'Enable','off')
    1687 set(handles.CoordType,'Enable','off')
     1710set(handles.transform_fct,'Enable','off')
    16881711%set the displayed GUI item needed for input parameters
    16891712%list_input=feval(ACTION);% input list asked by the selected function
     
    17891812        case 'CoordType'   %hidden by default
    17901813            if isequal(lower(varargout{ilist+1}),'on')
    1791                 set(handles.CoordType,'Enable','on')
     1814                set(handles.transform_fct,'Enable','on')
    17921815                view_TRANSFORM(handles,'on')
    17931816            end
     
    21102133    else
    21112134        siz=size(times);
    2112         if siz(1)>=last_i & siz(2)>=last_j
     2135        if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1
    21132136            time_first=times(first_i,first_j);
    21142137            time_last=times(last_i,last_j);
     
    21882211
    21892212
    2190 
    2191 
    2192 
    2193 
     2213% --- Executes on selection change in transform_fct.
     2214function transform_fct_Callback(hObject, eventdata, handles)
     2215
     2216global nb_transform
     2217
     2218% huvmat=get(handles.transform_fct,'parent');
     2219menu=get(handles.transform_fct,'String');
     2220ind_coord=get(handles.transform_fct,'Value');
     2221coord_option=menu{ind_coord};
     2222list_transform=get(handles.transform_fct,'UserData')
     2223ff=functions(list_transform{end});
     2224if isequal(coord_option,'more...');
     2225    coord_fct='';
     2226    prompt = {'Enter the name of the transform function'};
     2227    dlg_title = 'user defined transform';
     2228    num_lines= 1;
     2229    [FileName, PathName, filterindex] = uigetfile( ...
     2230       {'*.m', ' (*.m)';
     2231        '*.m',  '.m files '; ...
     2232        '*.*', 'All Files (*.*)'}, ...
     2233        'Pick a file', ff.file);
     2234    if isequal(PathName(end),'/')||isequal(PathName(end),'\')
     2235        PathName(end)=[];
     2236    end
     2237    transform_selected =fullfile(PathName,FileName);
     2238    if ~exist(transform_selected,'file')
     2239          return
     2240    end
     2241    [ppp,transform,xt_fct]=fileparts(FileName);% removes extension .m
     2242    if ~isequal(ext_fct,'.m')
     2243        msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
     2244        return
     2245    end
     2246   menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
     2247   ind_coord=get(handles.transform_fct,'Value');
     2248   addpath(PathName)
     2249   list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
     2250   set(handles.transform_fct,'UserData',list_transform)
     2251   rmpath(PathName)
     2252   % save the new menu in the personal file 'uvmat_perso.mat'
     2253   dir_perso=prefdir;%personal Matalb directory
     2254   profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     2255   if exist(profil_perso,'file')
     2256       for ilist=nb_transform+1:numel(list_transform)
     2257           ff=functions(list_transform{ilist})
     2258           transform_fct{ilist-nb_transform}=ff.file;
     2259       end
     2260        save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
     2261   end
     2262end
     2263
     2264%check the current path to the selected function
     2265func=functions(list_transform{ind_coord});
     2266set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
     2267
     2268
     2269
     2270function path_transform_Callback(hObject, eventdata, handles)
     2271% hObject    handle to path_transform (see GCBO)
     2272% eventdata  reserved - to be defined in a future version of MATLAB
     2273% handles    structure with handles and user data (see GUIDATA)
     2274
     2275% Hints: get(hObject,'String') returns contents of path_transform as text
     2276%        str2double(get(hObject,'String')) returns contents of path_transform as a double
     2277
     2278
     2279% --- Executes during object creation, after setting all properties.
     2280function path_transform_CreateFcn(hObject, eventdata, handles)
     2281% hObject    handle to path_transform (see GCBO)
     2282% eventdata  reserved - to be defined in a future version of MATLAB
     2283% handles    empty - handles not created until after all CreateFcns called
     2284
     2285% Hint: edit controls usually have a white background on Windows.
     2286%       See ISPC and COMPUTER.
     2287if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
     2288    set(hObject,'BackgroundColor','white');
     2289end
     2290
     2291
  • trunk/src/uvmat.m

    r38 r39  
    195195%-------------------------------------------------------------------
    196196%WARNING: avoid the second input parameter, leads to erros
    197 global dircur dir_opening
     197global dircur dir_opening nb_builtin
    198198% Choose default command menuline output for uvmat
    199199handles.output = hObject;
     
    221221set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
    222222set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
    223 %set(hObject,'ResizeFcn',{@resize_uvmat})
     223
     224%TRANSFORM menu: loads the information stored in prefdir to initiate the browser and the list of functions
     225menu_str={'';'phys';'px';'phys_polar'};
     226nb_builtin=numel(menu_str); %number of functions
     227[path_uvmat,name,ext]=fileparts(which('uvmat'));
     228addpath(fullfile(path_uvmat,'transform_field'))
     229fct_handle{1,1}=[];
     230testexist(1)=1;
     231for ilist=2:length(menu_str)
     232    if exist(menu_str{ilist},'file')
     233        fct_handle{ilist,1}=str2func(menu_str{ilist});
     234        testexist(ilist)=1;
     235    else
     236        testexist(ilist)=0;
     237    end
     238%     fct_handle{ilist,1}=fullfile(path_uvmat,'transform_field');%path to  the transform functions path_transform;
     239end
     240rmpath(fullfile(path_uvmat,'transform_field'))
    224241
    225242%load the list of previously browsed files in menus Open and Open_1
     
    247264          set(handles.MenuFile_5,'Label',h.MenuFile_5);
    248265          set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
    249      end
     266      end
     267      if isfield(h,'transform_fct') && iscell(h.transform_fct)
     268         for ilist=1:length(h.transform_fct);
     269             [path,file]=fileparts(h.transform_fct{ilist});
     270             addpath(path)
     271             if exist(file,'file')
     272                h_func=str2func(file);
     273                testexist=[testexist 1];
     274             else
     275                h_func=[];
     276                testexist=[testexist 0];
     277             end
     278             fct_handle=[fct_handle; {h_func}];%concatene the list of paths
     279             rmpath(path)
     280             menu_str=[menu_str; {file}];
     281         end
     282      end
    250283 end
     284menu_str=menu_str(find(testexist));
     285fct_handle=fct_handle(find(testexist));
     286menu_str=[menu_str;{'more...'}];
     287set(handles.transform_fct,'String',menu_str)
     288set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
    251289 
    252290%initiates menu of vector colors
     
    259297[errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
    260298
    261 %check the path of menu_coord transform
    262 %set(handles.menu_coord,'String',{'';'phys';'px';'more...'})
     299%check the path of transform_fct transform
     300%set(handles.transform_fct,'String',{'';'phys';'px';'more...'})
    263301% path_fct{1}='';
    264302% path_fct{2}=fileparts(path_to_uvmat);
    265303% path_fct{3}=fileparts(path_to_uvmat);
    266304% path_fct{4}=fileparts(path_to_uvmat);
    267 % set(handles.menu_coord,'UserData',path_fct)
     305% set(handles.transform_fct,'UserData',path_fct)
    268306
    269307%case of an input argument for uvmat
     
    303341    if ~isempty(Field)
    304342        set(handles.Fields,'Value',1)
    305         set(handles.Fields,'String',{'get_field...'})
    306 %         set(handles.Fields,'Value',2)% option 'get_field...'     
     343        set(handles.Fields,'String',{'get_field...'})   
    307344        set(handles.Fields,'UserData',Field)
    308345        testinputfield=1;
     
    344381    end
    345382end
    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
    392383
    393384set_vec_col_bar(handles)
     
    790781        set(handles.pxcm,'String','')
    791782        set(handles.pycm,'String','')
    792         set(handles.menu_coord,'Value',1); %  no transform by default
     783        set(handles.transform_fct,'Value',1); %  no transform by default
    793784    else
    794785        if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
     
    802793            set(handles.pycm,'String',num2str(pixcmy))
    803794        end
    804         set(handles.menu_coord,'Value',2); % phys transform by default
     795        set(handles.transform_fct,'Value',2); % phys transform by default
    805796        if isfield(GeometryCalib,'SliceCoord')
    806797           siz=size(GeometryCalib.SliceCoord);
     
    15161507        end
    15171508        %px to phys or other transform on field
    1518          menu_transform=get(handles.menu_coord,'String');
    1519         choice_value=get(handles.menu_coord,'Value');
    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');
     1509         menu_transform=get(handles.transform_fct,'String');
     1510        choice_value=get(handles.transform_fct,'Value');
     1511        transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
     1512        transform_list=get(handles.transform_fct,'UserData');
    15221513        transform=transform_list{choice_value};
    15231514        if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
     
    17501741
    17511742%px to phys or other transform on field
    1752 menu_transform=get(handles.menu_coord,'String');
    1753 choice_value=get(handles.menu_coord,'Value');
    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');
     1743menu_transform=get(handles.transform_fct,'String');
     1744choice_value=get(handles.transform_fct,'Value');
     1745transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
     1746transform_list=get(handles.transform_fct,'UserData');
    17561747transform=transform_list{choice_value};
    17571748if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
     
    20342025            [Field{2},var_detect]=nc2struct(filename_1,SubField.ListVarName); %read the corresponding input data               
    20352026            Field{2}.VarAttribute=SubField.VarAttribute;
    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');
     2027%             if isequal(get(hhget_field.transform_fct,'Visible'),'on')
     2028%                 list_transform=get(hhget_field.transform_fct,'String');
     2029%                 val_list=get(hhget_field.transform_fct,'Value');
    20392030%                 transf=list_transform{val_list};
    20402031%                 if ~isempty(transf)
     
    21712162   XmlData_1=UvData.XmlData_1;
    21722163end
    2173 menu_transform=get(handles.menu_coord,'String');
    2174 choice_value=get(handles.menu_coord,'Value');
    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
     2164menu_transform=get(handles.transform_fct,'String');
     2165choice_value=get(handles.transform_fct,'Value');
     2166%transform=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
     2167transform_list=get(handles.transform_fct,'UserData');
     2168transform=transform_list{choice_value};%selected function handles
    21782169
    21792170% z index
     
    21902181        end
    21912182    else
    2192         'TESTrun'
    21932183        Field{1}=transform(Field{1},XmlData);
    2194          Field{1}
    21952184    end
    21962185end
     
    40033992
    40043993%-------------------------------------------------------------
    4005 % --- Executes on selection change in menu_coord.
    4006 function menu_coord_Callback(hObject, eventdata, handles)
     3994% --- Executes on selection change in transform_fct.
     3995function transform_fct_Callback(hObject, eventdata, handles)
    40073996%-------------------------------------------------------------
    4008 huvmat=get(handles.menu_coord,'parent');
    4009 menu=get(handles.menu_coord,'String');
    4010 ind_coord=get(handles.menu_coord,'Value');
     3997global nb_builtin
     3998
     3999huvmat=get(handles.transform_fct,'parent');
     4000menu=get(handles.transform_fct,'String');
     4001ind_coord=get(handles.transform_fct,'Value');
    40114002coord_option=menu{ind_coord};
    4012 list_transform=get(handles.menu_coord,'UserData');
    4013    
     4003list_transform=get(handles.transform_fct,'UserData');
     4004ff=functions(list_transform{end}) 
    40144005if isequal(coord_option,'more...');
    40154006    coord_fct='';
    4016     dir_perso=prefdir;
    4017     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    4018     if exist(profil_perso,'file')
    4019           h=load (profil_perso);
    4020          if isfield(h,'coord_fct')
    4021                 coord_fct=h.coord_fct;
    4022          end
    4023     end
     4007
     4008%     if exist(profil_perso,'file')
     4009%           h=load (profil_perso);
     4010%          if isfield(h,'transform_fct')
     4011%                 transform_fct=h.transform_fct;
     4012%          end
     4013%     end
    40244014    prompt = {'Enter the name of the transform function'};
    40254015    dlg_title = 'user defined transform';
     
    40294019        '*.m',  '.m files '; ...
    40304020        '*.*', 'All Files (*.*)'}, ...
    4031         'Pick a file', coord_fct);
     4021        'Pick a file', ff.file);
    40324022    if isequal(PathName(end),'/')||isequal(PathName(end),'\')
    40334023        PathName(end)=[];
    40344024    end
    4035     coord_fct=fullfile(PathName,FileName);
    4036     if ~exist(coord_fct,'file')
    4037            msgbox_uvmat('ERROR',['image procesing fct ' coord_fct ' not found'])
    4038     else
    4039        [ppp,transform]=fileparts(FileName);% removes extension .m
    4040        menu=update_menu(handles.menu_coord,transform);%add the selected fct to the menu
    4041        ind_coord=get(handles.menu_coord,'Value');
    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)
    4046        if exist(profil_perso,'file')
    4047             save (profil_perso,'coord_fct','-append'); %store the root name for future opening of uvmat
    4048         end
    4049     end   
     4025    transform_selected =fullfile(PathName,FileName);
     4026    if ~exist(transform_selected,'file')
     4027%            msgbox_uvmat('ERROR',['procesing fct ' transform_selected ' not found'])
     4028           return
     4029    end
     4030   [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
     4031   if ~isequal(ext_fct,'.m')
     4032        msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
     4033        return
     4034   end
     4035   menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
     4036   ind_coord=get(handles.transform_fct,'Value');
     4037   addpath(PathName)
     4038   list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
     4039   set(handles.transform_fct,'UserData',list_transform)
     4040   rmpath(PathName)
     4041   % save the new menu in the personal file 'uvmat_perso.mat'
     4042   dir_perso=prefdir;%personal Matalb directory
     4043   profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     4044   if exist(profil_perso,'file')
     4045       for ilist=nb_builtin+1:numel(list_transform)
     4046           ff=functions(list_transform{ilist});
     4047           transform_fct{ilist-nb_builtin}=ff.file;
     4048       end
     4049        save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
     4050   end   
    40504051end
    40514052
    40524053%check the current path to the selected function
    4053 func=functions(list_transform{ind_coord})
     4054func=functions(list_transform{ind_coord});
    40544055set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
    40554056%CurrentPath=fileparts(which(coord_option));
     
    48084809param.filter1=get(handles.filter1,'Value');
    48094810param.filter2=get(handles.filter2,'Value');
    4810 param.menu_coord_str=get(handles.menu_coord,'String');
    4811 param.menu_coord_val=get(handles.menu_coord,'Value');
     4811param.menu_coord_str=get(handles.transform_fct,'String');
     4812param.menu_coord_val=get(handles.transform_fct,'Value');
    48124813
    48134814series(param); %run the series interface
     
    48624863%--------------------------------------------------------------------------
    48634864function enable_transform(handles,state)
    4864 set(handles.menu_coord,'Visible',state)
     4865set(handles.transform_fct,'Visible',state)
    48654866set(handles.TRANSFORM_txt,'Visible',state)   
    4866 set(handles.menu_coord,'Visible',state) 
     4867set(handles.transform_fct,'Visible',state) 
    48674868set(handles.path_transform,'Visible',state)
    48684869set(handles.pxcmx_txt,'Visible',state)
Note: See TracChangeset for help on using the changeset viewer.