spiketools.measures.trials.compute_segment_frs

spiketools.measures.trials.compute_segment_frs(spikes, segments)[source]

Compute firing rate across trial segments.

Parameters:
spikes1d array or list of 1d array

Spike times, in seconds. Can be single array, or list of spike times per trial.

segments2d array

Time definitions of the segments, per trial, used as time bins. Should have shape: [n_trials, n_segments + 1].

Returns:
frs2d array

Firing rate per trial, per segment.

Examples

Compute firing rate across segments, with custom segment times per trial:

>>> spikes = [np.array([0.002, 0.005, 0.120, 0.175, 0.250]),
...           np.array([0.275, 0.290, 0.300, 0.350, 0.500]),
...           np.array([0.550, 0.650, 0.700, 0.950])]
>>> segments = np.array([[0.00, 0.15, 0.25],
...                      [0.20, 0.40, 0.60],
...                      [0.50, 0.70, 0.90]])
>>> compute_segment_frs(spikes, segments)
array([[20., 20.],
       [20.,  5.],
       [10.,  5.]])