spike_psth#

syncopy.spike_psth(data, binsize='rice', output='rate', latency='maxperiod', vartriallen=True, keeptrials=True, parallel=None, select=None, **kwargs)[source]#

Peristimulus time histogram

The parameters listed below can be provided as is or a via a cfg configuration ‘structure’, see Notes for details.

Parameters:
  • data (SpikeData) – A non-empty Syncopy SpikeData object

  • binsize (float or one of {'rice', 'sqrt'}, optional) – Binsize in seconds or get optimal bin width via Rice rule (‘rice’) or square root of number of observations (‘sqrt’)

  • output ({'rate', 'spikecount', 'proportion'}, optional) – Set to ‘rate’ to convert the output to firing rates (spikes/sec), ‘spikecount’ to count the number spikes per trial or ‘proportion’ to normalize the area under the PSTH to 1 Defaults to ‘rate’

  • vartriallen (bool, optional) – True (default): accept variable trial lengths and use all available trials and the samples in every trial. Missing values (empty bins) will be ignored in the computation and results stored as NaNs False : only select those trials that fully cover the window as specified by latency and discard those trials that do not.

  • latency (array_like or {'maxperiod', 'minperiod', 'prestim', 'poststim'}) – Either set desired time interval ([begin, end]) for spike counting in seconds, ‘maxperiod’ (default) for the maximum period available or ‘minperiod’ for the minimal time interval all trials share, or `’prestim’ (all t < 0) or ‘poststim’ (all t > 0)

  • keeptrials (bool, optional) – If True the psth’s of individual trials are returned, otherwise results are averaged across trials.

Returns:

  • out (TimeLockData) – Time locked data object, with additional datasets: out.avg and out.var

  • parallel (None or bool) – If None (recommended), processing is automatically performed in parallel (i.e., concurrently across trials/channel-groups), provided a dask parallel processing client is running and available. Parallel processing can be manually disabled by setting parallel to False. If parallel is True but no parallel processing client is running, computing will be performed sequentially.

  • select (dict or StructDict or str) – In-place selection of subset of input data for processing. Please refer to syncopy.selectdata() for further usage details.

Examples

spd is a SpikeData object.

Computing the rate histogram with a 0.2 seconds bin size and on the maximally available time interval, covering all events:

>>> spy.spike_psth(spd, binsize=0.2, latency='maxperiod')

Get the spike counts for the max. common time interval where there is activity for all trials and use the square root bin size selection rule:

>>> spy.spike_psth(spd, binsize='sqrt', latency='minperiod', output='spikecount')

Firing rates between 0.1 and 0.5 seconds in 50ms bins, discarding trials which do not have events in every bin of the selected latency interval:

>>> spy.spike_psth(spd, binsize=0.05, latency=[0.1, 0.5], vartriallen=False)