aind_ephys_utils.metrics.latency module

Metrics related to response latency.

aind_ephys_utils.metrics.latency.spike_latency(times, events, interval, use_psth=True, std_above_baseline=2, bin_size=0.001)

Computes latency of spikes to a set of events.

If use_psth is set to True, the latency will be computed using the average PSTH, rather than spikes on individual trials.

If use_psth is set to False, the latency will be computed as the median time to first spike on individual trials.

Parameters:
  • times (ndarray) – 1-D sequence of times to align (in seconds). Must be sorted in ascending order.

  • events (ndarray) – 1-D sequence of reference times (in seconds).

  • interval (tuple) – First value = baseline interval (ignored if use_psth = False) Second value = maximum latency

  • use_psth (bool, optional) – Set to True to use PSTH method, False otherwise

  • std_above_baseline (float, optional) – Determines threshold for response onset Latency = first value above Mean + Std * T

  • bin_size (float, optional) – Determines bin size (in seconds) for PSTH method

Returns:

  • if use_psth = True

  • latency (float) – First spike latency in s

  • psth (float) – The PSTH used to compute latency

  • if use_psth = False

  • first_spike_latency (float) – First spike latency in s

  • individual_latencies (ndarray) – Latency values for all trials with spikes