Table Of Contents

Previous topic

misc.plot.base

Next topic

misc.plot.mri

misc.plot.erp

Module: misc.plot.erp

Basic ERP (here ERP = Event Related Plot ;-)) plotting

Can be used for plotting not only ERP but any event-locked data

Functions

mvpa.misc.plot.erp.plotERP(data, SR=500, onsets=None, pre=0.20000000000000001, pre_onset=None, post=None, pre_mean=None, color='r', errcolor=None, errtype=None, ax=<module 'pylab' from '/usr/lib/pymodules/python2.5/pylab.pyc'>, ymult=1.0, *args, **kwargs)

Plot single ERP on existing canvas

Parameters:
  • data (1D or 2D ndarray) – The data array can either be 1D (samples over time) or 2D (trials x samples). In the first case a boxcar mapper is used to extract the respective trial timecourses given a list of trial onsets. In the latter case, each row of the data array is taken as the EEG signal timecourse of a particular trial.
  • onsets (list(int)) – List of onsets (in samples not in seconds).
  • SR (int) – Sampling rate (1/s) of the signal.
  • pre (float) – Duration (in seconds) to be plotted prior to onset.
  • pre_onset (float or None) – If data is already in epochs (2D) then pre_onset provides information on how many seconds pre-stimulus were used to generate them. If None, then pre_onset = pre
  • post (float) – Duration (in seconds) to be plotted after the onset.
  • pre_mean (float) – Duration (in seconds) at the beginning of the window which is used for deriving the mean of the signal. If None, pre_mean = pre
  • errtype (None | ‘ste’ | ‘std’ | ‘ci95’ | list of previous three) – Type of error value to be computed per datapoint. ‘ste’: standard error of the mean ‘std’: standard deviation ‘ci95’: 95% confidence interval (1.96 * ste) None: no error margin is plotted (default) Optionally, multiple error types can be specified in a list. In that case all of them will be plotted.
  • color (matplotlib color code) – Color to be used for plotting the mean signal timecourse.
  • errcolor (matplotlib color code) – Color to be used for plotting the error margin. If None, use main color but with weak alpha level
  • ax – Target where to draw.
  • ymult (float) – Multiplier for the values. E.g. if negative-up ERP plot is needed: provide ymult=-1.0
  • *args, **kwargs – Additional arguments to plot().
Return type:

array

Returns:

Mean ERP timeseries.

mvpa.misc.plot.erp.plotERPs(erps, data=None, ax=None, pre=0.20000000000000001, post=None, pre_onset=None, xlabel='time (s)', ylabel='$\mu V$', ylim=None, ymult=1.0, legend=None, xlformat='%4g', ylformat='%4g', loffset=10, alinewidth=2, **kwargs)

Plot multiple ERPs on a new figure.

Parameters:
  • erps (list of tuples) – List of definitions of ERPs. Each tuple should consist of (label, color, onsets) or a dictionary which defines, label, color, onsets, data. Data provided in dictionary overrides ‘common’ data provided in the next argument data
  • data – Data for ERPs to be derived from 1D (samples)
  • ax – Where to draw (e.g. subplot instance). If None, new figure is created
  • pre (float) – Duration (seconds) to be plotted prior to onset
  • pre_onset (float or None) – If data is already in epochs (2D) then pre_onset provides information on how many seconds pre-stimulus were used to generate them. If None, then pre_onset = pre
  • post (float or None) – Duration (seconds) to be plotted after the onset. If any data is provided with onsets, it can’t be None. If None – plots all time points after onsets
  • ymult (float) – Multiplier for the values. E.g. if negative-up ERP plot is needed: provide ymult=-1.0
  • xlformat (basestring) – Format of the x ticks
  • ylformat (basestring) – Format of the y ticks
  • legend (basestring or None) – If not None, legend will be plotted with position argument provided in this argument
  • loffset (int) – Offset in voxels for axes and tick labels. Different matplotlib frontends might have different opinions, thus offset value might need to be tuned specifically per frontend
  • alinewidth (int) – Axis and ticks line width
  • **kwargs – Additional arguments provided to plotERP()
kwargs  = {'SR' : eeg.SR, 'pre_mean' : 0.2}
fig = plotERPs((('60db', 'b', eeg.erp_onsets['60db']),
                 ('80db', 'r', eeg.erp_onsets['80db'])),
                data[:, eeg.sensor_mapping['Cz']],
                ax=fig.add_subplot(1,1,1,frame_on=False), pre=0.2,
                post=0.6, **kwargs)
or
fig = plotERPs((('60db', 'b', eeg.erp_onsets['60db']),
                  {'color': 'r',
                   'onsets': eeg.erp_onsets['80db'],
                   'data' : data[:, eeg.sensor_mapping['Cz']]}
                 ),
                data[:, eeg.sensor_mapping['Cz']],
                ax=fig.add_subplot(1,1,1,frame_on=False), pre=0.2,
                post=0.6, **kwargs)
Returns:current fig handler