spiketools.measures.trials.compute_pre_post_rates

spiketools.measures.trials.compute_pre_post_rates(trial_spikes, pre_window, post_window)[source]

Compute the firing rates in pre and post event windows.

Parameters:
trial_spikeslist of 1d array

Spike times per trial.

pre_window, post_windowlist of [float, float]

The pre and post event time window, in seconds, to compute firing rate across.

Returns:
frs_pre, frs_post1d array

Computed pre & post firing rate for each trial.

Examples

Compute the pre & post firing rates for specified time windows across 3 trials:

>>> trial_spikes = [np.array([-0.150, -0.005, -0.002, 0.250, 0.450, 0.625]),
...                 np.array([-0.250, 0.275, 0.290, 0.3, 0.350, 0.6]),
...                 np.array([0.550, 0.650, 0.70, 0.9, 0.950])]
>>> pre_window, post_window = [-0.5, 0.0], [0.5, 0.9]
>>> compute_pre_post_rates(trial_spikes, pre_window, post_window)
(array([6., 2., 0.]), array([2.5, 2.5, 7.5]))