nabu.processing.histogram
source module nabu.processing.histogram
Classes
-
PartialHistogram — A class for computing histogram progressively.
-
VolumeHistogram — A class for computing the histogram of an entire volume. Unless explicitly specified, histogram is computed in several passes so that not all the volume is loaded in memory.
Functions
-
add_last_bin — Add the last bin (max value) to a list of bin edges.
source class PartialHistogram(method='fixed_bins_width', bin_width='uint16', num_bins=None, min_bins=None, backend='silx')
A class for computing histogram progressively.
In certain cases, it is cumbersome to compute a histogram directly on a big chunk of data (ex. data not fitting in memory, disk access too slow) while some parts of the data are readily available in-memory.
Initialize a PartialHistogram class.
Parameters
-
method : str, optional — Partial histogram computing method. Available are: -
fixed_bins_width: all the histograms are computed with the same bin width. The class adapts to the data range and computes the number of bins accordingly. -fixed_bins_number: all the histograms are computed with the same number of bins. The class adapts to the data range and computes the bin width accordingly. Default is "fixed_bins_width" -
bin_width : str or float, optional — Policy for histogram bins when method="fixed_bins_width". Available are: - "uint16": The bin width is computed so that floating-point elements
f1andf2satisfying|f1 - f2| < bin_widthimpliesf1_converted - f2_converted < 1once cast to uint16. - A number: all the bins have this fixed width.Default is "uint16"
-
num_bins : int, optional — Number of bins when method = 'fixed_bins_number'.
-
min_bins : int, optional — Minimum number of bins when method = 'fixed_bins_width'.
-
backend : str, optional — Which histogram backend to use for computations. Available are "silx", "numpy". Fastest is "silx".
Methods
source method PartialHistogram.get_bin_width(dmin, dmax)
Raises
-
ValueError
source method PartialHistogram.compute_histogram(data, data_range=None)
source method PartialHistogram.merge_histograms(histograms, **kwargs)
source class VolumeHistogram(data_url, chunk_size_slices=100, chunk_size_GB=None, nbins=1000000.0, logger=None)
A class for computing the histogram of an entire volume. Unless explicitly specified, histogram is computed in several passes so that not all the volume is loaded in memory.
Initialize a VolumeHistogram object.
Parameters
-
fname : DataUrl — DataUrl to the HDF5 file.
-
chunk_size_slices : int, optional — Compute partial histograms of groups of slices. This is the default behavior, where the groups size is 100 slices. This parameter is mutually exclusive with 'chunk_size_GB'.
-
chunk_size_GB : float, optional — Maximum memory (in GB) to use when computing the histogram by group of slices. This parameter is mutually exclusive with 'chunk_size_slices'.
-
nbins : int, optional — Histogram number of bins. Default is 1e6.
Methods
source method VolumeHistogram.compute_volume_histogram()
source hist_as_2Darray(hist, center=True, dtype='f')
source add_last_bin(histo_bins)
Add the last bin (max value) to a list of bin edges.