The Histogram class#
- class rockverse.voxel_image.histogram.Histogram(image, *, bins=None, region=None, mask=None, segmentation=None)[source]#
Parallel CPU
Compute and manage histograms, probability density functions (PDFs), cumulative distribution functions (CDFs), and percentiles for VoxelImage data.
This class provides methods to calculate histograms, PDFs, CDFs, and percentiles, with support for regions of interest, masks, and segmentation.
- Parameters:
image (VoxelImage) – Input image.
bins (int or sequence of scalars, optional) – If int, number of equal-width bins in the range of image min and max. If sequence, defines bin edges (including rightmost edge), and ignores values outside bins when calculating the histogram. Default value is 256.
region (Region (optional)) – The region of interest in the image. If specified, only voxels within the region will be considered when computing the histogram.
mask (Boolean VoxelImage (optional)) – The mask to apply on the image data. If specified, only unmasked voxels will be considered when computing the histogram.
segmentation (Unsigned integer VoxelImage (optional)) – The segmentation data for image regions. If specified, histograms will also have individual counts for each segmentation phase.
Attributes summary
The input voxel image.
The region associated to the histogram.
The mask associated to the histogram.
The segmentation associated to the histogram.
Tuple with segmentation phases.
The histogram bins.
The centers of the histogram bins.
The image minimum value.
The image maximum value.
Get the histogram count as a Pandas DataFrame.
Compute the Probability Density Function (PDF) from the calculated histogram.
Compute the Cumulative Distribution Function (CDF) for the full image and phase by phase as a pandas DataFrame.
Methods summary
Estimate the q-th percentiles by linear interpolation on histogram CDF and bins.
Attributes documentation
- image#
The input voxel image.
- region#
The region associated to the histogram.
- mask#
The mask associated to the histogram.
- segmentation#
The segmentation associated to the histogram.
- phases#
Tuple with segmentation phases.
- bins#
The histogram bins.
- bin_centers#
The centers of the histogram bins.
- min#
The image minimum value.
- max#
The image maximum value.
- count#
Get the histogram count as a Pandas DataFrame.
- Returns:
A data frame containing the histogram values for the full image and each segmentation phase.
- Return type:
pandas.DataFrame
- pdf#
Compute the Probability Density Function (PDF) from the calculated histogram. PDF values are normalized such that the total area for the bins (bin width times histogram height) equals 1.
- Returns:
pdf – DataFrame containing the PDF values for the full image and for each segmentation phase.
- Return type:
pandas.DataFrame
- cdf#
Compute the Cumulative Distribution Function (CDF) for the full image and phase by phase as a pandas DataFrame.
- Returns:
A DataFrame containing the CDF values for the full image and each segmentation phase.
- Return type:
pandas.DataFrame
Examples
>>> # Get the CDF DataFrame >>> cdf = histogram.cdf >>> # Access the CDF values for a specific segmentation phase >>> phase_cdf = cdf[phase_id]
Methods
- percentile(q)[source]#
Estimate the q-th percentiles by linear interpolation on histogram CDF and bins.
- Parameters:
q (float or array-like of floats) – Percentage or sequence of percentages. Must obey 0<=q<=100.
- Returns:
Percentile values.
- Return type:
float or array-like of floats
Examples
>>> # Compute the 10th percentile >>> p = histogram.percentile(10) >>> # Compute quartiles (25th, 50th, and 75th percentiles) >>> Q1, Q2, Q3 = histogram.percentile([25, 50, 75])