[Eeglablist] Please help on basic usage of erpimage

Makoto Miyakoshi mmiyakoshi at ucsd.edu
Thu Jul 23 10:40:35 PDT 2015


Dear Jaime,

I agree with Allan though I always use 'imagesc()' with 'axis xy'.
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.

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.

Makoto

%%%%%%%%%%%%%%%%%
             >> figure; [outdata,outvar,outtrials,limits,axhndls, ...
                         erp,amps,cohers,cohsig,ampsig,outamps,...
                         phsangls,phsamp,sortidx,erpsig] ...
                             =
erpimage(data,sortvar,times,'title',avewidth,decimate,...
                                   'key', 'val', ...); % use options

 Required input:
    data     = [vector or matrix] Single-channel input data to image.
                Formats (1,frames*trials) or (frames,trials)

  Optional ordered inputs {with defaults}:

    sortvar  = [vector | []] Variable to sort epochs on (length(sortvar) =
nepochs)
               Example: sortvar may by subject response time in each epoch
(in ms)
               {default|[]: plot in input order}
    times    = [vector | []] vector of latencies (in ms) for each epoch
time point.
                Else [startms ntimes srate] = [start latency (ms), time
points
                (=frames) per epoch, sampling rate (Hz)]. Else [] ->
0:nframes-1
                {default: []}
   'title'   = ['string'] Plot title {default: none}
    avewidth = [positive scalar (may be non-integer)]. If avg_type is set
to 'boxcar'
                (the default), this is the number of trials used to smooth
                (vertically) with a moving-average. If avg_type is set to
                'Gaussian,' this is the standard deviation (in units of
                trials) of the Gaussian window used to smooth (vertically)
                with a moving-average.  Gaussian window extends three
                standard deviations below and three standard deviations
above window
                center (trials beyond window are not incorporated into
average). {default: no
                smoothing}
    decimate = Factor to decimate|interpolate ntrials by (may be
non-integer)
                Else, if this is large (> sqrt(ntrials)), output this many
epochs.
                {default|0->1}

  Optional unordered 'keyword',argument pairs:

  Re-align data epochs:
    'align'  = [latency] Time-lock data to sortvar. Plot sortvar at given
latency
                (in ms). Else Inf -> plot sortvar at median sortvar latency
                {default: do not align}
    'timewarp' = {[events], [warpms], {colors}} Time warp ERP, amplitude
and phase
                time-courses before smoothing. 'events' is a matrix whose
columns
                specify the latencies (in ms) at which a series of
successive events occur
                in each trial. 'warpms' is an optional vector of latencies
(in ms) to which
                the series of events should be time locked. (Note: Epoch
start and end
                should not be declared as events or warpms}. If 'warpms' is
absent or [],
                the median of each 'events' column will be used. {colors}
contains a
                list of Matlab linestyles to use for vertical lines marking
the occurrence
                of the time warped events. If '', no line will be drawn for
this event
                column. If fewer colors than event columns, cycles through
the given color
                labels.  Note: Not compatible with 'vert' (below).
    'renorm' = ['yes'|'no'| formula] Normalize sorting variable to epoch
                latency range and plot. 'yes'= autoscale. formula must be a
linear
                transformation in the format 'a*x+b'
                Example of formula: '3*x+2'. {default: 'no'}
                If sorting by string values like event type, suggested
formulas for:
                  letter string: '1000*x', number string: '30000*x-1500'
    'noplot' = ['on'|'off'] Do not plot sortvar {default: Plot sortvar if
in times range}
    'NoShow' = ['on'|'off'] Do not plot erpimage, simply return outputs
{default: 'off'}

  Sort data epochs:
  'nosort'       = ['on'|'off'] Do not sort data epochs. {default: Sort
data epochs by
                   sortvar (see sortvar input above)}
  'replace_ties' = ['yes'|'no'] Replace trials with the same value of
                   sortvar with the mean of those trials.  Only works if
sorting trials
                   by sortvar. {default: 'no'}
  'valsort'      = [startms endms direction] Sort data on (mean) value
                   between startms and (optional) endms. Direction is 1 or
-1.
                   If -1, plot max-value epoch at bottom {default: sort on
sortvar}
  'phasesort'    = [ms_center prct freq maxfreq topphase] Sort epochs by
phase in
                   a 3-cycle window centered at latency ms_center (ms).
                   Percentile (prct) in range [0,100] gives percent of
trials
                   to reject for (too) low amplitude. Else, if in range
[-100,0],
                   percent of trials to reject for (too) high amplitude;
                   freq (Hz) is the phase-sorting frequency. With optional
                   maxfreq, sort by phase at freq of max power in the data
in
                   the range [freq,maxfreq] (Note: 'phasesort' arg freq
overrides
                   the frequency specified in 'coher'). With optional
topphase,
                   sort by phase, putting topphase (degrees, in range
[-180,180])
                   at the top of the image. Note: 'phasesort' now uses
circular
                   smoothing. Use 'cycles' (below) for wavelet length.
                   {default: [0 25 8 13 180]}
   'ampsort'     = [center_ms prcnt freq maxfreq]  Sort epochs by amplitude.
                   (See 'phasesort' above). If ms_center is 'Inf', then
sorting
                   is by mean power across the time window specified by
'sortwin'
                   below. If third arg, freq, is < 0, sort by mean power in
the range
                   [ abs(freq)   maxfreq ].
   'sortwin'     = [start_ms end_ms] If center_ms == Inf in 'ampsort' arg
(above), sorts
                   by mean amplitude across window centers shifted from
start_ms
                   to end_ms by 10 ms.
   'showwin'     = ['on'|'off'] Show sorting window behind ERP trace.
{default: 'off'}

  Plot time-varying spectral amplitude instead of potential:
  'plotamps'     = ['on'|'off'] Image amplitudes at each trial and latency
instead of
                   potential values. Note: Currently requires 'coher'
(below) with alpha signif.
                   Use 'cycles' (see below) > (its default) 3 for better
frequency specificity,
                   {default: plot potential, not amplitudes, with no
minimum}. The average power
                   (in log space) before time 0 is automatically removed.
Note that the
                   'baseline' parameter has no effect on 'plotamps'.
Instead use
                   change "baselinedb" or "basedB" in the 'limits'
parameter. By default
                   the baseline is removed before time 0.

  Specify plot parameters:
    'limits'         = [lotime hitime minerp maxerp lodB hidB locoher
hicoher basedB]
                       Plot axes limits. Can use NaN (or nan, but not Nan)
for missing items
                       and omit late items. Use last input, basedB, to set
the
                       baseline dB amplitude in 'plotamps' plots {default:
from data}
    'sortvar_limits' = [min max] minimum and maximum sorting variable
                       values to image. This only affects visualization of
                       ERPimage and ERPs (not smoothing).  Cannot be used
                       if sorting by any factor besides sortvar (e.g.,
                       phase).
    'signif'         = [lo_dB, hi_dB, coher_signif_level] Use precomputed
significance
                       thresholds (as from outputs ampsig, cohsig) to save
time. {default: none}
    'caxis'          = [lo hi] Set color axis limits. Else [fraction] Set
caxis limits at
                       (+/-)fraction*max(abs(data)) {default: symmetrical
in dB, based on data limits}

  Add epoch-mean ERP to plot:
    'erp'      = ['on'|'off'|1|2|3|4] Plot ERP time average of the trials
below the
                 image.  If 'on' or 1, a single ERP (the mean of all
trials) is shown.  If 2,
                 two ERPs (super and sub median trials) are shown.  If 3,
the trials are split into
                 tertiles and their three ERPs are shown.  If 4, the trials
are split into quartiles
                 and four ERPs are shown. Note, if you want negative
voltage plotted up, change YDIR
                 to -1 in icadefs.m.  If 'erpalpha' option is used, any
values of 'erp' greater than
                 1 will be reset to 1. {default no ERP plotted}
    'erpalpha' = [alpha] Visualizes two-sided significance threshold (i.e.,
a two-tailed test) for the
                 null hypothesis of a zero mean, symmetric distribution
(range: [.001 0.1]). Thresholds
                 are determined via a permutation test. Requires 'erp' to
be a value other than 'off'.
                 If 'erp' is set  to a value greater than 1, it is reset to
1 to increase plot readability.
                 {default: no alpha significance thresholds plotted}
    'erpstd'   = ['on'|'off'] Plot ERP +/- stdev. Requires 'erp' {default:
no std. dev. plotted}
    'erp_grid' = If 'erp_grid' is added as an option voltage axis dashed
grid lines will be
                  added to the ERP plot to facilitate judging ERP amplitude
    'rmerp'    = ['on'|'off'] Subtract the average ERP from each trial
before processing {default: no}

  Add time/frequency information:
    'coher'  = [freq] Plot ERP average plus mean amplitude & coherence at
freq (Hz)
                Else [minfrq maxfrq] = same, but select frequency with max
power in
                given range. (Note: the 'phasesort' freq (above) overwrites
these
                parameters). Else [minfrq maxfrq alpha] = plot coher.
signif. level line
                at probability alpha (range: [0,0.1]) {default: no coher,
no alpha level}
    'srate'  = [freq] Specify the data sampling rate in Hz for amp/coher
(if not
                implicit in third arg, times) {default: as defined in
icadefs.m}
    'cycles' = [float] Number of cycles in the wavelet time/frequency
decomposition {default: 3}

  Add plot features:
    'cbar'           = ['on'|'off'] Plot color bar to right of ERP-image
{default no}
    'cbar_title'     = [string] The title for the color bar (e.g., '\muV'
for
                        microvolts).
    'topo'           = {map,chan_locs,eloc_info} Plot a 2-D scalp map at
upper left of image.
                        map may be a single integer, representing the
plotted data channel,
                        or a vector of scalp map channel values. chan_locs
may be a channel locations
                        file or a chanlocs structure (EEG.chanlocs). See
'>> topoplot example'
                        eloc_info (EEG.chaninfo), if empty ([]) or absent,
implies the 'X' direction
                        points towards the nose and all channels are
plotted {default: no scalp map}
    'spec'           = [loHz,hiHz] Plot the mean data spectrum at upper
right of image.
    'specaxis'       = ['log'|'lin] Use 'lin' for linear spectrum frequency
scaling,
                        else 'log' for log scaling {default: 'log'}
    'horz'           = [epochs_vector] Plot horizontal lines at specified
epoch numbers.
    'vert'           = [times_vector] Plot vertical dashed lines at
specified latencies
    'auxvar'         = [size(nvars,ntrials) matrix] Plot auxiliary
variable(s) for each trial
                        as separate traces. Else,
'auxvar',{[matrix],{colorstrings}}
                        to specify N trace colors.  Ex: colorstrings =
{'r','bo-','','k:'}
                        (see also: 'vert' and 'timewarp' above). {default:
none}
    'sortvarpercent' = [float vector] Plot percentiles for the sorting
variable
                        for instance, [0.1 0.5 0.9] plots the 10th
percentile, the median
                        and the 90th percentile.
  Plot options:
  'noxlabel'          = ['on'|'off'] Do not plot "Time (ms)" on the bottom
x-axis
  'yerplabel'         = ['string'] ERP ordinate axis label (default is
ERP). Print uV with '\muV'
  'avg_type'          = ['boxcar'|'Gaussian'] The type of moving average
used to smooth
                         the data. 'Boxcar' smoothes the data by simply
taking the mean of
                         a certain number of trials above and below each
trial.
                         'Gaussian' does the same but first weights the
trials
                         according to a Gaussian distribution (e.g., nearby
trials
                         receive greater weight).  The Gaussian is better
than the
                         boxcar in that it rather evenly filters out high
frequency
                         vertical components in the ERPimage. See
'avewidth' argument
                         description for more information. {default: boxcar}
  'img_trialax_label' = ['string'] The label of the axis corresponding to
trials in the ERPimage
                         (e.g., 'Reaction Time').  Note, if
img_trialax_label is set to something
                         besides 'Trials' or [], the tick marks on this
axis will be set in units
                         of the sorting variable.  This is a useful
alternative to plotting the
                         sorting variable when the sorting variable is not
in milliseconds. This
                         option is not effective if sorting by amplitude,
phase, or EEG value. {default: 'Trials'}
  'img_trialax_ticks' = Vector of sorting variable values at which tick
marks (e.g., [300 350 400 450]
                         for reaction time in msec) will appear on the
trial axis of the erpimage. Tick mark
                         values should be given in units img_trialax_label
(e.g., 'Trials' or msec).
                         This option is not effective if sorting by
amplitude, phase, or EEG value.
                         {default: automatic}
  'baseline'          = [low_boundary high_boundary] a time window (in
msec) whose mean amplitude in
                         each trial will be removed from each trial (e.g.,
[-100 0]) after filtering.
                         Useful in conjunction with 'filt' option to
re-basline trials after they have been
                         filtered. Not necessary if data have already been
baselined and erpimage
                         processing does not affect baseline amplitude
{default: no further baselining
                         of data}.
  'baselinedb'        = [low_boundary high_boundary] a time window (in
msec) whose mean amplitude in
                         each trial will be removed from each trial (e.g.,
[-100 0]). Use basedB in limits
                         to remove a fixed value. Default is time before 0.
If you do not want to use a
                         baseline for amplitude plotting, enter a NaN value.
  'filt'              = [low_boundary high_boundary] a two element vector
indicating the frequency
                         cut-offs for a 3rd order Butterworth filter that
will be applied to each
                         trial of data.  If low_boundary=0, the filter is a
low pass filter.  If
                         high_boundary=srate/2, then the filter is a high
pass filter.  If both
                         boundaries are between 0 and srate/2, then the
filter is a bandpass filter.
                         If both boundaries are between 0 and -srate/2,
then the filter is a bandstop
                         filter (with boundaries equal to the absolute
values of low_boundary and
                         high_boundary).  Note, using this option requires
the 'srate' option to be
                         specified and the signal processing toolbox
function butter.m.  You should
                         probably use the 'baseline' option as well since
the mean prestimulus baseline
                         may no longer be 0 after the filter is applied
{default: no filtering}

  Optional outputs:
     outdata  = (times,epochsout) data matrix (after smoothing)
      outvar  = (1,epochsout) actual values trials are sorted on (after
smoothing).
                if 'sortvarpercent' is used, this variable contains a cell
array with
                { sorted_values { sorted_percent1 ... sorted_percentN } }
    outtrials = (1,epochsout)  smoothed trial numbers
      limits  = (1,10) array, 1-9 as in 'limits' above, then analysis
frequency (Hz)
     axhndls  = vector of 1-7 plot axes handles
(img,cbar,erp,amp,coh,topo,spec)
         erp  = plotted ERP average
        amps  = mean amplitude time course
       coher  = mean inter-trial phase coherence time course
      cohsig  = coherence significance level
      ampsig  = amplitude significance levels [lo high]
     outamps  = matrix of imaged amplitudes (from option 'plotamps')
    phsangls  = vector of sorted trial phases at the phase-sorting frequency
      phsamp  = vector of sorted trial amplitudes at the phase-sorting
frequency
     sortidx  = indices of input data epochs in the sorting order
      erpsig  = trial average significance levels [2,frames]

  Example:  >> figure;
               erpimage(data,RTs,[-400 256 256],'Test',1,1,...
                             'erp','cbar','vert',-350);
     Plots an ERP-image of 1-s data epochs sampled at 256 Hz, sorted by
RTs, with
     title ('Test'), and sorted epochs not smoothed or decimated (1,1).
Overplots
     the (unsmoothed) RT latencies on the colored ERP-image. Also plots the
     epoch-mean (ERP), a color bar, and a dashed vertical line at -350 ms.

  Authors: Scott Makeig, Tzyy-Ping Jung & Arnaud Delorme,
           CNL/Salk Institute, La Jolla, 3-2-1998 -
%%%%%%%%%%%%%%%%%%%%5



On Fri, Jul 10, 2015 at 3:59 PM, Stephen Politzer-Ahles <spa268 at nyu.edu>
wrote:

> Hi Jaime,
>
> 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.
>
> Best,
> Steve
>
>
>
> Stephen Politzer-Ahles
> New York University, Abu Dhabi
> Neuroscience of Language Lab
> http://www.nyu.edu/projects/politzer-ahles/
>
> On Fri, Jul 10, 2015 at 7:09 AM, Jaime Heiss <jaime.heiss at sri.com> wrote:
>
>>  Hello.
>>
>> Where can I find basic examples on how to plot an ERP from a data Matrix
>> using erpimage function from within a script (without user input)?
>>
>> 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).
>>
>> I need to produce the plot below without calling the user interface.
>>
>> See https://dl.dropboxusercontent.com/u/1803710/erp.jpg
>>
>>
>>
>> I have read the help and FAQ and can’t get it right. Sorry.
>>
>>
>>
>> Thanks.
>>
>>
>>
>>
>>
>> Jaime Heiss, PhD.
>>
>> Research Scientist
>>
>> SRI International
>>
>>
>>
>> _______________________________________________
>> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
>> To unsubscribe, send an empty email to
>> eeglablist-unsubscribe at sccn.ucsd.edu
>> For digest mode, send an email with the subject "set digest mime" to
>> eeglablist-request at sccn.ucsd.edu
>>
>
>
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to
> eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to
> eeglablist-request at sccn.ucsd.edu
>



-- 
Makoto Miyakoshi
Swartz Center for Computational Neuroscience
Institute for Neural Computation, University of California San Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20150723/83132f1a/attachment.html>


More information about the eeglablist mailing list