Home > matlabmk > sig_raster_dif_coefs.m

sig_raster_dif_coefs

PURPOSE ^

sig_raster() - Plots 2D (electrode x time/frequency) raster diagram of

SYNOPSIS ^

function img=sig_raster_dif_coefs(regress_results_or_fname,varargin)

DESCRIPTION ^

 sig_raster() - Plots 2D (electrode x time/frequency) raster diagram of 
                variables that show significant effects according to t-tests. 
                Significant positive effects are represented 
                with white squares (red if color is requested).  
                Significant negative effects are represented with
                black squares (blue if color is requested).
                
 Usage:
  >> img=sig_raster_coefs(regress_results_or_fname,varargin)

 Required Inputs:
  regress_results  - A GND/GRP/specGND structure variable or the filename of 
                      sucah a variable that has been saved to disk.   
                      To create a GND variable from Kutaslab ERP files (e.g.,
                      *.nrm files) use avgs2GND.m.  To do the same from 
                      EEGLAB *.set files use sets2GND.m.  To create a
                      a GRP structure use GNDs2GRP.m. See Mass Univariate ERP  
                      Toolbox documentation for detailed information about the 
                      format of GND and GRP variables. If you specifiy a filename 
                      be sure to include the file's path, unless the file is
                      in the current working directory.              
  test_id           - [integer] The index # of the t-test results 
                      stored in the GND/GRP/specGND variable that you wish to visualize.  
                      To see what test results are available, look at 
                      the "t_tests" field of your variable (e.g., GND.t_tests)
                      or use the functions headinfo.m or headinfo_spec.m.

 Optional Inputs:
  x_ticks          - [vector] The times/frequencies you want marked with ticks
                     on the x-axis.  Note, because the EEG has been sampled 
                     at discrete time points, not all times between the 
                     minimum and maximum analyzed times/frequencies can be
                     used.  When a tick is requested that is not available, 
                     the closest possible value is used. If not
                     specified, x_ticks are automatically chosen based
                     on the time/frequency range covered by the diagram. 
                     This option has no effect if the t-test was
                     executed based on mean voltages/power within specified 
                     time windows/frequency bands.
  fig_id           - [integer] The index # of the MATLAB figure in which
                     the diagram will be produced.  Useful for overwriting
                     old figures. {default: lowest unused index}
  use_color        - [integer] If non-zero, non-gray scale colors will be
                     used in the diagram. {default: 0}
  plot_vert_lines  - [integer] If non-zero, vertical lines separating all
                     time points included in the t-test will be 
                     shown. If 0, the only vertical lines drawn will be 
                     those that separate times/frequencies included in a test 
                     from those not included. This option has no effect if 
                     the t-test was executed based on mean voltage/power 
                     within specified time windows. {default: 1}
  lr_sym           - [integer] If non-zero, left hemisphere electrodes are
                     plot from most anterior to most posterior and right 
                     hemisphere electrodes are plot from most posterior to 
                     most anterior.  This may make it easier to visualize 
                     the degree of effect left-right symmetry.  If 0, all
                     electrodes are plot from most anterior to most
                     posterior.
  verblevel        - An integer specifiying the amount of information you want
                     this function to provide about what it is doing during runtime.
                     Options are:
                      0 - quiet, only show errors, warnings, and EEGLAB reports
                      1 - stuff anyone should probably know
                      2 - stuff you should know the first time you start working
                          with a data set {default value}
                      3 - stuff that might help you debug (show all
                          reports)

 Outputs:
  img              - Two-dimensional matrix (channel x time/frequency) 
                     representing the visualized raster.  This could be
                     useful for making your own personalized raster plot
                     (e.g., >> imagesc(img);).  Note that the matrix
                     includes rows for any blank rows separating groups of
                     channels (e.g., left electrodes from midline
                     electrodes).
         

 Global Variable:
   VERBLEVEL - Mass Univariate ERP Toolbox level of verbosity (i.e., tells functions
               how much to report about what they're doing during
               runtime) set by the optional function argument 'verblevel'

 Notes:
 -The printed/exported figure will have the same dimensions as the figure
 on the display.  Thus you can undo figure clutter by re-sizing it.

 -Some image viewers (e.g., Apple's Preview) may have trouble viewing 
 postscript raster images since they downsample the image to make the file 
 smaller, which blurs the lines.  Ghostview  and Adobe Illustrator should
 be able to view the files just fine.  If viewing the raster as a
 postscript file is producing problems, you can save the figure in jpg 
 format.

 -Assignment of electrode to left, midline, or right grouping of
 electrodes is based on the regress_results.chanlocs(x).theta coordinate.  Anterior to
 posterior organization of electrodes is based on regress_results.chanlocs(x).radius.

 Author:
 David Groppe
 Kutaslab, 3/2010

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % sig_raster() - Plots 2D (electrode x time/frequency) raster diagram of
0002 %                variables that show significant effects according to t-tests.
0003 %                Significant positive effects are represented
0004 %                with white squares (red if color is requested).
0005 %                Significant negative effects are represented with
0006 %                black squares (blue if color is requested).
0007 %
0008 % Usage:
0009 %  >> img=sig_raster_coefs(regress_results_or_fname,varargin)
0010 %
0011 % Required Inputs:
0012 %  regress_results  - A GND/GRP/specGND structure variable or the filename of
0013 %                      sucah a variable that has been saved to disk.
0014 %                      To create a GND variable from Kutaslab ERP files (e.g.,
0015 %                      *.nrm files) use avgs2GND.m.  To do the same from
0016 %                      EEGLAB *.set files use sets2GND.m.  To create a
0017 %                      a GRP structure use GNDs2GRP.m. See Mass Univariate ERP
0018 %                      Toolbox documentation for detailed information about the
0019 %                      format of GND and GRP variables. If you specifiy a filename
0020 %                      be sure to include the file's path, unless the file is
0021 %                      in the current working directory.
0022 %  test_id           - [integer] The index # of the t-test results
0023 %                      stored in the GND/GRP/specGND variable that you wish to visualize.
0024 %                      To see what test results are available, look at
0025 %                      the "t_tests" field of your variable (e.g., GND.t_tests)
0026 %                      or use the functions headinfo.m or headinfo_spec.m.
0027 %
0028 % Optional Inputs:
0029 %  x_ticks          - [vector] The times/frequencies you want marked with ticks
0030 %                     on the x-axis.  Note, because the EEG has been sampled
0031 %                     at discrete time points, not all times between the
0032 %                     minimum and maximum analyzed times/frequencies can be
0033 %                     used.  When a tick is requested that is not available,
0034 %                     the closest possible value is used. If not
0035 %                     specified, x_ticks are automatically chosen based
0036 %                     on the time/frequency range covered by the diagram.
0037 %                     This option has no effect if the t-test was
0038 %                     executed based on mean voltages/power within specified
0039 %                     time windows/frequency bands.
0040 %  fig_id           - [integer] The index # of the MATLAB figure in which
0041 %                     the diagram will be produced.  Useful for overwriting
0042 %                     old figures. {default: lowest unused index}
0043 %  use_color        - [integer] If non-zero, non-gray scale colors will be
0044 %                     used in the diagram. {default: 0}
0045 %  plot_vert_lines  - [integer] If non-zero, vertical lines separating all
0046 %                     time points included in the t-test will be
0047 %                     shown. If 0, the only vertical lines drawn will be
0048 %                     those that separate times/frequencies included in a test
0049 %                     from those not included. This option has no effect if
0050 %                     the t-test was executed based on mean voltage/power
0051 %                     within specified time windows. {default: 1}
0052 %  lr_sym           - [integer] If non-zero, left hemisphere electrodes are
0053 %                     plot from most anterior to most posterior and right
0054 %                     hemisphere electrodes are plot from most posterior to
0055 %                     most anterior.  This may make it easier to visualize
0056 %                     the degree of effect left-right symmetry.  If 0, all
0057 %                     electrodes are plot from most anterior to most
0058 %                     posterior.
0059 %  verblevel        - An integer specifiying the amount of information you want
0060 %                     this function to provide about what it is doing during runtime.
0061 %                     Options are:
0062 %                      0 - quiet, only show errors, warnings, and EEGLAB reports
0063 %                      1 - stuff anyone should probably know
0064 %                      2 - stuff you should know the first time you start working
0065 %                          with a data set {default value}
0066 %                      3 - stuff that might help you debug (show all
0067 %                          reports)
0068 %
0069 % Outputs:
0070 %  img              - Two-dimensional matrix (channel x time/frequency)
0071 %                     representing the visualized raster.  This could be
0072 %                     useful for making your own personalized raster plot
0073 %                     (e.g., >> imagesc(img);).  Note that the matrix
0074 %                     includes rows for any blank rows separating groups of
0075 %                     channels (e.g., left electrodes from midline
0076 %                     electrodes).
0077 %
0078 %
0079 % Global Variable:
0080 %   VERBLEVEL - Mass Univariate ERP Toolbox level of verbosity (i.e., tells functions
0081 %               how much to report about what they're doing during
0082 %               runtime) set by the optional function argument 'verblevel'
0083 %
0084 % Notes:
0085 % -The printed/exported figure will have the same dimensions as the figure
0086 % on the display.  Thus you can undo figure clutter by re-sizing it.
0087 %
0088 % -Some image viewers (e.g., Apple's Preview) may have trouble viewing
0089 % postscript raster images since they downsample the image to make the file
0090 % smaller, which blurs the lines.  Ghostview  and Adobe Illustrator should
0091 % be able to view the files just fine.  If viewing the raster as a
0092 % postscript file is producing problems, you can save the figure in jpg
0093 % format.
0094 %
0095 % -Assignment of electrode to left, midline, or right grouping of
0096 % electrodes is based on the regress_results.chanlocs(x).theta coordinate.  Anterior to
0097 % posterior organization of electrodes is based on regress_results.chanlocs(x).radius.
0098 %
0099 % Author:
0100 % David Groppe
0101 % Kutaslab, 3/2010
0102 
0103 %%%%%%%%%%%%%%%% REVISION LOG %%%%%%%%%%%%%%%%%
0104 % 3/27/2010-Comments revised to accommodate GRP variable
0105 %
0106 % 4/8/2010-chanloc theta values standardized to a range of +/- 180 (A2 had
0107 % a theta of 240 for some reason)
0108 %
0109 % 10/5/2010-channels lacking a theta coordinate are assigned a theta
0110 % coordinate of 0 and radius of 2
0111 %
0112 % 12/14/2010-Compatible with specGND variables now too
0113 %
0114 % 3/29/2011-Classifies any electrode with a radius of 0 as a midline
0115 % electrode
0116 
0117 %%%%%%%%%%%%%%%% FUTURE WORK %%%%%%%%%%%%%%%%%
0118 % -When you click on figure, box with time and electrode appear behind edges
0119 % of figure.  Fix this somehow?
0120 % -Make it possible to further exclude channels from plot?
0121 % -Make it possible to deal with overlapping time windows when mean time
0122 % windows are used?
0123 
0124 
0125 function img=sig_raster_dif_coefs(regress_results_or_fname,varargin)
0126 
0127 p=inputParser;
0128 p.addRequired('regress_results_or_fname',@(x) isstruct(x) || ischar(x)); 
0129 p.addParamValue('x_ticks',[],@isnumeric);
0130 p.addParamValue('predictor',[],@isnumeric);
0131 p.addParamValue('fig_id',[],@(x) isnumeric(x) && (length(x)==1));
0132 p.addParamValue('use_color',0,@(x) isnumeric(x) || ischar(x));
0133 p.addParamValue('plot_vert_lines',1,@(x) isnumeric(x) || ischar(x));
0134 p.addParamValue('lr_sym',0,@(x) isnumeric(x) || ischar(x));
0135 p.addParamValue('verblevel',[],@(x) isnumeric(x) && (length(x)==1));
0136 
0137 p.parse(regress_results_or_fname,varargin{:});
0138 
0139 % Manage VERBLEVEL
0140 if isempty(p.Results.verblevel),
0141     VERBLEVEL=2; %not global, just local
0142 else
0143     VERBLEVEL=p.Results.verblevel;
0144 end
0145 
0146 use_color=str2bool(p.Results.use_color);
0147 plot_vert_lines=str2bool(p.Results.plot_vert_lines);
0148 lr_sym=str2bool(p.Results.lr_sym);
0149 
0150 %Load "regress_results" variable
0151 if ischar(regress_results_or_fname),
0152     fprintf('Loading GND, GRP, or specGND struct variable from file %s.\n',regress_results_or_fname);
0153     load(regress_results_or_fname,'-MAT');
0154     if ~exist('regress_results','var')
0155         error('File %s does not contain a regress_results variable.',regress_results_or_fname);
0156     end
0157 else
0158    regress_results=regress_results_or_fname;
0159    clear regress_results_or_fname;
0160 end
0161 
0162 %FDR or permutation test correction for multiple comparisons
0163 if VERBLEVEL,
0164     fprintf('Correcting for multiple comparisons via FDR procedure: %s\n', ...
0165         regress_results.crctn_method);
0166 end
0167 
0168 fprintf('White squares indicate time point/electrode pairs in which Group %s has larger coefficients than Group %s.\n', ...
0169     regress_results.group_descr{1},regress_results.group_descr{2});
0170 fprintf('Black squares indicate time point/electrode pairs in which Group %s has larger coefficients than Group %s.\n', ...
0171     regress_results.group_descr{2},regress_results.group_descr{1});
0172 
0173 %Clean up code by copying some GND.t_tests variables to their own
0174 %variable
0175 use_bin=regress_results.bins;
0176 [n_use_chans, n_tpt, n_pred]=size(regress_results.mn_dif);
0177 use_tpts=linspace(regress_results.time_wind(1),regress_results.time_wind(2), ...
0178     n_tpt);
0179 pval=regress_results.p_cor;
0180 grands_t=regress_results.t_dif;
0181 use_chans=1:n_use_chans;
0182 
0183 if isempty(p.Results.predictor)
0184     for a=1:n_pred,
0185        fprintf('%d) %s\n',a,regress_results.predictor_names{a}); 
0186     end
0187     use_pred=input('Enter the number of the predictor you wish to plot: ');
0188 else
0189     use_pred=p.Results.predictor;
0190 end
0191 if use_pred>n_pred,
0192    error('This regress_results variable only has %d precitors in it.  You cannot plot #%d.', ...
0193        n_pred,use_pred);
0194 end
0195 
0196 % Standardize theta to -180<theta<=180 degrees
0197 for c=1:n_use_chans,
0198     theta=mod(regress_results.chanlocs(c).theta,360);
0199     if isempty(theta),
0200         watchit(sprintf('Channel #%d (Label: %s) does not have a theta coordinate. To produce raster, I''m assigning it temporary coordinate of: theta=0.',c,regress_results.chanlocs(c).labels));
0201         theta=0;
0202     end
0203     if theta>180,
0204         theta=theta-360;
0205     elseif theta<=-180,
0206         theta=360+theta;
0207     end
0208     regress_results.chanlocs(c).theta=theta;
0209     
0210     if isempty(regress_results.chanlocs(c).radius),
0211         regress_results.chanlocs(c).radius=2;
0212         watchit(sprintf('Channel #%d (Label: %s) does not have a radius coordinate. To produce raster, I''m assigning it temporary coordinate of: radius=2.',c,regress_results.chanlocs(c).labels));
0213     end
0214 end
0215 
0216 % Get midline electrodes from front to back
0217 midline=[];
0218 midline_dist=[]; %distance from MiCe
0219 for c=1:n_use_chans,
0220     theta=regress_results.chanlocs(c).theta;
0221     radius=regress_results.chanlocs(c).radius;
0222 
0223     if theta==0 || radius==0,
0224         midline=[midline c];
0225         midline_dist=[midline_dist radius];
0226     elseif theta==180,
0227         midline=[midline c];
0228         midline_dist=[midline_dist -radius];
0229     end
0230 end
0231 [midline_dist id]=sort(midline_dist,2,'descend');
0232 midline=midline(id);
0233 n_midline=length(midline);
0234 
0235 % Get left electrodes from front to back
0236 left=[];
0237 left_dist=[];
0238 for c=1:n_use_chans,
0239     %standardize theta to a range between +/-180
0240     theta=regress_results.chanlocs(c).theta;
0241     
0242     if (theta<0) && (theta>-180)
0243         if regress_results.chanlocs(c).radius,
0244             %make sure electrode isn't midline or right
0245             left=[left c];
0246             ang=90-abs(theta);
0247             dist=regress_results.chanlocs(c).radius*sin(ang*2*pi/360);
0248             left_dist=[left_dist dist];
0249         end
0250     end
0251 end
0252 [left_dist id]=sort(left_dist,2,'descend');
0253 left=left(id);
0254 n_left=length(left);
0255 
0256 % Get right electrodes from front to back
0257 right=[];
0258 right_dist=[];
0259 for c=1:n_use_chans,
0260     %standardize theta to a range between +/-180
0261     theta=regress_results.chanlocs(c).theta;
0262     
0263     if (theta>0) && (theta<180)
0264         if regress_results.chanlocs(c).radius,
0265             %make sure electrode isn't midline or right
0266             right=[right c];
0267             ang=90-abs(theta);
0268             dist=regress_results.chanlocs(c).radius*sin(ang*2*pi/360);
0269             right_dist=[right_dist dist];
0270         end
0271     end
0272 end
0273 % Make right electrodes back to front if requested
0274 if lr_sym,
0275    right_dist=-right_dist; 
0276 end
0277 [right_dist id]=sort(right_dist,2,'descend');
0278 right=right(id);
0279 n_right=length(right);
0280 
0281 % Compute time/frequency tick mark locations and labels
0282 %show_tpts=use_tpts(1):use_tpts(end); %show_tpts differs from use_tpts if multiple non-contiguous time windows were used
0283 %n_show_tpts=length(show_tpts);
0284 % Test was based on each time point in time window(s)/frequency band(s)
0285 srate=1/((use_tpts(2)-use_tpts(1))/1000);
0286 if isempty(p.Results.x_ticks),
0287     tm_range=use_tpts(end)-use_tpts(1);
0288     omag=orderofmag(tm_range);
0289     tm_step=round(omag*srate/1000);
0290     xtick=1:tm_step:n_tpt;
0291     xtick_lab=cell(1,length(xtick));
0292     for a=1:length(xtick),
0293         xtick_lab{a}=num2str(use_tpts(xtick(a)));
0294     end
0295 else
0296     tk_ct=0;
0297     xtick=zeros(1,length(p.Results.x_ticks));
0298     for t=p.Results.x_ticks,
0299         tk_ct=tk_ct+1;
0300         xtick(tk_ct)=find_tpt(use_tpts,t);
0301     end
0302     xtick=unique(xtick); %get rid of any redundant ticks
0303     xtick_lab=cell(1,length(xtick));
0304     for a=1:length(xtick),
0305         xtick_lab{a}=num2str(use_tpts(xtick(a)));
0306     end
0307 end
0308 
0309 fdr_crct=~strcmpi(regress_results.crctn_method,'perm');
0310 if VERBLEVEL,
0311     if fdr_crct,
0312         fprintf('q level of critical t-scores: %f.\n',regress_results.family_alpha);
0313     else
0314         fprintf('Estimated alpha level of critical t-scores: %f.\n',regress_results.perm_test_info.est_alpha);
0315     end
0316 end
0317 
0318 %Initialize variables
0319 n_blank=(n_right>0)+(n_left>0)+(n_midline>0)-1;
0320 if use_color,
0321     img=-.25*ones(n_use_chans+n_blank,n_tpt);%makes skipped lines grey (non-sig rectangles are white)
0322 else
0323     img=zeros(n_use_chans+n_blank,n_tpt); %makes skipped lines grey
0324 end
0325 chan_lab=cell(1,n_use_chans);
0326 dat.chan_lab=cell(1,n_use_chans+n_blank); %channel labels including empty cells for skipped lines
0327 %dat_chan_lab is needed to make sig_raster plot interactive
0328 
0329 %Get IDs of time points/frequencies used in perm test (some shown time points/frequencies may not
0330 %have been included
0331 used_tpt_ids=zeros(1,n_tpt);
0332 for a=1:n_tpt,
0333    if ismember(use_tpts(a),use_tpts),
0334       used_tpt_ids(a)=1; 
0335    end
0336 end
0337 used_tpt_ids=find(used_tpt_ids);
0338 
0339 %Construct raster for left electrodes
0340 ct=0;
0341 skipped=[];
0342 for a=left,
0343     ct=ct+1;
0344     elec_id=find(use_chans==a);
0345     if fdr_crct,
0346         img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<=regress_results.family_alpha).*sign(grands_t(elec_id,:,use_pred));
0347     else
0348         img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<regress_results.perm_test_info.est_alpha).*sign(grands_t(elec_id,:,use_pred));
0349     end
0350     chan_lab{ct}=regress_results.chanlocs(use_chans(elec_id)).labels;
0351     dat.chan_lab{ct}=regress_results.chanlocs(use_chans(elec_id)).labels;
0352 end
0353 
0354 if ~isempty(midline),
0355     if ct>0,
0356         %skip line to separate left and midline electrodes
0357         ct=ct+1;
0358         skipped=ct;
0359     end
0360     for a=midline,
0361         ct=ct+1;
0362         elec_id=find(use_chans==a);
0363         if fdr_crct,
0364             img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<=regress_results.family_alpha).*sign(grands_t(elec_id,:,use_pred));
0365         else
0366             img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<regress_results.perm_test_info.est_alpha).*sign(grands_t(elec_id,:,use_pred));
0367         end
0368         chan_lab{ct-length(skipped)}=regress_results.chanlocs(use_chans(elec_id)).labels;
0369         dat.chan_lab{ct}=regress_results.chanlocs(use_chans(elec_id)).labels;
0370     end
0371 end
0372 
0373 if ~isempty(right),
0374     if ct>0,
0375         %skip line to separate right from left or midline electrodes
0376         ct=ct+1;
0377         skipped=[skipped ct];
0378     end
0379     for a=right,
0380         ct=ct+1;
0381         elec_id=find(use_chans==a);
0382         if fdr_crct,
0383             img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<=regress_results.family_alpha).*sign(grands_t(elec_id,:,use_pred));
0384         else
0385             img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<regress_results.perm_test_info.est_alpha).*sign(grands_t(elec_id,:,use_pred));
0386         end
0387         chan_lab{ct-length(skipped)}=regress_results.chanlocs(use_chans(elec_id)).labels;
0388         dat.chan_lab{ct}=regress_results.chanlocs(use_chans(elec_id)).labels;
0389     end
0390 end
0391 
0392 
0393 if isempty(p.Results.fig_id)
0394     fig_h=figure;
0395 else
0396     fig_h=figure(p.Results.fig_id); clf;
0397 end
0398 % if isfield(GND,'bin_info')
0399 %     set(fig_h,'name',['Bin ' int2str(use_bin) ' [' GND.bin_info(use_bin).bindesc ']'],'paperpositionmode','auto');
0400 % else
0401 %     set(fig_h,'name',['Bin ' int2str(use_bin) ' [' GND.bindesc{use_bin} ']'],'paperpositionmode','auto');
0402 % end
0403 %setting paperpositionmode to 'auto' means that if the figure is manually
0404 %resized, the printed version of the figure will reflect the whatever the
0405 %shown size was (at the time of printing)
0406 
0407 if use_color,
0408     %skipped rows/columns=grey, nonsig=white, +sig=red, -sig=blue
0409     h_img=imagesc(img,[-1 1]);colormap([0 0 1; .5 .5 .5; 1 1 1; 1 0 0]);
0410 else
0411     h_img=imagesc(img,[-1 1]);colormap([0 0 0; .6 .6 .6; 1 1 1]);
0412 end
0413 bdfcn=['Cp = get(gca,''CurrentPoint''); ' ...
0414     'Xp=Cp(2,1);', ...
0415     'Yp=Cp(2,2);', ...
0416     'dat=get(gcbo,''userdata'');', ...
0417     'ht=text(Xp,Yp,[int2str(dat.times(round(Xp))) '' ms, '' dat.chan_lab{round(Yp)}]);' ...
0418     'set(ht,''backgroundcolor'',''w'',''horizontalalignment'',''center'',''verticalalignment'',''middle'',''buttondownfcn'',''delete(gcbo);'');'];
0419 dat.times=use_tpts; %dat.chan_lab has been set above
0420 set(h_img,'buttondownfcn',bdfcn,'userdata',dat);
0421 set(gca,'xtick',xtick,'xticklabel',xtick_lab,'tickdir','out');
0422 
0423 set(gca,'ytick',setdiff(1:(n_use_chans+n_blank),skipped),'yticklabel',chan_lab,'box','off');
0424 
0425 h=xlabel('Time (ms)');
0426 set(h,'fontsize',12,'fontweight','bold');
0427 
0428 h=ylabel('Electrode');
0429 set(h,'fontsize',12,'fontweight','bold');
0430 
0431 %
0432 % if isfield(GND,'bin_info')
0433 %     h=title(['Bin ' int2str(use_bin) ': ' GND.bin_info(use_bin).bindesc]);
0434 % else
0435 
0436 % end
0437 h=title([regress_results.predictor_names{use_pred} ', Bin(s) ' num2str(regress_results.bins)]);
0438 set(h,'interpreter','none','fontsize',14,'fontweight','bold');
0439 
0440 hold on;
0441 v=axis;
0442 %rightmost vertical line to cover up weird white lip that peeks out from
0443 %under imagesc
0444 h=plot([1 1]*v(2),v(3:4));
0445 set(h,'color',[1 1 1]*.6);
0446 
0447 %horizontal lines
0448 %show_times=GND.time_pts(use_tpts);
0449 %start_tpt=find_tpt(GND.t_tests(test_id).time_wind(a,1),use_tpts);
0450 %stop_tpt=find_tpt(GND.t_tests(test_id).time_wind(a,2),use_tpts);
0451 %start_tpt=use_tpts(1);
0452 %stop_tpt=use_tpts(end);
0453 v=axis;
0454 start_tpt=v(1);
0455 stop_tpt=v(2);
0456 for c=0:(n_use_chans+n_blank-1),
0457     h=plot([start_tpt-.5 stop_tpt+.5],[1 1]*c+.5);
0458     if ismember(c+1,skipped) || ismember(c,skipped),
0459         %make lines near boundaries different??  currently not used
0460         set(h,'color',[0 0 0],'buttondownfcn',bdfcn,'userdata',dat);
0461     else
0462         set(h,'color',[0 0 0],'buttondownfcn',bdfcn,'userdata',dat);
0463     end
0464 end
0465 
0466 %vertical lines
0467 if plot_vert_lines
0468     for t=1:(n_tpt),
0469         if ismember(use_tpts(t),use_tpts),
0470             if ismember(t+1,xtick) || ismember(t,xtick),
0471                 %draw vertical lines at time tick marks differently??
0472                 %currently option isn't used
0473                 c=[0 0 0];
0474             else
0475                 c=[0 0 0];
0476             end
0477             if isempty(skipped),
0478                 h=plot([1 1]*t+.5,v(3:4));
0479                 set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat);
0480                 if t==1 || ~ismember(use_tpts(t-1),use_tpts),
0481                     h=plot([1 1]*t-.5,v(3:4));
0482                     set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat);
0483                 end
0484             else
0485                 h=plot([1 1]*t+.5,[v(3) skipped(1)-.5]);
0486                 set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat);
0487                 if length(skipped)==2,
0488                     h=plot([1 1]*t+.5,[skipped(1)+.5 skipped(2)-.5]);
0489                     set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat);
0490                 end
0491                 h=plot([1 1]*t+.5,[skipped(end)+.5 v(4)]);
0492                 set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat);
0493                 
0494                 if t==1 || ~ismember(use_tpts(t-1),use_tpts),
0495                     h=plot([1 1]*t-.5,[v(3) skipped(1)-.5]);
0496                     set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat);
0497                     if length(skipped)==2,
0498                         h=plot([1 1]*t-.5,[skipped(1)+.5 skipped(2)-.5]);
0499                         set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat);
0500                     end
0501                     h=plot([1 1]*t-.5,[skipped(end)+.5 v(4)]);
0502                     set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat);
0503                 end
0504             end
0505         end
0506     end
0507 end
0508 
0509 
0510 %
0511 %% %%%%%%%%%%%%%%%%%%%%% function orderofmag() %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0512 %
0513 function ord=orderofmag(val)
0514 %function ord=orderofmag(val)
0515 %
0516 % Returns the order of magnitude of the value of 'val' in multiples of 10
0517 % (e.g., 10^-1, 10^0, 10^1, 10^2, etc ...)
0518 % used for computing erpimage trial axis tick labels as an alternative for
0519 % plotting sorting variable
0520 
0521 val=abs(val);
0522 if val>=1
0523     ord=1;
0524     val=floor(val/10);
0525     while val>=1,
0526         ord=ord*10;
0527         val=floor(val/10);
0528     end
0529     return;
0530 else
0531     ord=1/10;
0532     val=val*10;
0533     while val<1,
0534         ord=ord/10;
0535         val=val*10;
0536     end
0537     return;
0538 end
0539 
0540 
0541 %
0542 %% %%%%%%%%%%%%%%%%%%%%% function str2bool() %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0543 %
0544 function bool=str2bool(str)
0545 %function bool=str2bool(str)
0546 
0547 if ischar(str),
0548     if strcmpi(str,'yes') || strcmpi(str,'y')
0549         bool=1;
0550     else
0551         bool=0;
0552     end
0553 else
0554    bool=str; 
0555 end

Generated on Tue 10-May-2016 16:37:45 by m2html © 2005