numpyradiomics.firstorder#
- numpyradiomics.firstorder(image, mask, voxelVolume=1, binWidth=25, voxelArrayShift=0, extend=True)[source]#
Compute first-order (intensity-based) statistics for a given image and mask, replicating Pyradiomics first-order features.
- Parameters:
image (np.ndarray) – 3D image array containing voxel intensities.
mask (np.ndarray) – 3D mask array (same shape as image), where non-zero values indicate the ROI.
voxelVolume (float, optional) – Volume of a single voxel (used to scale TotalEnergy). Default is 1.
binWidth (float, optional) – Width of bins for histogram-based features (entropy, uniformity). Default is 25.
voxelArrayShift (float, optional) – Value to add to intensities before computing Energy/RMS. Default is 0.
extend (bool, optional) – If True, returns extended features not strictly in the PyRadiomics standard set (05/95 Percentile, CoeffOfVar, Heterogeneity). Default is True.
- Returns:
Dictionary containing first-order feature names and their computed values.
- Base Features:
Energy: Sum of squared voxel intensities.
TotalEnergy: Energy scaled by voxelVolume.
Entropy: Histogram-based Shannon entropy.
Minimum: Minimum intensity.
Maximum: Maximum intensity.
Mean: Mean intensity.
Median: Median intensity.
Range: Maximum - Minimum.
Variance: Variance of intensities.
StandardDeviation: Standard deviation of intensities.
Skewness: Measure of asymmetry of the distribution.
Kurtosis: Measure of the “tailedness” of the distribution.
MeanAbsoluteDeviation: Mean distance of all intensity values from the Mean.
RobustMeanAbsoluteDeviation: Mean distance of intensities (10-90th percentile) from the Mean.
RootMeanSquared: Square root of the mean of all the squared intensity values.
10Percentile: 10th percentile of intensities.
90Percentile: 90th percentile of intensities.
InterquartileRange: 75th percentile - 25th percentile.
Uniformity: Sum of squared histogram probabilities.
- Extended Features (if
extend=True): 05Percentile: 5th percentile of intensities.
95Percentile: 95th percentile of intensities.
CoefficientOfVariation: Standard Deviation / Mean.
Heterogeneity: Interquartile Range / Median.
- Return type:
Example
>>> import numpyradiomics as npr >>> # Generate a noisy ellipsoid (simulation of a tumor) >>> img, mask = npr.dro.noisy_ellipsoid(radii_mm=(20, 10, 5), intensity_range=(20, 80)) >>> >>> # Compute first order statistics >>> feats = npr.firstorder(img, mask) >>> >>> print(f"Mean: {feats['Mean']:.2f}") Mean: 50.02 >>> print(f"Range: {feats['Range']:.2f}") Range: 59.91