spiketools.spatial.place.compute_place_bins¶
- spiketools.spatial.place.compute_place_bins(spikes, position, timestamps, bins, area_range=None, speed=None, min_speed=None, max_speed=None, time_threshold=None, occupancy=None, orientation=None)[source]¶
Compute the spatially binned spiking activity.
- Parameters:
- spikes1d array
Spike times, in seconds.
- position1d or 2d array
Position values.
- timestamps1d array
Timestamps, in seconds, corresponding to the position values.
- binsint or list of [int, int]
The bin definition for dividing up the space. If 1d, can be integer. If 2d should be a list, defined as [number of x_bins, number of y_bins].
- area_rangelist of list, optional
Edges of the area to bin, defined as [[x_min, x_max], [y_min, y_max]].
- speed1d array, optional
Speed values corresponding to each position. Should be the same length as timestamps.
- min_speed, max_speedfloat, optional
Minimum and/or maximum speed thresholds to apply. Any spikes with an associated speed below the minimum or above maximum are dropped.
- time_thresholdfloat, optional
A maximum time threshold, per bin observation, to apply. If provided, any bin values with an associated time length above this value are dropped.
- occupancy1d or 2d array, optional
Computed occupancy across the space. If provided, used to normalize bin counts.
- orientation{‘row’, ‘column’}, optional
The orientation of the position data. If not provided, is inferred from the position data.
- Returns:
- place_bins2d array
The spike activity per spatial bin.
Examples
Compute spike activity across 2d spatial bins:
>>> spikes = np.array([0.2, 0.25, 0.3, 0.38, 0.41, 0.5, 0.59, 0.77, 0.95, 0.96]) >>> position = np.array([[0.1, 0.3, 0.35, 0.36, 0.37, 0.4, 0.45, 0.46, 0.55, 0.7], ... [1.0, 1.5, 1.55, 1.65, 1.66, 2.0, 3.0, 4.0, 5.5, 7.0]]) >>> timestamps = np.array([0.01, 0.03, 0.2, 0.25, 0.45, 0.46, 0.47, 0.49, 0.5, 0.65]) >>> bins = [3, 2] >>> compute_place_bins(spikes, position, timestamps, bins) array([[5, 0, 0], [0, 1, 4]])