spiketools.spatial.occupancy.normalize_bin_counts¶
- spiketools.spatial.occupancy.normalize_bin_counts(bin_counts, occupancy)[source]¶
Normalize bin counts by occupancy.
- Parameters:
- bin_counts1d or 2d array
Bin counts.
- occupancy1d or 2d array
Spatially binned occupancy.
- Returns:
- normalized_bin_counts1d or 2d array
Normalized bin counts.
Notes
For any bins in which the occupancy is zero, the output will NaN.
Examples
Normalized a pre-computed 2d bin counts array by occupancy:
>>> bin_counts = np.array([[0, 1, 0], [1, 2, 0]]) >>> occupancy = np.array([[0, 2, 1], [1, 1, 0]]) >>> normalize_bin_counts(bin_counts, occupancy) array([[nan, 0.5, 0. ], [1. , 2. , nan]])