spiketools.spatial.utils.convert_1dindices

spiketools.spatial.utils.convert_1dindices(indices, bins)[source]

Convert a set of 1d bin indices into the equivalent 2d indices.

Parameters:
indices1d array

Bin assignment indices for a 1d binning.

binslist of [int, int]

The bin definition for dividing up the space. If 2d should be a list, defined as [number of x_bins, number of y_bins].

Returns:
xbins, ybins1d array

Bin assignment indices for the x and y dimension of a 2d binning.

Notes

The equivalent 2d indices for a set of 1d indices are those that access the equivalent values once the data array has been reshaped to the given 2d bin definition.

Examples

Convert 1d bin indices into equivalent 2d indices with a [4, 4] shape:

>>> indices = np.array([0, 4, 5, 6, 7, 3, 2, 1, 0])
>>> bins = [3, 3]
>>> convert_1dindices(indices, bins)
(array([0, 1, 2, 0, 1, 0, 2, 1, 0]), array([0, 1, 1, 2, 2, 1, 0, 0, 0]))