locan.process.aggregate.histogram

locan.process.aggregate.histogram(locdata, loc_properties=None, other_property=None, bins=None, n_bins=None, bin_size=None, bin_edges=None, bin_range=None)[source]

Make histogram of loc_properties (columns in locdata.data) by binning all localizations or averaging other_property within each bin.

Bins are half-open intervals. If bin_range is derived from the data, the upper bound is widened by a negligible amount (1e-12 of the range) so that the localization with the maximum coordinate is counted.

Parameters:
  • locdata (LocData) – Localization data.

  • loc_properties (str | Iterable[str] | None) – Localization properties to be grouped into bins. If None The coordinate_values of locdata are used.

  • other_property (str | None) – Localization property that is averaged in each pixel. If None localization counts are shown.

  • bins (Bins | Axis | AxesTuple | None) – The bin specification as defined in Bins

  • n_bins (int | Sequence[int] | ndarray[tuple[int, ...], dtype[floating]] | ndarray[tuple[int, ...], dtype[integer]] | None) – The number of bins for all or each dimension. 5 yields 5 bins in all dimensions. (2, 5) yields 2 bins for one dimension and 5 for the other dimension.

  • bin_size (float | Sequence[float] | Sequence[Sequence[float]] | Sequence[float | Sequence[float]] | ndarray[tuple[int, ...], dtype[floating]] | ndarray[tuple[int, ...], dtype[integer]] | None) – The size of bins for all or each bin and for all or each dimension with shape (dimension,) or (dimension, n_bins). 5 would describe bin_size of 5 for all bins in all dimensions. ((2, 5),) yield bins of size (2, 5) for one dimension. (2, 5) yields bins of size 2 for one dimension and 5 for the other dimension. ((2, 5), (1, 3)) yields bins of size (2, 5) for one dimension and (1, 3) for the other dimension. To specify arbitrary sequence of bin_size use bin_edges instead.

  • bin_edges (Sequence[float] | Sequence[Sequence[float]] | Sequence[ndarray[tuple[int, ...], dtype[floating]] | ndarray[tuple[int, ...], dtype[integer]]] | ndarray[tuple[int, ...], dtype[floating]] | ndarray[tuple[int, ...], dtype[integer]] | None) – Bin edges for all or each dimension with shape (dimension, n_bin_edges).

  • bin_range (Union[tuple[float, float], Sequence[float], Sequence[Sequence[float]], ndarray[tuple[int, ...], dtype[floating]], ndarray[tuple[int, ...], dtype[integer]], Literal['zero', 'link'], None]) – Minimum and maximum edge for all or each dimensions with shape (2,) or (dimension, 2). If None (min, max) ranges are determined from data and returned; if ‘zero’ (0, max) ranges with max determined from data are returned. if ‘link’ (min_all, max_all) ranges with min and max determined from all combined data are returned.

Return type:

Histogram

Raises:
  • ValueError – If the bin specification is inconsistent or its dimension does not match loc_properties.

  • TypeError – If locdata is empty, more than three loc_properties are given or other_property is not a valid property.