Ignore:
Timestamp:
May 21, 2013, 9:12:42 PM (11 years ago)
Author:
sommeria
Message:

corrections for mask and transform fct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uigetfile_uvmat.m

    r635 r641  
    1010% InputDir: directory to browse at first display
    1111
    12 function fileinput=uigetfile_uvmat(title,InputName)
     12function fileinput=uigetfile_uvmat(title,InputName,FilterExt)
     13if ~exist('FilterExt','var')
     14    FilterExt='*';
     15end
    1316fileinput=''; %default file selection
    1417if strcmp(title,'status_display')
     
    5962    uicontrol('Style','popupmenu','Units','normalized', 'Position', [0.75 0.8 0.2 0.04],'tag','sort_option','Callback',@refresh_GUI,'Visible','off',...
    6063            'String',{'name';'date'},'FontUnits','points','FontSize',12,'FontWeight','bold');   
    61     uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.08 0.9 0.66], 'Callback', @(src,event)list_Callback(option,src,event),'tag','list',...
     64    uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.08 0.9 0.66], 'Callback', @(src,event)list_Callback(option,FilterExt,src,event),'tag','list',...
    6265        'FontUnits','points','FontSize',12);
    6366    uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.005 0.2 0.07],'Callback',@(src,event)close(option,src,event),...
     
    8083    drawnow
    8184end
    82 refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName)% refresh the list of content of the current dir 
     85refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName,FilterExt)% refresh the list of content of the current dir 
    8386if ~strcmp(option,'status_display') 
    8487    uiwait(hfig)
     
    98101%------------------------------------------------------------------------   
    99102% --- launched by refreshing the display figure
    100 function refresh_GUI(hObject,InputFileName)
     103function refresh_GUI(hObject,InputFileName,FilterExt)
    101104%------------------------------------------------------------------------
    102105if ~exist('InputFileName','var')
     
    125128        NbOutputFile_str=num2str(NbOutputFile);
    126129    end
    127     [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content
     130    [ListFiles,NumFiles]=list_files(DirName,1,TimeStart,FilterExt);% list the directory content
    128131   
    129132    %% update the waitbar
     
    140143    end
    141144    hcheck_date=findobj(hfig,'tag','check_date');
    142     [ListFiles,NumFiles]=list_files(DirName,get(hcheck_date,'Value'),sort_option);% list the directory content
     145    [ListFiles,NumFiles]=list_files(DirName,get(hcheck_date,'Value'),sort_option,FilterExt);% list the directory content
    143146end
    144147
     
    169172%------------------------------------------------------------------------   
    170173% --- launched by selecting an item on the file list
    171 function list_Callback(option,hObject,event)
     174function list_Callback(option,filter_ext,hObject,event)
    172175%------------------------------------------------------------------------
    173176hfig=get(hObject,'parent');%handle of the fig
     
    214217    hcheck_date=findobj(hfig,'tag','check_date');
    215218   
    216     ListFiles=list_files(FullSelectName,get(hcheck_date,'Value'),sort_option);% list the directory content
     219    ListFiles=list_files(FullSelectName,get(hcheck_date,'Value'),sort_option,filter_ext);% list the directory content
    217220    set(hObject,'Value',1)
    218221    set(hObject,'String',ListFiles)
     
    242245%-------------------------------------------------------------------------   
    243246% list the content of a directory
    244 function [ListFiles,NumFiles]=list_files(DirName,check_date,sort_option)
     247function [ListFiles,NumFiles]=list_files(DirName,check_date,sort_option,filter_ext)
    245248%-------------------------------------------------------------------------
    246249ListStruct=dir(DirName);% get structure of the current directory
     
    253256ListFiles=ListCells(1,:);%list of file names
    254257check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     258
    255259ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
    256260ListDates=cell2mat(ListCells(5,:));%list of numerical dates
     
    262266ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front
    263267end
     268
    264269if isnumeric(sort_option)|| strcmp(sort_option,'date')
    265270    [tild,index_sort]=sort(ListDates,2,'descend');% sort files by chronological order, recent first, put the dir first in the list
     
    270275cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
    271276check_keep=cellfun('isempty', cell_remove);
     277if exist('filter_ext')
     278    switch filter_ext
     279        case 'image'
     280            check_keep=check_keep & (cellfun(@isimage,ListFiles) |check_dir);
     281    end
     282end
    272283ListFiles=[{'+/..'} ListFiles(check_keep)];
    273284if check_date
     
    319330
    320331%-------------------------------------------------------------------------   
    321 % launched by deleting the status figure (only used in mode series status')
     332% --- launched by deleting the status figure (only used in mode series status')
     333%-------------------------------------------------------------------------
    322334function close(option,hObject, eventdata)
    323 %-------------------------------------------------------------------------
     335
    324336if strcmp(option,'status_display')
    325337    hseries=findobj(allchild(0),'Tag','series');
     
    330342delete(gcbf)
    331343
     344%-------------------------------------------------------------------------
     345% --- check whether a file is has an image name extension
     346%-------------------------------------------------------------------------
     347function CheckImage=isimage(filename)
     348
     349[pp,name,ext]=fileparts(filename);
     350ext
     351CheckImage=~isempty(ext)&&~strcmp(ext,'.')&&~isempty(imformats(regexprep(ext,'^.','')));
Note: See TracChangeset for help on using the changeset viewer.