Changeset 96 for aedes_juigetfiles.m


Ignore:
Timestamp:
Oct 20, 2009, 10:21:23 AM (10 years ago)
Author:
tjniskan
Message:
  • Added a possibility of loading ROIs in NIfTI file format.
  • Added custom filter feature to aedes_juigetfiles

M aedes_data_read.m
M aedes.m
M aedes_revision.m
M aedes_juigetfiles.m

File:
1 edited

Legend:

Unmodified
Added
Removed
  • aedes_juigetfiles.m

    r80 r96  
    7373scrsz=get(0,'screensize');
    7474fig_w = 870;%780;
    75 fig_h = 535;
     75fig_h = 545;%535;
    7676fig_pos = [scrsz(3)/2-fig_w/2 scrsz(4)/2-fig_h/2 fig_w fig_h];
    7777fh=figure('position',fig_pos,...
     
    9191H.fh=fh;
    9292%pos = [5 60 200 420];
    93 pos=[5 60 320 420];
     93%pos=[5 60 320 420];
     94pos=[5 70 320 420];
    9495%% Check if defaultdir exists
    9596if ischar(defaultdir)
     
    295296                  'style','text',...
    296297                  'backgroundcolor',FigColor);%[236 233 216]./255);
    297 
     298if isunix
     299  set(ff_tx,'fontsize',8)
     300end
    298301ffstr = {filefilter{:,2}};
    299302
     303% Custom Filter Edit
     304tmp=get(ff_tx,'position');
     305custom_filter_tx = uicontrol('parent',fh,...
     306  'units','pixel',...
     307  'position',[tmp(1) tmp(2)-30 100 20],...
     308  'string','Custom Filter:',...
     309  'horizontalalign','left',...
     310  'style','text',...
     311  'backgroundcolor',FigColor);
     312if isunix
     313  set(custom_filter_tx,'fontsize',8)
     314end
     315tmp=get(filefilter_popup,'position');
     316customfilter_popup = uicontrol('parent',fh,...
     317  'units','pixel',...
     318  'position',[tmp(1) tmp(2)-30 tmp(3)/2 25],...
     319  'string',' ',...
     320  'tooltip','Filter using regular expressions',...
     321  'style','edit',...
     322  'backgroundcolor','w',...
     323  'callback',{@l_DirNodeSelected,tree,filetree});
     324
     325
    300326% Construct find string for regexp
    301 regexp_str = strrep(strrep(strrep({filefilter{:,1}},';','|'),'*.','\.'),'\.*','.+');
     327%regexp_str = strrep(strrep(strrep({filefilter{:,1}},';','|'),'*.','\.'),'\.*','.*');
     328regexp_str={filefilter{:,1}};
     329for ii=1:numel(regexp_str)
     330  str=regexp_str{ii};
     331  if any(str==';')
     332    [delim,tmp_str]=regexp(str,';','match','split');
     333    tmp_str=regexprep(regexprep(regexprep(regexprep(tmp_str,'\*\.','\\\.'),'^([^\\\.\*])','\^$1'),'([^\*])$','$1\$'),'^\\\.\*$','\.\*');
     334    str = sprintf('(%s)|',tmp_str{:});
     335    str = str(1:end-1);
     336  else
     337    str=regexprep(regexprep(regexprep(regexprep(str,'\*\.','\\\.'),'^([^\\\.\*])','\^$1'),'([^\*])$','$1\$'),'^\\\.\*$','\.\*');
     338  end
     339  regexp_str{ii} = str;
     340end
    302341set(filefilter_popup,'string',ffstr,'userdata',regexp_str)
    303342
     
    318357H.updateHistory = true;
    319358H.iconpath = iconpath;
     359H.customfilter_popup = customfilter_popup;
    320360setappdata(H.fh,'H',H)
    321361
     
    554594% Execute when directory node is selected
    555595%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    556 function l_DirNodeSelected(h,evd,tree,filetree)
     596function l_DirNodeSelected(hCaller,evd,tree,filetree)
    557597
    558598H=getappdata(findall(0,'tag','aedes_juigetfiles_main_fig'),'H');
     
    643683filenames={ch(~[ch(:).isdir]).name};
    644684filter_val=get(H.filefilter_popup,'value');
    645 regexp_str = get(H.filefilter_popup,'userdata');
    646 regexp_str = regexp_str{filter_val};
    647 if ~strcmp(regexp_str,'.+')
    648   [s_ind,e_ind]=regexpi(filenames,['(' regexp_str ')$']);
    649   if ~isempty(s_ind)
    650     ind = (double(char(s_ind{:}))-double(char(e_ind{:})))~=0;
    651     filenames = {filenames{logical(ind)}};
    652   else
    653     filenames = {};
    654   end
     685if ~isempty(hCaller) && hCaller~=H.customfilter_popup
     686  regexp_str = get(H.filefilter_popup,'userdata');
     687  regexp_str = regexp_str{filter_val};
     688else
     689  regexp_str = get(H.customfilter_popup,'string');
     690end
     691if ~strcmp(regexp_str,'.*')
     692  [s_ind,e_ind]=regexpi(filenames,regexp_str);
     693  ind=~cellfun('isempty',s_ind);
     694  filenames = {filenames{ind}};
     695 
     696%   if ~isempty(s_ind)
     697%     ind = (double(char(s_ind{:}))-double(char(e_ind{:})))~=0;
     698%     filenames = {filenames{logical(ind)}};
     699%   else
     700%     filenames = {};
     701%   end
    655702end
    656703directories={ch([ch(:).isdir]).name};
     
    659706  ind = regexp(directories,'^\.');
    660707  directories = {directories{cellfun('isempty',ind)}};
     708end
     709
     710% Set regexp filter string to custom filter editbox
     711if ~isempty(hCaller) && hCaller~=H.customfilter_popup
     712  set(H.customfilter_popup,'string',regexp_str)
    661713end
    662714
Note: See TracChangeset for help on using the changeset viewer.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008