<div dir="ltr">Dear Jaime,<div><br></div><div>I agree with Allan though I always use 'imagesc()' with 'axis xy'. </div><div>I also agree with Steve, it's a good idea to start from what you get from eegh() because at least you can start from the working code. </div><div><br></div><div>In EEGLAB erpimage() function (which is one of the oldest functions and written by Scott in late 90's; which tend to mean that it should be well-equipped with options), you can find a long help. Type 'help erpimage' and you'll find the following. Read it carefully, try one option at a time, repeat this process and you'll eventually get the plot you want.</div><div><br></div><div>Makoto </div><div><br></div><div>%%%%%%%%%%%%%%%%%</div><div><div> >> figure; [outdata,outvar,outtrials,limits,axhndls, ...</div><div> erp,amps,cohers,cohsig,ampsig,outamps,...</div><div> phsangls,phsamp,sortidx,erpsig] ...</div><div> = erpimage(data,sortvar,times,'title',avewidth,decimate,...</div><div> 'key', 'val', ...); % use options</div></div><div><br></div><div><div> Required input:</div><div> data = [vector or matrix] Single-channel input data to image.</div><div> Formats (1,frames*trials) or (frames,trials)</div><div> </div><div> Optional ordered inputs {with defaults}:</div><div> </div><div> sortvar = [vector | []] Variable to sort epochs on (length(sortvar) = nepochs)</div><div> Example: sortvar may by subject response time in each epoch (in ms)</div><div> {default|[]: plot in input order}</div><div> times = [vector | []] vector of latencies (in ms) for each epoch time point.</div><div> Else [startms ntimes srate] = [start latency (ms), time points</div><div> (=frames) per epoch, sampling rate (Hz)]. Else [] -> 0:nframes-1</div><div> {default: []}</div><div> 'title' = ['string'] Plot title {default: none}</div><div> avewidth = [positive scalar (may be non-integer)]. If avg_type is set to 'boxcar'</div><div> (the default), this is the number of trials used to smooth</div><div> (vertically) with a moving-average. If avg_type is set to</div><div> 'Gaussian,' this is the standard deviation (in units of</div><div> trials) of the Gaussian window used to smooth (vertically)</div><div> with a moving-average. Gaussian window extends three</div><div> standard deviations below and three standard deviations above window</div><div> center (trials beyond window are not incorporated into average). {default: no</div><div> smoothing}</div><div> decimate = Factor to decimate|interpolate ntrials by (may be non-integer)</div><div> Else, if this is large (> sqrt(ntrials)), output this many epochs.</div><div> {default|0->1}</div><div> </div><div> Optional unordered 'keyword',argument pairs:</div><div> </div><div> Re-align data epochs:</div><div> 'align' = [latency] Time-lock data to sortvar. Plot sortvar at given latency</div><div> (in ms). Else Inf -> plot sortvar at median sortvar latency</div><div> {default: do not align}</div><div> 'timewarp' = {[events], [warpms], {colors}} Time warp ERP, amplitude and phase</div><div> time-courses before smoothing. 'events' is a matrix whose columns</div><div> specify the latencies (in ms) at which a series of successive events occur</div><div> in each trial. 'warpms' is an optional vector of latencies (in ms) to which</div><div> the series of events should be time locked. (Note: Epoch start and end</div><div> should not be declared as events or warpms}. If 'warpms' is absent or [],</div><div> the median of each 'events' column will be used. {colors} contains a</div><div> list of Matlab linestyles to use for vertical lines marking the occurrence</div><div> of the time warped events. If '', no line will be drawn for this event</div><div> column. If fewer colors than event columns, cycles through the given color</div><div> labels. Note: Not compatible with 'vert' (below).</div><div> 'renorm' = ['yes'|'no'| formula] Normalize sorting variable to epoch</div><div> latency range and plot. 'yes'= autoscale. formula must be a linear</div><div> transformation in the format 'a*x+b'</div><div> Example of formula: '3*x+2'. {default: 'no'}</div><div> If sorting by string values like event type, suggested formulas for:</div><div> letter string: '1000*x', number string: '30000*x-1500'</div><div> 'noplot' = ['on'|'off'] Do not plot sortvar {default: Plot sortvar if in times range}</div><div> 'NoShow' = ['on'|'off'] Do not plot erpimage, simply return outputs {default: 'off'}</div><div> </div><div> Sort data epochs:</div><div> 'nosort' = ['on'|'off'] Do not sort data epochs. {default: Sort data epochs by</div><div> sortvar (see sortvar input above)}</div><div> 'replace_ties' = ['yes'|'no'] Replace trials with the same value of</div><div> sortvar with the mean of those trials. Only works if sorting trials</div><div> by sortvar. {default: 'no'}</div><div> 'valsort' = [startms endms direction] Sort data on (mean) value</div><div> between startms and (optional) endms. Direction is 1 or -1.</div><div> If -1, plot max-value epoch at bottom {default: sort on sortvar}</div><div> 'phasesort' = [ms_center prct freq maxfreq topphase] Sort epochs by phase in</div><div> a 3-cycle window centered at latency ms_center (ms).</div><div> Percentile (prct) in range [0,100] gives percent of trials</div><div> to reject for (too) low amplitude. Else, if in range [-100,0],</div><div> percent of trials to reject for (too) high amplitude;</div><div> freq (Hz) is the phase-sorting frequency. With optional</div><div> maxfreq, sort by phase at freq of max power in the data in</div><div> the range [freq,maxfreq] (Note: 'phasesort' arg freq overrides</div><div> the frequency specified in 'coher'). With optional topphase,</div><div> sort by phase, putting topphase (degrees, in range [-180,180])</div><div> at the top of the image. Note: 'phasesort' now uses circular</div><div> smoothing. Use 'cycles' (below) for wavelet length.</div><div> {default: [0 25 8 13 180]}</div><div> 'ampsort' = [center_ms prcnt freq maxfreq] Sort epochs by amplitude.</div><div> (See 'phasesort' above). If ms_center is 'Inf', then sorting</div><div> is by mean power across the time window specified by 'sortwin'</div><div> below. If third arg, freq, is < 0, sort by mean power in the range</div><div> [ abs(freq) maxfreq ].</div><div> 'sortwin' = [start_ms end_ms] If center_ms == Inf in 'ampsort' arg (above), sorts</div><div> by mean amplitude across window centers shifted from start_ms</div><div> to end_ms by 10 ms.</div><div> 'showwin' = ['on'|'off'] Show sorting window behind ERP trace. {default: 'off'}</div><div> </div><div> Plot time-varying spectral amplitude instead of potential:</div><div> 'plotamps' = ['on'|'off'] Image amplitudes at each trial and latency instead of </div><div> potential values. Note: Currently requires 'coher' (below) with alpha signif.</div><div> Use 'cycles' (see below) > (its default) 3 for better frequency specificity,</div><div> {default: plot potential, not amplitudes, with no minimum}. The average power</div><div> (in log space) before time 0 is automatically removed. Note that the </div><div> 'baseline' parameter has no effect on 'plotamps'. Instead use</div><div> change "baselinedb" or "basedB" in the 'limits' parameter. By default</div><div> the baseline is removed before time 0.</div><div> </div><div> Specify plot parameters:</div><div> 'limits' = [lotime hitime minerp maxerp lodB hidB locoher hicoher basedB]</div><div> Plot axes limits. Can use NaN (or nan, but not Nan) for missing items</div><div> and omit late items. Use last input, basedB, to set the</div><div> baseline dB amplitude in 'plotamps' plots {default: from data}</div><div> 'sortvar_limits' = [min max] minimum and maximum sorting variable</div><div> values to image. This only affects visualization of</div><div> ERPimage and ERPs (not smoothing). Cannot be used</div><div> if sorting by any factor besides sortvar (e.g.,</div><div> phase).</div><div> 'signif' = [lo_dB, hi_dB, coher_signif_level] Use precomputed significance</div><div> thresholds (as from outputs ampsig, cohsig) to save time. {default: none}</div><div> 'caxis' = [lo hi] Set color axis limits. Else [fraction] Set caxis limits at</div><div> (+/-)fraction*max(abs(data)) {default: symmetrical in dB, based on data limits}</div><div> </div><div> Add epoch-mean ERP to plot:</div><div> 'erp' = ['on'|'off'|1|2|3|4] Plot ERP time average of the trials below the</div><div> image. If 'on' or 1, a single ERP (the mean of all trials) is shown. If 2,</div><div> two ERPs (super and sub median trials) are shown. If 3, the trials are split into</div><div> tertiles and their three ERPs are shown. If 4, the trials are split into quartiles</div><div> and four ERPs are shown. Note, if you want negative voltage plotted up, change YDIR</div><div> to -1 in icadefs.m. If 'erpalpha' option is used, any values of 'erp' greater than</div><div> 1 will be reset to 1. {default no ERP plotted}</div><div> 'erpalpha' = [alpha] Visualizes two-sided significance threshold (i.e., a two-tailed test) for the</div><div> null hypothesis of a zero mean, symmetric distribution (range: [.001 0.1]). Thresholds</div><div> are determined via a permutation test. Requires 'erp' to be a value other than 'off'.</div><div> If 'erp' is set to a value greater than 1, it is reset to 1 to increase plot readability.</div><div> {default: no alpha significance thresholds plotted}</div><div> 'erpstd' = ['on'|'off'] Plot ERP +/- stdev. Requires 'erp' {default: no std. dev. plotted}</div><div> 'erp_grid' = If 'erp_grid' is added as an option voltage axis dashed grid lines will be</div><div> added to the ERP plot to facilitate judging ERP amplitude</div><div> 'rmerp' = ['on'|'off'] Subtract the average ERP from each trial before processing {default: no}</div><div> </div><div> Add time/frequency information:</div><div> 'coher' = [freq] Plot ERP average plus mean amplitude & coherence at freq (Hz)</div><div> Else [minfrq maxfrq] = same, but select frequency with max power in</div><div> given range. (Note: the 'phasesort' freq (above) overwrites these</div><div> parameters). Else [minfrq maxfrq alpha] = plot coher. signif. level line</div><div> at probability alpha (range: [0,0.1]) {default: no coher, no alpha level}</div><div> 'srate' = [freq] Specify the data sampling rate in Hz for amp/coher (if not</div><div> implicit in third arg, times) {default: as defined in icadefs.m}</div><div> 'cycles' = [float] Number of cycles in the wavelet time/frequency decomposition {default: 3}</div><div> </div><div> Add plot features:</div><div> 'cbar' = ['on'|'off'] Plot color bar to right of ERP-image {default no}</div><div> 'cbar_title' = [string] The title for the color bar (e.g., '\muV' for</div><div> microvolts).</div><div> 'topo' = {map,chan_locs,eloc_info} Plot a 2-D scalp map at upper left of image.</div><div> map may be a single integer, representing the plotted data channel,</div><div> or a vector of scalp map channel values. chan_locs may be a channel locations</div><div> file or a chanlocs structure (EEG.chanlocs). See '>> topoplot example'</div><div> eloc_info (EEG.chaninfo), if empty ([]) or absent, implies the 'X' direction</div><div> points towards the nose and all channels are plotted {default: no scalp map}</div><div> 'spec' = [loHz,hiHz] Plot the mean data spectrum at upper right of image.</div><div> 'specaxis' = ['log'|'lin] Use 'lin' for linear spectrum frequency scaling, </div><div> else 'log' for log scaling {default: 'log'}</div><div> 'horz' = [epochs_vector] Plot horizontal lines at specified epoch numbers.</div><div> 'vert' = [times_vector] Plot vertical dashed lines at specified latencies</div><div> 'auxvar' = [size(nvars,ntrials) matrix] Plot auxiliary variable(s) for each trial</div><div> as separate traces. Else, 'auxvar',{[matrix],{colorstrings}}</div><div> to specify N trace colors. Ex: colorstrings = {'r','bo-','','k:'}</div><div> (see also: 'vert' and 'timewarp' above). {default: none}</div><div> 'sortvarpercent' = [float vector] Plot percentiles for the sorting variable</div><div> for instance, [0.1 0.5 0.9] plots the 10th percentile, the median</div><div> and the 90th percentile.</div><div> Plot options:</div><div> 'noxlabel' = ['on'|'off'] Do not plot "Time (ms)" on the bottom x-axis</div><div> 'yerplabel' = ['string'] ERP ordinate axis label (default is ERP). Print uV with '\muV'</div><div> 'avg_type' = ['boxcar'|'Gaussian'] The type of moving average used to smooth</div><div> the data. 'Boxcar' smoothes the data by simply taking the mean of</div><div> a certain number of trials above and below each trial.</div><div> 'Gaussian' does the same but first weights the trials</div><div> according to a Gaussian distribution (e.g., nearby trials</div><div> receive greater weight). The Gaussian is better than the</div><div> boxcar in that it rather evenly filters out high frequency</div><div> vertical components in the ERPimage. See 'avewidth' argument</div><div> description for more information. {default: boxcar}</div><div> 'img_trialax_label' = ['string'] The label of the axis corresponding to trials in the ERPimage</div><div> (e.g., 'Reaction Time'). Note, if img_trialax_label is set to something</div><div> besides 'Trials' or [], the tick marks on this axis will be set in units</div><div> of the sorting variable. This is a useful alternative to plotting the</div><div> sorting variable when the sorting variable is not in milliseconds. This</div><div> option is not effective if sorting by amplitude, phase, or EEG value. {default: 'Trials'}</div><div> 'img_trialax_ticks' = Vector of sorting variable values at which tick marks (e.g., [300 350 400 450]</div><div> for reaction time in msec) will appear on the trial axis of the erpimage. Tick mark</div><div> values should be given in units img_trialax_label (e.g., 'Trials' or msec).</div><div> This option is not effective if sorting by amplitude, phase, or EEG value.</div><div> {default: automatic}</div><div> 'baseline' = [low_boundary high_boundary] a time window (in msec) whose mean amplitude in</div><div> each trial will be removed from each trial (e.g., [-100 0]) after filtering.</div><div> Useful in conjunction with 'filt' option to re-basline trials after they have been</div><div> filtered. Not necessary if data have already been baselined and erpimage</div><div> processing does not affect baseline amplitude {default: no further baselining</div><div> of data}.</div><div> 'baselinedb' = [low_boundary high_boundary] a time window (in msec) whose mean amplitude in</div><div> each trial will be removed from each trial (e.g., [-100 0]). Use basedB in limits</div><div> to remove a fixed value. Default is time before 0. If you do not want to use a </div><div> baseline for amplitude plotting, enter a NaN value.</div><div> 'filt' = [low_boundary high_boundary] a two element vector indicating the frequency</div><div> cut-offs for a 3rd order Butterworth filter that will be applied to each</div><div> trial of data. If low_boundary=0, the filter is a low pass filter. If</div><div> high_boundary=srate/2, then the filter is a high pass filter. If both</div><div> boundaries are between 0 and srate/2, then the filter is a bandpass filter.</div><div> If both boundaries are between 0 and -srate/2, then the filter is a bandstop</div><div> filter (with boundaries equal to the absolute values of low_boundary and</div><div> high_boundary). Note, using this option requires the 'srate' option to be</div><div> specified and the signal processing toolbox function butter.m. You should</div><div> probably use the 'baseline' option as well since the mean prestimulus baseline</div><div> may no longer be 0 after the filter is applied {default: no filtering}</div><div> </div><div> Optional outputs:</div><div> outdata = (times,epochsout) data matrix (after smoothing)</div><div> outvar = (1,epochsout) actual values trials are sorted on (after smoothing).</div><div> if 'sortvarpercent' is used, this variable contains a cell array with</div><div> { sorted_values { sorted_percent1 ... sorted_percentN } }</div><div> outtrials = (1,epochsout) smoothed trial numbers</div><div> limits = (1,10) array, 1-9 as in 'limits' above, then analysis frequency (Hz)</div><div> axhndls = vector of 1-7 plot axes handles (img,cbar,erp,amp,coh,topo,spec)</div><div> erp = plotted ERP average</div><div> amps = mean amplitude time course</div><div> coher = mean inter-trial phase coherence time course</div><div> cohsig = coherence significance level</div><div> ampsig = amplitude significance levels [lo high]</div><div> outamps = matrix of imaged amplitudes (from option 'plotamps')</div><div> phsangls = vector of sorted trial phases at the phase-sorting frequency</div><div> phsamp = vector of sorted trial amplitudes at the phase-sorting frequency</div><div> sortidx = indices of input data epochs in the sorting order</div><div> erpsig = trial average significance levels [2,frames]</div><div> </div><div> Example: >> figure;</div><div> erpimage(data,RTs,[-400 256 256],'Test',1,1,...</div><div> 'erp','cbar','vert',-350);</div><div> Plots an ERP-image of 1-s data epochs sampled at 256 Hz, sorted by RTs, with</div><div> title ('Test'), and sorted epochs not smoothed or decimated (1,1). Overplots</div><div> the (unsmoothed) RT latencies on the colored ERP-image. Also plots the</div><div> epoch-mean (ERP), a color bar, and a dashed vertical line at -350 ms.</div><div> </div><div> Authors: Scott Makeig, Tzyy-Ping Jung & Arnaud Delorme,</div><div> CNL/Salk Institute, La Jolla, 3-2-1998 -</div></div><div>%%%%%%%%%%%%%%%%%%%%5</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 10, 2015 at 3:59 PM, Stephen Politzer-Ahles <span dir="ltr"><<a href="mailto:spa268@nyu.edu" target="_blank">spa268@nyu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Jaime,<div><br></div><div>If you produce the plot once from the user interface, and then run 'eegh' in the command line, you will see the code that produced the plot.</div><div><br></div><div>Best,</div><div>Steve</div></div><div class="gmail_extra"><span class="HOEnZb"><font color="#888888"><br clear="all"><div><div><div dir="ltr"><div><br><br></div>Stephen Politzer-Ahles<br>New York University, Abu Dhabi<br>Neuroscience of Language Lab<br><a href="http://www.nyu.edu/projects/politzer-ahles/" target="_blank">http://www.nyu.edu/projects/politzer-ahles/</a><br></div></div></div>
<br></font></span><div class="gmail_quote"><div><div class="h5">On Fri, Jul 10, 2015 at 7:09 AM, Jaime Heiss <span dir="ltr"><<a href="mailto:jaime.heiss@sri.com" target="_blank">jaime.heiss@sri.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Hello.<u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none">Where can I find basic examples on how to plot an ERP from a data Matrix using
<span style="font-size:10.0pt;font-family:"Courier New";color:black">erpimage function from within a script (without user input)?<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:black">The matrix has 12000 points in each row (1 trial = 1 row). SR is 2000Hz and I need to plot from 2000 to 4500 ms. (each row is 6s of data).<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:black">I need to produce the plot below without calling the user interface.
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:black">See <a href="https://dl.dropboxusercontent.com/u/1803710/erp.jpg" target="_blank">https://dl.dropboxusercontent.com/u/1803710/erp.jpg</a><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:black"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:black">I have read the help and FAQ and can’t get it right. Sorry.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:black"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:black">Thanks.</span><span style="font-size:12.0pt;font-family:"Courier New""><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"MV Boli"">Jaime Heiss, PhD.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"MV Boli"">Research Scientist<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"MV Boli"">SRI International<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<br></div></div><span class="">_______________________________________________<br>
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" rel="noreferrer" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu" target="_blank">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>
For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu" target="_blank">eeglablist-request@sccn.ucsd.edu</a><br></span></blockquote></div><br></div>
<br>_______________________________________________<br>
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" rel="noreferrer" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>
For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu">eeglablist-request@sccn.ucsd.edu</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego<br></div></div>
</div>