HistomicsTK
HistomicsTK copied to clipboard
Edge case with cytoplasm feature extraction
The problem
There is a subtle edge case with with compute_nuclei_features for the cytoplasm features. In particular, dilate_xor is not guaranteed to for cytoplasm for every single nuclei i.e. there can be nuclei with 0 cyotoplasm pixels in cyto_mask
(e.g. suppose a nucleus is totally surrounded by other nuclei).
I don't have example code I can reasonably give to demonstrate this edge case -- and it isn't super frequent, but it does happen. When the issue does occur you get an error in [lablocs[v['label']]]](https://github.com/DigitalSlideArchive/HistomicsTK/blob/1200e540c0184a2fde3a2e7e85644ce93f1e1a11/histomicstk/features/compute_nuclei_features.py#L190)
Potential solution
I'm not sure what the best way to address this edge case is. I think the most natural thing is to return NaNs for the cytoplasm features when there are zero cytoplasm pixels for a given nucleus. To accomplish this we could make this line
cyto_props = [cyto_props[lablocs[v['label']]] if v['label'] in lablocs else None for v in nuclei_props]
then enable the feature extraction functions (e.g. compute_intensity_features, compute_gradient_features, compute_haralick_features) to return NaN vectors when an entry of rprops is None.
Hi @idc9 - if you want to branch and implement a solution we will add a test.
Will do. May take sometime.
@subinkitware while you are working on the nuclear feature code, perhaps you might be able address this?
@subinkitware while you are working on the nuclear feature code, perhaps you might be able address this?
Manthey already addressed this issue in #1034. I can see NaN in the extracted features.csv
file if cytoplasm is not found.