⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 roi_select.m

📁 国外的一个PLStoolbox,主要用于处理图象,也可以用来回归,欢迎使用
💻 M
📖 第 1 页 / 共 2 页
字号:
        'ListboxTop',0, ...
        'Position',pos, ...
        'HorizontalAlignment','center', ...
        'String','CANCEL', ...
        'Callback','roi_select({''CANCEL_BUTTON_PRESSED''});', ...
        'Tag','CANCELButton');

   x = .01;
   y = 0;
   w = 1;

   pos = [x y w h];

   c = uicontrol('Parent',h0, ...		% Message Line
   	'Style','text', ...
   	'Units','normal', ...
   	'BackgroundColor',[0.8 0.8 0.8], ...
   	'ForegroundColor',[0.8 0.0 0.0], ...
	'fontunit','normal', ...
   	'FontSize',fnt, ...
   	'HorizontalAlignment','left', ...
   	'Position',pos, ...
   	'String','', ...
   	'Tag','MessageLine');


      %--------------------------- menu ----------------------

      %  file
      %
      h_file = uimenu('parent',h0, ...
           'label','&File', ...
	   'tag','menu_file');
      h2 = uimenu('parent', h_file, ...
           'callback','roi_select({''LOAD_TXT''});', ...
           'label','&Load from a text file', ...
   	   'tag', 'menu_load');
      h2 = uimenu('parent', h_file, ...
           'callback','roi_select({''SAVE_TXT''});', ...
           'label','&Save to a text file', ...
	   'tag', 'menu_save');
      h2 = uimenu('parent', h_file, ...
           'callback','close(gcbf);', ...
           'label','&Close', ...
           'visible','off', ...	
	   'tag', 'menu_close');

   pause(0.01)

   h1 = findobj(gcf,'tag','ChannelList');
   set(h1,'string',chan_nam);

   selected_chan_nam = chan_nam(str2num(old_chan_order_str),:);
   h1 = findobj(gcf,'tag','SelectedChannelList');
   set(h1,'string',selected_chan_nam);

   set(h1, 'user', str2num(old_chan_order_str));
   set(findobj(gcf,'tag','SelectedChannelLabel'),'string', ...
	['Selected ROIs: ', ...
	num2str(length(str2num(old_chan_order_str)))]);

   setappdata(gcf,'old_chan_order_str',old_chan_order_str);
   setappdata(gcf,'chan_nam',chan_nam);

%   msg = 'The order of "Selected ROI" must be the same as the one in compare file.';
%   uiwait(msgbox(msg,'Warning!','modal'));

   return;					% Init


% --------------------------------------------------------------------
function AddSessionProfile()

   h = findobj(gcf,'Tag','ChannelList');    % get the selected file
   selected_chan_idx = get(h,'Value')';

   %  update selected channel list
   %
   h = findobj(gcf,'Tag','SelectedChannelList');	   
   selected_chan_order_str = get(h,'String');

   old_chan_order = get(h,'Userdata');

   % check for duplication
   %
   if ~isempty(intersect(selected_chan_idx, old_chan_order))
      msg = 'ERROR: Duplicate channel is not allowed.';
      set(findobj(gcf,'Tag','MessageLine'),'String',msg);
      return;
   end; 

   chan_order = [old_chan_order; selected_chan_idx];

   % if isempty(old_chan_order)
   if isempty(get(h, 'string'))
      set(h, 'value', 1);
   end

   update_chan_order(chan_order);

   return;					% AddSessionProfile


% --------------------------------------------------------------------
function MoveUpSessionProfile()

   %  update the session profile list
   %
   h = findobj(gcf,'Tag','SelectedChannelList');	   
   list_top = get(h,'ListboxTop');
   move_idx = get(h,'Value');
   chan_list = get(h,'String');
   chan_order = get(h,'user');

   if (move_idx == 1),			% already on the top of list
      return;
   end;

   temp_buffer = chan_list(move_idx-1,:);
   chan_list(move_idx-1,:) = chan_list(move_idx,:);
   chan_list(move_idx,:) = temp_buffer;

   temp_buffer = chan_order(move_idx-1);
   chan_order(move_idx-1) = chan_order(move_idx);
   chan_order(move_idx) = temp_buffer;

   curr_value = move_idx - 1;

   set(h,'String',chan_list,'Userdata',chan_order, ...
         'Value',curr_value);

   if (curr_value < list_top)
      set(h,'ListBoxTop',curr_value);
   else
      set(h,'ListBoxTop',list_top);
   end;

   return;					% MoveUpSessionProfile


% --------------------------------------------------------------------
function MoveDownSessionProfile()

   %  update the session profile list
   %
   h = findobj(gcf,'Tag','SelectedChannelList');	   
   list_top = get(h,'ListboxTop');
   move_idx = get(h,'Value');
   chan_list = get(h,'String');
   chan_order = get(h,'user');

   if (move_idx == size(chan_list,1)),		% already on the bottom of list
      return;
   end;
   
   temp_buffer = chan_list(move_idx+1,:);
   chan_list(move_idx+1,:) = chan_list(move_idx,:);
   chan_list(move_idx,:) = temp_buffer;

   temp_buffer = chan_order(move_idx+1);
   chan_order(move_idx+1) = chan_order(move_idx);
   chan_order(move_idx) = temp_buffer;

   curr_value = move_idx + 1;

   set(h,'String',chan_list,'Userdata',chan_order, ...
         'Value',curr_value);

   set(h,'ListBoxTop',list_top);

   return;					% MoveDownSessionProfile


% --------------------------------------------------------------------
function RemoveSessionProfile()

   %  update the session profile list
   %
   h = findobj(gcf,'Tag','SelectedChannelList');	   
   remove_idx = get(h,'Value');
   chan_list = get(h,'String');
   chan_order = get(h,'Userdata');

   if isempty(chan_order)
      return;
   end

   mask = zeros(1,size(chan_list,1));
   mask(remove_idx) = 1;
   chan_order = chan_order(find(mask == 0));

   if length(remove_idx) > 1
      set(h, 'value', 1);
   elseif remove_idx == size(chan_list,1)
      set(h, 'value', remove_idx-1);
   end

   update_chan_order(chan_order);

   return;					% RemoveSessionProfile


%----------------------------------------------------------------------------
function update_chan_order(chan_order)

   chan_nam = getappdata(gcf,'chan_nam');
   selected_chan_nam = chan_nam(chan_order,:);

   h1 = findobj(gcf,'tag','SelectedChannelList');

   set(h1, 'string',selected_chan_nam, 'user', chan_order);
   set(findobj(gcf,'tag','SelectedChannelLabel'),'string', ...
	['Selected ROIs: ', num2str(length(chan_order))]);

   return;


%----------------------------------------------------------------------------
function delete_fig

    try
       load('pls_profile');
       pls_profile = which('pls_profile.mat');

       roi_select_pos = get(gcbf,'position');

       save(pls_profile, '-append', 'roi_select_pos');
    catch
    end

   return;


%----------------------------------------------------------------------------
function load_txt

   [fn, pn] = uigetfile('*.txt','Open Electrode Order File');

   if isequal(fn,0) | isequal(pn,0)
      return;
   end

   chan_file = fullfile(pn, fn);

   try
      chan_order = load('-ascii', chan_file);
   catch
      msg = 'Invalid electrode order file';
      uiwait(msgbox(msg,'Error','modal'));
      return;
   end

   if   sum(size(chan_order))~=(size(chan_order,1)+1) | ...
	size(chan_order,1)~=size(unique(chan_order),1) | ...
	all(chan_order~=round(chan_order)) | ...
	min(chan_order)<1

      msg = 'Invalid electrode order file';
      uiwait(msgbox(msg,'Error','modal'));
      return;

   end

   h = findobj(gcf,'Tag','SelectedChannelList');	   

   if isempty(get(h, 'string'))
      set(h, 'value', 1);
   end

   update_chan_order(chan_order);

   return


%----------------------------------------------------------------------------
function save_txt

   SelectedChannelList = get(findobj(gcf,'Tag','SelectedChannelList'),'Userdata');

   [fn, pn] = uiputfile('*.txt','Save Electrode Order File');
   chan_file = [pn filesep fn];

   if ~fn
%      msg = 'WARNING: No file is saved.';
%      uiwait(msgbox(msg,'Uncomplete','modal'));

      return;
   else
      try
         save(chan_file,'-ascii','SelectedChannelList')
      catch
         msg = 'ERROR: Cannot save file';
         set(findobj(gcf,'Tag','MessageLine'),'String',msg);
         return;
      end
   end

   return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -