spiketools.spatial.occupancy.compute_bin_counts_pos

spiketools.spatial.occupancy.compute_bin_counts_pos(position, bins, area_range=None, occupancy=None, orientation=None)[source]

Compute counts per bin, from position data.

Parameters:
position1d or 2d array

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]]. Any values outside this range will be considered outliers, and not used to compute edges.

occupancy1d or 2d array, optional

Occupancy across the spatial bins. 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:
bin_counts1d or 2d array

Amount of events in each bin. For 2d, has shape [n_y_bins, n_x_bins] (see notes).

Notes

For the 2d case, note that while the inputs to this function list the x-axis first, the output of this function, being a 2d array, follows the numpy convention in which columns (y-axis) are on the 0th dimension, and rows (x-axis) are on the 1th dimension.

Examples

Compute counts across 2d bins from position data:

>>> position = np.array([[0.5, 1.0, 1.5, 2.0, 3.0],
...                      [0.1, 0.2, 0.3, 0.4, 0.5]])
>>> bins = [2, 3]
>>> compute_bin_counts_pos(position, bins)
array([[2, 0],
       [1, 0],
       [0, 2]])