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(regress_results,test_id,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
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(regress_results,test_id,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_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 %Clean up code by copying some GND.t_tests variables to their own 0169 %variable 0170 use_bin=regress_results.bins; 0171 [n_use_chans, n_tpt, n_pred]=size(regress_results.mn_coefs); 0172 use_tpts=linspace(regress_results.time_wind(1),regress_results.time_wind(2), ... 0173 n_tpt); 0174 pval=regress_results.p_coefs_cor; 0175 grands_t=regress_results.mn_coefs; 0176 use_chans=1:n_use_chans; 0177 0178 if isempty(p.Results.predictor) 0179 for a=1:n_pred, 0180 fprintf('%d) %s\n',a,regress_results.predictor_names{a}); 0181 end 0182 use_pred=input('Enter the number of the predictor you wish to plot: '); 0183 else 0184 use_pred=p.Results.predictor; 0185 end 0186 if use_pred>n_pred, 0187 error('This regress_results variable only has %d precitors in it. You cannot plot #%d.', ... 0188 n_pred,use_pred); 0189 end 0190 0191 % Standardize theta to -180<theta<=180 degrees 0192 for c=1:n_use_chans, 0193 theta=mod(regress_results.chanlocs(c).theta,360); 0194 if isempty(theta), 0195 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)); 0196 theta=0; 0197 end 0198 if theta>180, 0199 theta=theta-360; 0200 elseif theta<=-180, 0201 theta=360+theta; 0202 end 0203 regress_results.chanlocs(c).theta=theta; 0204 0205 if isempty(regress_results.chanlocs(c).radius), 0206 regress_results.chanlocs(c).radius=2; 0207 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)); 0208 end 0209 end 0210 0211 % Get midline electrodes from front to back 0212 midline=[]; 0213 midline_dist=[]; %distance from MiCe 0214 for c=1:n_use_chans, 0215 theta=regress_results.chanlocs(c).theta; 0216 radius=regress_results.chanlocs(c).radius; 0217 0218 if theta==0 || radius==0, 0219 midline=[midline c]; 0220 midline_dist=[midline_dist radius]; 0221 elseif theta==180, 0222 midline=[midline c]; 0223 midline_dist=[midline_dist -radius]; 0224 end 0225 end 0226 [midline_dist id]=sort(midline_dist,2,'descend'); 0227 midline=midline(id); 0228 n_midline=length(midline); 0229 0230 % Get left electrodes from front to back 0231 left=[]; 0232 left_dist=[]; 0233 for c=1:n_use_chans, 0234 %standardize theta to a range between +/-180 0235 theta=regress_results.chanlocs(c).theta; 0236 0237 if (theta<0) && (theta>-180) 0238 if regress_results.chanlocs(c).radius, 0239 %make sure electrode isn't midline or right 0240 left=[left c]; 0241 ang=90-abs(theta); 0242 dist=regress_results.chanlocs(c).radius*sin(ang*2*pi/360); 0243 left_dist=[left_dist dist]; 0244 end 0245 end 0246 end 0247 [left_dist id]=sort(left_dist,2,'descend'); 0248 left=left(id); 0249 n_left=length(left); 0250 0251 % Get right electrodes from front to back 0252 right=[]; 0253 right_dist=[]; 0254 for c=1:n_use_chans, 0255 %standardize theta to a range between +/-180 0256 theta=regress_results.chanlocs(c).theta; 0257 0258 if (theta>0) && (theta<180) 0259 if regress_results.chanlocs(c).radius, 0260 %make sure electrode isn't midline or right 0261 right=[right c]; 0262 ang=90-abs(theta); 0263 dist=regress_results.chanlocs(c).radius*sin(ang*2*pi/360); 0264 right_dist=[right_dist dist]; 0265 end 0266 end 0267 end 0268 % Make right electrodes back to front if requested 0269 if lr_sym, 0270 right_dist=-right_dist; 0271 end 0272 [right_dist id]=sort(right_dist,2,'descend'); 0273 right=right(id); 0274 n_right=length(right); 0275 0276 % Compute time/frequency tick mark locations and labels 0277 %show_tpts=use_tpts(1):use_tpts(end); %show_tpts differs from use_tpts if multiple non-contiguous time windows were used 0278 %n_show_tpts=length(show_tpts); 0279 % Test was based on each time point in time window(s)/frequency band(s) 0280 srate=1/((use_tpts(2)-use_tpts(1))/1000); 0281 if isempty(p.Results.x_ticks), 0282 tm_range=use_tpts(end)-use_tpts(1); 0283 omag=orderofmag(tm_range); 0284 tm_step=round(omag*srate/1000); 0285 xtick=1:tm_step:n_tpt; 0286 xtick_lab=cell(1,length(xtick)); 0287 for a=1:length(xtick), 0288 xtick_lab{a}=num2str(use_tpts(xtick(a))); 0289 end 0290 else 0291 tk_ct=0; 0292 xtick=zeros(1,length(p.Results.x_ticks)); 0293 for t=p.Results.x_ticks, 0294 tk_ct=tk_ct+1; 0295 xtick(tk_ct)=find_tpt(use_tpts,t); 0296 end 0297 xtick=unique(xtick); %get rid of any redundant ticks 0298 xtick_lab=cell(1,length(xtick)); 0299 for a=1:length(xtick), 0300 xtick_lab{a}=num2str(use_tpts(xtick(a))); 0301 end 0302 end 0303 0304 fdr_crct=~strcmpi(regress_results.crctn_method,'perm'); 0305 if VERBLEVEL, 0306 if fdr_crct, 0307 fprintf('q level of critical t-scores: %f.\n',regress_results.family_alpha); 0308 else 0309 fprintf('Estimated alpha level of critical t-scores: %f.\n',regress_results.perm_test_info.est_alpha); 0310 end 0311 end 0312 0313 %Initialize variables 0314 n_blank=(n_right>0)+(n_left>0)+(n_midline>0)-1; 0315 if use_color, 0316 img=-.25*ones(n_use_chans+n_blank,n_tpt);%makes skipped lines grey (non-sig rectangles are white) 0317 else 0318 img=zeros(n_use_chans+n_blank,n_tpt); %makes skipped lines grey 0319 end 0320 chan_lab=cell(1,n_use_chans); 0321 dat.chan_lab=cell(1,n_use_chans+n_blank); %channel labels including empty cells for skipped lines 0322 %dat_chan_lab is needed to make sig_raster plot interactive 0323 0324 %Get IDs of time points/frequencies used in perm test (some shown time points/frequencies may not 0325 %have been included 0326 used_tpt_ids=zeros(1,n_tpt); 0327 for a=1:n_tpt, 0328 if ismember(use_tpts(a),use_tpts), 0329 used_tpt_ids(a)=1; 0330 end 0331 end 0332 used_tpt_ids=find(used_tpt_ids); 0333 0334 %Construct raster for left electrodes 0335 ct=0; 0336 skipped=[]; 0337 for a=left, 0338 ct=ct+1; 0339 elec_id=find(use_chans==a); 0340 if fdr_crct, 0341 img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<=regress_results.family_alpha).*sign(grands_t(elec_id,:,use_pred)); 0342 else 0343 img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<regress_results.perm_test_info.est_alpha).*sign(grands_t(elec_id,:,use_pred)); 0344 end 0345 chan_lab{ct}=regress_results.chanlocs(use_chans(elec_id)).labels; 0346 dat.chan_lab{ct}=regress_results.chanlocs(use_chans(elec_id)).labels; 0347 end 0348 0349 if ~isempty(midline), 0350 if ct>0, 0351 %skip line to separate left and midline electrodes 0352 ct=ct+1; 0353 skipped=ct; 0354 end 0355 for a=midline, 0356 ct=ct+1; 0357 elec_id=find(use_chans==a); 0358 if fdr_crct, 0359 img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<=regress_results.family_alpha).*sign(grands_t(elec_id,:,use_pred)); 0360 else 0361 img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<regress_results.perm_test_info.est_alpha).*sign(grands_t(elec_id,:,use_pred)); 0362 end 0363 chan_lab{ct-length(skipped)}=regress_results.chanlocs(use_chans(elec_id)).labels; 0364 dat.chan_lab{ct}=regress_results.chanlocs(use_chans(elec_id)).labels; 0365 end 0366 end 0367 0368 if ~isempty(right), 0369 if ct>0, 0370 %skip line to separate right from left or midline electrodes 0371 ct=ct+1; 0372 skipped=[skipped ct]; 0373 end 0374 for a=right, 0375 ct=ct+1; 0376 elec_id=find(use_chans==a); 0377 if fdr_crct, 0378 img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<=regress_results.family_alpha).*sign(grands_t(elec_id,:,use_pred)); 0379 else 0380 img(ct,used_tpt_ids)=(pval(elec_id,:,use_pred)<regress_results.perm_test_info.est_alpha).*sign(grands_t(elec_id,:,use_pred)); 0381 end 0382 chan_lab{ct-length(skipped)}=regress_results.chanlocs(use_chans(elec_id)).labels; 0383 dat.chan_lab{ct}=regress_results.chanlocs(use_chans(elec_id)).labels; 0384 end 0385 end 0386 0387 0388 if isempty(p.Results.fig_id) 0389 fig_h=figure; 0390 else 0391 fig_h=figure(p.Results.fig_id); clf; 0392 end 0393 % if isfield(GND,'bin_info') 0394 % set(fig_h,'name',['Bin ' int2str(use_bin) ' [' GND.bin_info(use_bin).bindesc ']'],'paperpositionmode','auto'); 0395 % else 0396 % set(fig_h,'name',['Bin ' int2str(use_bin) ' [' GND.bindesc{use_bin} ']'],'paperpositionmode','auto'); 0397 % end 0398 %setting paperpositionmode to 'auto' means that if the figure is manually 0399 %resized, the printed version of the figure will reflect the whatever the 0400 %shown size was (at the time of printing) 0401 0402 if use_color, 0403 %skipped rows/columns=grey, nonsig=white, +sig=red, -sig=blue 0404 h_img=imagesc(img,[-1 1]);colormap([0 0 1; .5 .5 .5; 1 1 1; 1 0 0]); 0405 else 0406 h_img=imagesc(img,[-1 1]);colormap([0 0 0; .6 .6 .6; 1 1 1]); 0407 end 0408 bdfcn=['Cp = get(gca,''CurrentPoint''); ' ... 0409 'Xp=Cp(2,1);', ... 0410 'Yp=Cp(2,2);', ... 0411 'dat=get(gcbo,''userdata'');', ... 0412 'ht=text(Xp,Yp,[int2str(dat.times(round(Xp))) '' ms, '' dat.chan_lab{round(Yp)}]);' ... 0413 'set(ht,''backgroundcolor'',''w'',''horizontalalignment'',''center'',''verticalalignment'',''middle'',''buttondownfcn'',''delete(gcbo);'');']; 0414 dat.times=use_tpts; %dat.chan_lab has been set above 0415 set(h_img,'buttondownfcn',bdfcn,'userdata',dat); 0416 set(gca,'xtick',xtick,'xticklabel',xtick_lab,'tickdir','out'); 0417 0418 set(gca,'ytick',setdiff(1:(n_use_chans+n_blank),skipped),'yticklabel',chan_lab,'box','off'); 0419 0420 h=xlabel('Time (ms)'); 0421 set(h,'fontsize',12,'fontweight','bold'); 0422 0423 h=ylabel('Electrode'); 0424 set(h,'fontsize',12,'fontweight','bold'); 0425 0426 % 0427 % if isfield(GND,'bin_info') 0428 % h=title(['Bin ' int2str(use_bin) ': ' GND.bin_info(use_bin).bindesc]); 0429 % else 0430 0431 % end 0432 h=title([regress_results.predictor_names{use_pred} ', Bin(s) ' num2str(regress_results.bins)]); 0433 set(h,'interpreter','none','fontsize',14,'fontweight','bold'); 0434 0435 hold on; 0436 v=axis; 0437 %rightmost vertical line to cover up weird white lip that peeks out from 0438 %under imagesc 0439 h=plot([1 1]*v(2),v(3:4)); 0440 set(h,'color',[1 1 1]*.6); 0441 0442 %horizontal lines 0443 %show_times=GND.time_pts(use_tpts); 0444 %start_tpt=find_tpt(GND.t_tests(test_id).time_wind(a,1),use_tpts); 0445 %stop_tpt=find_tpt(GND.t_tests(test_id).time_wind(a,2),use_tpts); 0446 %start_tpt=use_tpts(1); 0447 %stop_tpt=use_tpts(end); 0448 v=axis; 0449 start_tpt=v(1); 0450 stop_tpt=v(2); 0451 for c=0:(n_use_chans+n_blank-1), 0452 h=plot([start_tpt-.5 stop_tpt+.5],[1 1]*c+.5); 0453 if ismember(c+1,skipped) || ismember(c,skipped), 0454 %make lines near boundaries different?? currently not used 0455 set(h,'color',[0 0 0],'buttondownfcn',bdfcn,'userdata',dat); 0456 else 0457 set(h,'color',[0 0 0],'buttondownfcn',bdfcn,'userdata',dat); 0458 end 0459 end 0460 0461 %vertical lines 0462 if plot_vert_lines 0463 for t=1:(n_tpt), 0464 if ismember(use_tpts(t),use_tpts), 0465 if ismember(t+1,xtick) || ismember(t,xtick), 0466 %draw vertical lines at time tick marks differently?? 0467 %currently option isn't used 0468 c=[0 0 0]; 0469 else 0470 c=[0 0 0]; 0471 end 0472 if isempty(skipped), 0473 h=plot([1 1]*t+.5,v(3:4)); 0474 set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat); 0475 if t==1 || ~ismember(use_tpts(t-1),use_tpts), 0476 h=plot([1 1]*t-.5,v(3:4)); 0477 set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat); 0478 end 0479 else 0480 h=plot([1 1]*t+.5,[v(3) skipped(1)-.5]); 0481 set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat); 0482 if length(skipped)==2, 0483 h=plot([1 1]*t+.5,[skipped(1)+.5 skipped(2)-.5]); 0484 set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat); 0485 end 0486 h=plot([1 1]*t+.5,[skipped(end)+.5 v(4)]); 0487 set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat); 0488 0489 if t==1 || ~ismember(use_tpts(t-1),use_tpts), 0490 h=plot([1 1]*t-.5,[v(3) skipped(1)-.5]); 0491 set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat); 0492 if length(skipped)==2, 0493 h=plot([1 1]*t-.5,[skipped(1)+.5 skipped(2)-.5]); 0494 set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat); 0495 end 0496 h=plot([1 1]*t-.5,[skipped(end)+.5 v(4)]); 0497 set(h,'color',c,'buttondownfcn',bdfcn,'userdata',dat); 0498 end 0499 end 0500 end 0501 end 0502 end 0503 0504 0505 % 0506 %% %%%%%%%%%%%%%%%%%%%%% function orderofmag() %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0507 % 0508 function ord=orderofmag(val) 0509 %function ord=orderofmag(val) 0510 % 0511 % Returns the order of magnitude of the value of 'val' in multiples of 10 0512 % (e.g., 10^-1, 10^0, 10^1, 10^2, etc ...) 0513 % used for computing erpimage trial axis tick labels as an alternative for 0514 % plotting sorting variable 0515 0516 val=abs(val); 0517 if val>=1 0518 ord=1; 0519 val=floor(val/10); 0520 while val>=1, 0521 ord=ord*10; 0522 val=floor(val/10); 0523 end 0524 return; 0525 else 0526 ord=1/10; 0527 val=val*10; 0528 while val<1, 0529 ord=ord/10; 0530 val=val*10; 0531 end 0532 return; 0533 end 0534 0535 0536 % 0537 %% %%%%%%%%%%%%%%%%%%%%% function str2bool() %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0538 % 0539 function bool=str2bool(str) 0540 %function bool=str2bool(str) 0541 0542 if ischar(str), 0543 if strcmpi(str,'yes') || strcmpi(str,'y') 0544 bool=1; 0545 else 0546 bool=0; 0547 end 0548 else 0549 bool=str; 0550 end