Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Guidance for Claude Code (and humans) working in this repository.

Nyxus is a scalable C++/Python library that computes engineered features
(intensity, texture, morphology, moments, digital-filter) from segmented and
whole-slide/whole-volume images. It computes 758 features in all, 539 for 2D
images, 213 for 3D volumes and 6 image quality features, at the ROI or
whole-slide/whole-volume images. It computes 760 features in all, 540 for 2D
images, 214 for 3D volumes and 6 image quality features, at the ROI or
whole-image level (`docs/tools/gen_feature_reference.py --check` keeps these
counts equal to the code), and is
designed to operate at any scale by assembling ROIs that span multiple image
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/nyxus?label=Conda%20downloads)](https://anaconda.org/conda-forge/nyxus)

Nyxus computes intensity, texture, morphology and image quality features for every region of
interest (ROI) in 2D images and 3D volumes: 758 features in all, 539 for 2D images, 213 for 3D
interest (ROI) in 2D images and 3D volumes: 760 features in all, 540 for 2D images, 214 for 3D
volumes and 6 image quality features. It runs from Python or the command line, reads TIFF,
OME-TIFF, OME-Zarr, NIfTI and DICOM files (OME-TIFF and OME-Zarr with up to five dimensions), and
assembles ROIs that span several image tiles. Each feature's validation against reference tools
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/glcm_3d_worked_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def check(table, column, expected, what):
# Default settings (64-level binning, ordered pairs)
default = run(img, seg, "default", False)
for column, expected in {"3GLCM_CONTRAST": 478.61, "3GLCM_CONTRAST_AVE": 620.39,
"3GLCM_JVAR": 257.66, "3GLCM_VARIANCE": 334.03}.items():
"3GLCM_JVAR": 334.03, "3GLCM_VARIANCE": 334.03}.items():
check(default, column, expected, "default")

# 3glcm/greydepth and coarse_gray_depth both set the number of levels
Expand Down
9 changes: 6 additions & 3 deletions docs/examples/glcm_worked_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@

# Values the page quotes for the default settings (64-level binning, ordered pairs)
default = Nyxus(["*ALL_GLCM*"]).featurize(img, mask)
quoted = {"CONTRAST": 473.45, "VARIANCE": 332.44, "JVAR": 345.41, "CLUSHADE": -585.66,
"SUMVARIANCE": 882.25, "CLUTEND": 882.25}
quoted = {"CONTRAST": 473.45, "VARIANCE": 332.44, "JVAR": 332.44, "CLUSHADE": 9490.19,
"SUMVARIANCE": 867.43, "CLUTEND": 867.43}
for name, expected in quoted.items():
got = default[f"GLCM_{name}_0"][0]
assert math.isclose(got, expected, rel_tol=5e-4), f"default GLCM_{name}_0 = {got}, page says {expected}"
mirrored = Nyxus(["*ALL_GLCM*"]).featurize(np.ascontiguousarray(img[:, ::-1]), mask)
assert math.isclose(mirrored["GLCM_CLUSHADE_0"][0], 9490.19, rel_tol=5e-4), "mirrored cluster shade"
assert math.isclose(default["GLCM_HOM2_AVE"][0], default["GLCM_IDM_AVE"][0], rel_tol=1e-12), "HOM2_AVE vs IDM_AVE"

# The default-settings values the IBSI definitions give on the same 64-level matrix of ordered pairs
# The default-settings values are the IBSI definitions on the same 64-level matrix of ordered pairs
binned = np.minimum(np.floor(64 * img.astype(int) / 5 + 1), 64).astype(int)
P = np.zeros((64, 64))
for r in range(5):
Expand Down
30 changes: 16 additions & 14 deletions docs/feature_descriptions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ ANG_BW_NEIGHBORS_MODE = "Most frequent direction, rounded to whole degrees, from
[glcm]
GLCM_ASM = "Angular second moment: the sum of the squared co-occurrence probabilities, which is high when a few grey-level pairs dominate (a uniform texture)."
GLCM_ACOR = "Autocorrelation: the co-occurrence-weighted mean of the product of the two grey levels of a pixel pair, which grows with both coarseness and brightness."
GLCM_CLUPROM = "Cluster prominence: the fourth moment of the sum of the two grey levels of a pair about twice the neighbour pixel's mean grey level, which is large when that distribution is asymmetric or heavy-tailed."
GLCM_CLUSHADE = "Cluster shade: the third moment of the sum of the two grey levels of a pair about twice the neighbour pixel's mean grey level, which measures the skewness of the co-occurrence matrix."
GLCM_CLUTEND = "Cluster tendency: the second moment of the sum of the two grey levels of a pair about twice the neighbour pixel's mean grey level, which measures how strongly pairs group into similar grey levels."
GLCM_CLUPROM = "Cluster prominence: the fourth moment of the sum of the two grey levels of a pair about its mean, the sum of the two pixels' mean grey levels, which is large when that distribution is asymmetric or heavy-tailed."
GLCM_CLUSHADE = "Cluster shade: the third moment of the sum of the two grey levels of a pair about its mean, the sum of the two pixels' mean grey levels, which measures the skewness of the co-occurrence matrix."
GLCM_CLUTEND = "Cluster tendency: the second moment of the sum of the two grey levels of a pair about its mean, the sum of the two pixels' mean grey levels, which measures how strongly pairs group into similar grey levels; it returns the same value as GLCM_SUMVARIANCE."
GLCM_CONTRAST = "Contrast: the co-occurrence-weighted mean squared grey-level difference between the two pixels of a pair, which grows with local intensity variation."
GLCM_CORRELATION = "Correlation: the linear correlation, from -1 to 1, between the grey levels of the two pixels of a pair."
GLCM_DIFAVE = "Difference average: the mean absolute grey-level difference between the two pixels of a pair, taken from the distribution of those differences."
Expand All @@ -269,21 +269,21 @@ GLCM_DIS = "Dissimilarity: the co-occurrence-weighted mean absolute difference b
GLCM_ENERGY = "Energy: the sum of the squared co-occurrence probabilities; it returns the same value as GLCM_ASM."
GLCM_ENTROPY = "Entropy: the base-2 entropy of the co-occurrence probabilities, which is high when many grey-level pairs are about equally likely; it returns the same value as GLCM_JE."
GLCM_HOM1 = "Homogeneity 1: the co-occurrence probabilities weighted by one over one plus the grey-level difference of the pair; it returns the same value as GLCM_ID."
GLCM_HOM2 = "Homogeneity 2: the co-occurrence probabilities weighted by one over one plus the squared grey-level difference of the pair; it returns the same value as GLCM_IDM and has no _AVE code."
GLCM_HOM2 = "Homogeneity 2: the co-occurrence probabilities weighted by one over one plus the squared grey-level difference of the pair; it returns the same value as GLCM_IDM."
GLCM_ID = "Inverse difference: the co-occurrence probabilities weighted by one over one plus the grey-level difference of the pair, which is high when paired pixels have similar grey levels."
GLCM_IDN = "Inverse difference normalized: inverse difference with the grey-level difference divided by the number of grey levels, which makes it less dependent on the number of grey levels."
GLCM_IDM = "Inverse difference moment: the co-occurrence probabilities weighted by one over one plus the squared grey-level difference of the pair, a measure of local homogeneity."
GLCM_IDMN = "Inverse difference moment normalized: inverse difference moment with the squared grey-level difference divided by the squared number of grey levels."
GLCM_INFOMEAS1 = "Informational measure of correlation 1: the joint entropy minus the entropy expected if the two grey levels were independent, divided by the entropy of one marginal distribution; it measures how much the two grey levels depend on each other."
GLCM_INFOMEAS1 = "Informational measure of correlation 1: the joint entropy minus the entropy expected if the two grey levels were independent, divided by the larger of the two marginal entropies; it measures how much the two grey levels depend on each other."
GLCM_INFOMEAS2 = "Informational measure of correlation 2: a 0-to-1 measure of the dependence between the two grey levels of a pair, computed from the gap between the joint entropy and the entropy of the product of the marginals."
GLCM_IV = "Inverse variance: the distribution of grey-level differences between paired pixels weighted by one over the squared difference, leaving out pairs with equal grey levels."
GLCM_JAVE = "Joint average: the co-occurrence-weighted mean grey level of the reference pixel of a pair."
GLCM_JE = "Joint entropy: the base-2 entropy of the co-occurrence probabilities, which is high when many grey-level pairs are about equally likely."
GLCM_JMAX = "Joint maximum: the largest co-occurrence probability, that is the share of pairs taken by the most common grey-level pair."
GLCM_JVAR = "Joint variance: the co-occurrence-weighted spread of the neighbour pixel's grey level around the joint average (the reference pixel's mean); it equals GLCM_VARIANCE only when the matrix is symmetric."
GLCM_JVAR = "Joint variance: the co-occurrence-weighted variance of the reference pixel's grey level about the joint average; it returns the same value as GLCM_VARIANCE."
GLCM_SUMAVERAGE = "Sum average: the mean of the sum of the two grey levels of a pixel pair."
GLCM_SUMENTROPY = "Sum entropy: the base-2 entropy of the distribution of the sum of the two grey levels of a pixel pair."
GLCM_SUMVARIANCE = "Sum variance: the spread of the sum of the two grey levels of a pair about twice the neighbour pixel's mean grey level; this code returns the cluster tendency value, the same as GLCM_CLUTEND."
GLCM_SUMVARIANCE = "Sum variance: the variance of the sum of the two grey levels of a pair; it returns the same value as GLCM_CLUTEND."
GLCM_VARIANCE = "Variance: the co-occurrence-weighted variance of the reference pixel's grey level about its mean (PyRadiomics sum of squares)."
GLCM_ASM_AVE = "Angular second moment, averaged over the angles."
GLCM_ACOR_AVE = "Autocorrelation, averaged over the angles."
Expand All @@ -299,6 +299,7 @@ GLCM_DIS_AVE = "Dissimilarity, averaged over the angles."
GLCM_ENERGY_AVE = "Energy, averaged over the angles."
GLCM_ENTROPY_AVE = "Entropy, averaged over the angles."
GLCM_HOM1_AVE = "Homogeneity 1, averaged over the angles."
GLCM_HOM2_AVE = "Homogeneity 2, averaged over the angles."
GLCM_ID_AVE = "Inverse difference, averaged over the angles."
GLCM_IDN_AVE = "Inverse difference normalized, averaged over the angles."
GLCM_IDM_AVE = "Inverse difference moment, averaged over the angles."
Expand Down Expand Up @@ -683,9 +684,9 @@ RADIAL_CV = "Multi-column feature RADIAL_CV_0 to RADIAL_CV_7: for each of the 8
[glcm_3d]
3GLCM_ACOR = "Autocorrelation: the co-occurrence-weighted mean of the product of the two grey levels of a voxel pair, which grows with both coarseness and brightness."
3GLCM_ASM = "Angular second moment: the sum of the squared co-occurrence probabilities, which is high when a few grey-level pairs dominate (a uniform texture)."
3GLCM_CLUPROM = "Cluster prominence: the fourth moment of the sum of the two grey levels of a pair about twice the mean grey level, which is large when that distribution is asymmetric or heavy-tailed."
3GLCM_CLUSHADE = "Cluster shade: the third moment of the sum of the two grey levels of a pair about twice the mean grey level, which measures the skewness of the co-occurrence matrix."
3GLCM_CLUTEND = "Cluster tendency: the second moment of the sum of the two grey levels of a pair about twice the mean grey level, which measures how strongly pairs group into similar grey levels."
3GLCM_CLUPROM = "Cluster prominence: the fourth moment of the sum of the two grey levels of a pair about its mean, the sum of the two voxels' mean grey levels, which is large when that distribution is asymmetric or heavy-tailed."
3GLCM_CLUSHADE = "Cluster shade: the third moment of the sum of the two grey levels of a pair about its mean, the sum of the two voxels' mean grey levels, which measures the skewness of the co-occurrence matrix."
3GLCM_CLUTEND = "Cluster tendency: the second moment of the sum of the two grey levels of a pair about its mean, the sum of the two voxels' mean grey levels, which measures how strongly pairs group into similar grey levels; it returns the same value as 3GLCM_SUMVARIANCE."
3GLCM_CONTRAST = "Contrast: the co-occurrence-weighted mean squared grey-level difference between the two voxels of a pair, which grows with local intensity variation."
3GLCM_CORRELATION = "Correlation: the linear correlation, from -1 to 1, between the grey levels of the two voxels of a pair."
3GLCM_DIFAVE = "Difference average: the mean absolute grey-level difference between the two voxels of a pair, taken from the distribution of those differences."
Expand All @@ -695,21 +696,21 @@ RADIAL_CV = "Multi-column feature RADIAL_CV_0 to RADIAL_CV_7: for each of the 8
3GLCM_ENERGY = "Energy: the sum of the squared co-occurrence probabilities; it returns the same value as 3GLCM_ASM."
3GLCM_ENTROPY = "Entropy: the base-2 entropy of the co-occurrence probabilities, which is high when many grey-level pairs are about equally likely; it returns the same value as 3GLCM_JE."
3GLCM_HOM1 = "Homogeneity 1: the co-occurrence probabilities weighted by one over one plus the grey-level difference of the pair; it returns the same value as 3GLCM_ID."
3GLCM_HOM2 = "Homogeneity 2: the co-occurrence probabilities weighted by one over one plus the squared grey-level difference of the pair; it returns the same value as 3GLCM_IDM and has no _AVE code."
3GLCM_HOM2 = "Homogeneity 2: the co-occurrence probabilities weighted by one over one plus the squared grey-level difference of the pair; it returns the same value as 3GLCM_IDM."
3GLCM_ID = "Inverse difference: the co-occurrence probabilities weighted by one over one plus the grey-level difference of the pair, which is high when paired voxels have similar grey levels."
3GLCM_IDN = "Inverse difference normalized: inverse difference with the grey-level difference divided by the number of grey levels, which makes it less dependent on the number of grey levels."
3GLCM_IDM = "Inverse difference moment: the co-occurrence probabilities weighted by one over one plus the squared grey-level difference of the pair, a measure of local homogeneity."
3GLCM_IDMN = "Inverse difference moment normalized: inverse difference moment with the squared grey-level difference divided by the squared number of grey levels."
3GLCM_INFOMEAS1 = "Informational measure of correlation 1: the joint entropy minus the entropy expected if the two grey levels were independent, divided by the entropy of one marginal distribution; it measures how much the two grey levels depend on each other."
3GLCM_INFOMEAS1 = "Informational measure of correlation 1: the joint entropy minus the entropy expected if the two grey levels were independent, divided by the larger of the two marginal entropies; it measures how much the two grey levels depend on each other."
3GLCM_INFOMEAS2 = "Informational measure of correlation 2: a 0-to-1 measure of the dependence between the two grey levels of a pair, computed from the gap between the joint entropy and the entropy of the product of the marginals."
3GLCM_IV = "Inverse variance: the distribution of grey-level differences between paired voxels weighted by one over the squared difference, leaving out pairs with equal grey levels."
3GLCM_JAVE = "Joint average: the co-occurrence-weighted mean grey level of the reference voxel of a pair."
3GLCM_JE = "Joint entropy: the base-2 entropy of the co-occurrence probabilities, which is high when many grey-level pairs are about equally likely."
3GLCM_JMAX = "Joint maximum: the largest co-occurrence probability, that is the share of pairs taken by the most common grey-level pair."
3GLCM_JVAR = "Joint variance: the co-occurrence-weighted spread of the neighbour voxel's grey level around the joint average (the reference voxel's mean)."
3GLCM_JVAR = "Joint variance: the co-occurrence-weighted variance of the reference voxel's grey level about the joint average; it returns the same value as 3GLCM_VARIANCE."
3GLCM_SUMAVERAGE = "Sum average: the mean of the sum of the two grey levels of a voxel pair."
3GLCM_SUMENTROPY = "Sum entropy: the base-2 entropy of the distribution of the sum of the two grey levels of a voxel pair."
3GLCM_SUMVARIANCE = "Sum variance: the spread of the sum of the two grey levels of a pair about twice the mean grey level; this code returns the cluster tendency value, the same as 3GLCM_CLUTEND."
3GLCM_SUMVARIANCE = "Sum variance: the variance of the sum of the two grey levels of a pair; it returns the same value as 3GLCM_CLUTEND."
3GLCM_VARIANCE = "Variance: the co-occurrence-weighted variance of the reference voxel's grey level about its mean (PyRadiomics sum of squares)."
3GLCM_ASM_AVE = "Angular second moment, averaged over the directions."
3GLCM_ACOR_AVE = "Autocorrelation, averaged over the directions."
Expand All @@ -725,6 +726,7 @@ RADIAL_CV = "Multi-column feature RADIAL_CV_0 to RADIAL_CV_7: for each of the 8
3GLCM_ENERGY_AVE = "Energy, averaged over the directions."
3GLCM_ENTROPY_AVE = "Entropy, averaged over the directions."
3GLCM_HOM1_AVE = "Homogeneity 1, averaged over the directions."
3GLCM_HOM2_AVE = "Homogeneity 2, averaged over the directions."
3GLCM_ID_AVE = "Inverse difference, averaged over the directions."
3GLCM_IDN_AVE = "Inverse difference normalized, averaged over the directions."
3GLCM_IDM_AVE = "Inverse difference moment, averaged over the directions."
Expand Down
Loading
Loading