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

📄 erp_showplot_ui.m

📁 绝对经典,老外制作的功能强大的matlab实现PLS_TOOBOX
💻 M
📖 第 1 页 / 共 3 页
字号:

            text_y = y + eta*wave_top/(abs(wave_bottom)+abs(wave_top));

            chan_name_hdl(i) = text(text_x(i),text_y(i), ...
               deblank(chan_nam(i,:)), 'userdata', [0, i], ...
               'buttondown','erp_plot_ui(''select_chan_name'');', ...
               'horizon', 'center', 'vertical', 'bottom', ...
               'fontsize',font_size,'clipping','on','Interpreter','none');

         end			% for selected_chan_idx

         hold off;

         %  create plot title
         %
         switch view_option
            case {1}
               h_title=text(.03,.99,'ERP Amplitude', ...
			'fontsize',font_size, 'fontweight','bold','Interpreter','none');
            case {2}
               h_title=text(.03,.99,'Grand Average Amplitude', ...
			'fontsize',font_size, 'fontweight','bold','Interpreter','none');
            case {3}
               h_title=text(.03,.99,'Electrode Salience', ...
			'fontsize',font_size, 'fontweight','bold','Interpreter','none');
            case {4}
               h_title=text(.03,.99,'Group Subject Amplitude', ...
			'fontsize',font_size, 'fontweight','bold','Interpreter','none');
            case {5}
               h_title=text(.03,.99,'Spatiotemporal Correlations', ...
			'fontsize',font_size, 'fontweight','bold','Interpreter','none');
         end

         setappdata(fig,'axis_template',axis_template);
         setappdata(fig,'xtick_template',xtick_template);
         setappdata(fig,'ytick_template',ytick_template);
         setappdata(fig,'laxis_hdl',laxis_hdl);
         setappdata(fig,'lxtick_hdl',lxtick_hdl);
         setappdata(fig,'lytick_hdl',lytick_hdl);
         setappdata(fig,'ltext_x',ltext_x);
         setappdata(fig,'ltext_y',ltext_y);
         setappdata(fig,'legend_text_hdl',legend_text_hdl);
         setappdata(fig,'offset',offset);
         setappdata(fig,'offset2',offset2);
         setappdata(fig,'offset3',offset3);
         setappdata(fig,'axis_hdl',axis_hdl);
         setappdata(fig,'xtick_hdl',xtick_hdl);
         setappdata(fig,'ytick_hdl',ytick_hdl);
         setappdata(fig,'wave_hdl',wave_hdl);
         setappdata(fig,'avg_wave_hdl',avg_wave_hdl);
         setappdata(fig,'bs_wave_hdl',bs_wave_hdl);
         setappdata(fig,'chan_name_hdl',chan_name_hdl);
         setappdata(fig,'h_title',h_title);
         setappdata(fig,'x_interval',x_interval);
         setappdata(fig,'y_interval',y_interval);
         setappdata(fig,'avg_amplitude',avg_amplitude);
         setappdata(fig,'wave_amplitude',wave_amplitude);
         setappdata(fig,'bs_x_amplitude',bs_x_amplitude);
         setappdata(fig,'bs_y_amplitude',bs_y_amplitude);
         setappdata(fig,'selected_wave_name',selected_wave_name);
         setappdata(fig,'selected_avg_name',selected_avg_name);
         setappdata(fig,'selected_bs_name',selected_bs_name);
         setappdata(fig,'selected_wave_idx',selected_wave_idx);
         setappdata(fig,'selected_avg_idx',selected_avg_idx);
         setappdata(fig,'selected_bs_idx',selected_bs_idx);
         setappdata(fig,'selected_chan_idx',selected_chan_idx);

      else		%  if there is NO wave

         setappdata(fig,'wave_hdl',[]);
         setappdata(fig,'avg_wave_hdl',[]);
         setappdata(fig,'bs_wave_hdl',[]);
         setappdata(fig,'legend_hdl',[]);
         setappdata(fig,'chan_name_hdl',[]);

         return;
      end		%  end of ~isempty(wave_disp) | ~isempty(avg_disp)

      init_option.color_code1 = color_code1;
      init_option.color_code2 = color_code2;
      init_option.color_code3 = color_code3;
      init_option.avg_max = avg_max;
      init_option.avg_min = avg_min;
      init_option.wave_max = wave_max;
      init_option.wave_min = wave_min;
      init_option.wave_top = wave_top;
      init_option.wave_bottom = wave_bottom;
      init_option.timepoint = timepoint;
      init_option.start_timepoint = start_timepoint;
      init_option.digit_interval = digit_interval;
      init_option.x = x;
      init_option.y = y;

      setappdata(fig,'init_option',init_option);


   else		%%%%%%%%%%%%%%%%%%%%% if NOT first time run showplot

      %++++++++++++++++++++++++++++++++++++++++++++++++

      init_option = getappdata(fig,'init_option');

      avg_max = init_option.avg_max;
      avg_min = init_option.avg_min;
      wave_max = init_option.wave_max;
      wave_min = init_option.wave_min;
      wave_top = init_option.wave_top;
      wave_bottom = init_option.wave_bottom;
      timepoint = round(init_option.timepoint);
      start_timepoint = floor(init_option.start_timepoint);
      x = init_option.x;
      y = init_option.y;

      orig_axis_hdl = getappdata(fig,'axis_template');
      orig_xtick_hdl = getappdata(fig,'xtick_template');
      orig_ytick_hdl = getappdata(fig,'ytick_template');
      laxis_hdl = getappdata(fig,'laxis_hdl');
      lxtick_hdl = getappdata(fig,'lxtick_hdl');
      lytick_hdl = getappdata(fig,'lytick_hdl');
      ltext_x = getappdata(fig,'ltext_x');
      ltext_y = getappdata(fig,'ltext_y');
      legend_text_hdl = getappdata(fig,'legend_text_hdl');
      offset = getappdata(fig,'offset');
      offset2 = getappdata(fig,'offset2');
      offset3 = getappdata(fig,'offset3');
      axis_hdl = getappdata(fig,'axis_hdl');
      xtick_hdl = getappdata(fig,'xtick_hdl');
      ytick_hdl = getappdata(fig,'ytick_hdl');
      wave_hdl = getappdata(fig,'wave_hdl');
      avg_wave_hdl = getappdata(fig,'avg_wave_hdl');
      bs_wave_hdl = getappdata(fig,'bs_wave_hdl');
      chan_name_hdl = getappdata(fig,'chan_name_hdl');
      h_title = getappdata(fig,'h_title');
      wave_amplitude = getappdata(fig,'wave_amplitude');
      avg_amplitude = getappdata(fig,'avg_amplitude');
      bs_x_amplitude = getappdata(fig,'bs_x_amplitude');
      bs_y_amplitude = getappdata(fig,'bs_y_amplitude');
      selected_wave_name = getappdata(fig,'selected_wave_name');
      selected_avg_name = getappdata(fig,'selected_avg_name');
      selected_bs_name = getappdata(fig,'selected_bs_name');
      selected_wave_idx = getappdata(fig,'selected_wave_idx');
      selected_avg_idx = getappdata(fig,'selected_avg_idx');
      selected_bs_idx = getappdata(fig,'selected_bs_idx');
      selected_chan_idx = getappdata(fig,'selected_chan_idx');
      eta = getappdata(fig,'eta');
      font_size = font_size_list(getappdata(fig,'font_size_selection'));

      num_wave = size(selected_wave_name,1);
      num_avg = size(selected_avg_name,1);
      num_bs = size(selected_bs_name,1);

      %  update legend axis
      %
      for j=1:size(laxis_hdl,1)    % for all the components on legend axis
         set(laxis_hdl(j), ...
            'xdata',eta*get(orig_axis_hdl(j),'xdata') ...
            +offset, ...
            'ydata',eta*(get(orig_axis_hdl(j),'ydata') ...
            +abs(wave_bottom)/(abs(wave_bottom)+abs(wave_top))) ...
            +offset2);
      end

      %  update legend tick marks
      %
      if ~isempty(orig_xtick_hdl)
         for j=1:size(lxtick_hdl,1)	% for all the components on legend xtick
            set(lxtick_hdl(j), ...
               'xdata',eta*get(orig_xtick_hdl(j),'xdata') ...
               +offset, ...
               'ydata',eta*(get(orig_xtick_hdl(j),'ydata') ...
               +abs(wave_bottom)/(abs(wave_bottom)+abs(wave_top))) ...
               +offset2);
         end
      end

      if ~isempty(orig_ytick_hdl)
         for j=1:size(lytick_hdl,1)	% for all the components on legend ytick
            set(lytick_hdl(j), ...
               'xdata',eta*get(orig_ytick_hdl(j),'xdata') ...
               +offset, ...
               'ydata',eta*(get(orig_ytick_hdl(j),'ydata') ...
               +abs(wave_bottom)/(abs(wave_bottom)+abs(wave_top))) ...
               +offset2);
         end
      end

      %  update legend axis label
      %
      %--------------------------------

      % north
      %
      if start_timepoint < 0
         ltext_x = eta * ((-start_timepoint)/(timepoint-1)) + offset;
      else
         ltext_x = offset;
      end
      ltext_y = eta + offset2 + offset3;
      set(legend_text_hdl(1),'position',[ltext_x,ltext_y,0], ...
	'fontsize',font_size);

      % south
      %
      if start_timepoint < 0
         ltext_x = eta * ((-start_timepoint)/(timepoint-1)) + offset;
      else
         ltext_x = offset;
      end
      ltext_y = offset2 - offset3;
      set(legend_text_hdl(2),'position',[ltext_x,ltext_y,0], ...
	'fontsize',font_size);

      % east
      %
      ltext_x = eta + offset + offset3;
      ltext_y = eta * abs(wave_bottom)/(abs(wave_bottom) ...
         + abs(wave_top)) + offset2;
      set(legend_text_hdl(3),'position',[ltext_x,ltext_y,0], ...
	'fontsize',font_size);

      % west
      %
      ltext_x = offset - offset3;
      ltext_y = eta * abs(wave_bottom)/(abs(wave_bottom) ...
         + abs(wave_top)) + offset2;
      set(legend_text_hdl(4),'position',[ltext_x,ltext_y,0], ...
	'fontsize',font_size);

      for i=selected_chan_idx

         for j=1:size(axis_hdl,1)    % for all the components on axis
            set(axis_hdl(j,i), ...
             'xdata',eta*get(orig_axis_hdl(j),'xdata')+x(i), ...
             'ydata',eta*get(orig_axis_hdl(j),'ydata')+y(i));
         end

         if ~isempty(orig_xtick_hdl)
            for j=1:size(xtick_hdl,1)	% for all the components on xtick
               set(xtick_hdl(j,i), ...
                  'xdata',eta*get(orig_xtick_hdl(j),'xdata')+x(i), ...
                  'ydata',eta*get(orig_xtick_hdl(j),'ydata')+y(i));
            end
         end

         if ~isempty(orig_ytick_hdl)
            for j=1:size(ytick_hdl,1)	% for all the components on ytick
               set(ytick_hdl(j,i), ...
                  'xdata',eta*get(orig_ytick_hdl(j),'xdata')+x(i), ...
                  'ydata',eta*get(orig_ytick_hdl(j),'ydata')+y(i));
            end
         end

         x_wave = eta * (0:timepoint-1)/(timepoint-1) + x(i);

         if num_avg ~= 0
            for j=selected_avg_idx
               y_wave = eta * ...
                  avg_amplitude(:,i,j)/(abs(wave_bottom)+abs(wave_top))+y(i);
               set(avg_wave_hdl(i,j),'xdata',x_wave,'ydata',y_wave);
            end              % for selected_avg_idx
         end

         if num_wave ~= 0
            for j=selected_wave_idx
               y_wave = eta * ...
                  wave_amplitude(:,i,j)/(abs(wave_bottom)+abs(wave_top))+y(i);
               set(wave_hdl(i,j),'xdata',x_wave,'ydata',y_wave);
            end
         end

         if num_bs ~= 0
            for j = selected_bs_idx

               x_mask = bs_x_amplitude(:,i,j);
               x_mask = find(x_mask)';
               bs_x_wave = x_wave(x_mask);

               bs_y_wave = bs_y_amplitude(:,i,j);
               bs_y_wave = eta * (bs_y_wave(x_mask) - abs(wave_bottom) ...
                     / (abs(wave_bottom) + abs(wave_top))) ...
                     + y(i);

               if bs_wave_hdl(i,j) ~= 99999
                  set(bs_wave_hdl(i,j),'xdata',bs_x_wave,'ydata',bs_y_wave);
               end

            end
         end

         if start_timepoint < 0
            text_x = x + eta*((-start_timepoint)/(timepoint-1));
         else
            text_x = x;
         end

         text_y = y + eta*wave_top/(abs(wave_bottom)+abs(wave_top));

         set(chan_name_hdl(i),'position',[text_x(i),text_y(i)], ...
		'fontsize',font_size);

      end	% for selected_chan_idx

      set(h_title,'fontsize',font_size);	% update title font size

   end					%%  if init_flag end

   if need_chan_name
      erp_plot_ui('display_chan_name','on');
   else
      erp_plot_ui('display_chan_name','off');
   end
 
   if need_chan_axes
      erp_plot_ui('display_chan_axes','on');
   else
      erp_plot_ui('display_chan_axes','off');
   end

   if need_chan_tick & need_chan_axes
      erp_plot_ui('display_chan_tick','on');
   else
      erp_plot_ui('display_chan_tick','off');
   end

   % below is the test routine, don't remove it
   %
   if(0)	% set 1 for test, 0 for normal

      switch system.class
         case 1
            type_str = 'BESAThetaPhi|EGI128|EGI256';

            switch system.type
               case 1
                  load('erp_loc_besa148');
               case 2
                  load('erp_loc_egi128');
               case 3
                  load('erp_loc_egi256');
            end
         case 2
            type_str = 'CTF-150';

            switch system.type
               case 1
                  load('erp_loc_ctf150');
            end
      end

      for i=1:size(chan_loc,1)
         x(i) = chan_loc(i,1);
         y(i) = chan_loc(i,2);
      end

      min_x = min(x);	max_x = max(x);
      min_y = min(y);	max_y = max(y);
      %  normalize & shift x & y array
      %
      x = (x-min_x) / (max_x-min_x);
      y = (y-min_y) / (max_y-min_y);

      for i=1:size(chan_loc,1)
         text(x(i), y(i), chan_nam(i,:),'Interpreter','none');
      %    text(x(i), y(i), num2str(i),'Interpreter','none');
      end

   end

   return;					% erp_showplot_ui

⌨️ 快捷键说明

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