chromatin_feats
Extracts chromatin features from the HE image and instance segmentation mask.
Note
This function extracts features related to the chromatin distribution within nuclei. These features include the total pixel area occupied by chromatin clumps within each nucleus, proportion of chromatin area to total nucleus area, number of distinct connected components (clumps) of chromatin within each nucleus, and proportion of chromatin that intersects with nucleus boundary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img
|
ndarray
|
Image to extract chromatin clumps from. Shape (H, W, 3). |
required |
label
|
ndarray
|
Label map of the cells/nuclei. Shape (H, W). |
required |
metrics
|
Tuple[str, ...]
|
Metrics to compute. Options are:
|
('chrom_area', 'chrom_nuc_prop')
|
mean
|
float
|
Mean intensity of the image. |
0
|
std
|
float
|
Standard deviation of the image. |
1
|
erode
|
bool
|
Whether to apply erosion to the chromatin clumps. |
False
|
mask
|
ndarray
|
Optional binary mask to apply to the image to restrict the region of interest. Shape (H, W). |
None
|
device
|
str
|
Device to use for computation. "cpu" or "cuda". |
'cpu'
|
Raises:
Type | Description |
---|---|
ValueError
|
If the shape of |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A DataFrame containing the extracted chromatin features. |
Examples:
>>> from histolytics.data import hgsc_cancer_he, hgsc_cancer_nuclei
>>> from histolytics.utils.raster import gdf2inst
>>> from histolytics.nuc_feats.chromatin import chromatin_feats
>>> import matplotlib.pyplot as plt
>>>
>>> # Load example data
>>> he_image = hgsc_cancer_he()
>>> nuclei = hgsc_cancer_nuclei()
>>>
>>> # Filter for a specific cell type if needed
>>> neoplastic_nuclei = nuclei[nuclei["class_name"] == "neoplastic"]
>>>
>>> # Convert nuclei GeoDataFrame to instance segmentation mask
>>> inst_mask = gdf2inst(neoplastic_nuclei, width=he_image.shape[1], height=he_image.shape[0])
>>> # Extract chromatin clumps
>>>
>>> metrics = ("chrom_area", "chrom_nuc_prop", "n_chrom_clumps", "chrom_boundary_prop")
>>> chrom_feats = chromatin_feats(he_image, inst_mask, metrics=metrics)
>>>
>>> print(chrom_feats.head(3))
chrom_area chrom_nuc_prop n_chrom_clumps chrom_boundary_prop
292 155 0.210027 3.0 0.163043
316 421 0.990588 1.0 0.625641
340 334 0.582897 2.0 0.527027
Source code in src/histolytics/nuc_feats/chromatin.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|