HistomicsTK icon indicating copy to clipboard operation
HistomicsTK copied to clipboard

Edge case with cytoplasm feature extraction

Open idc9 opened this issue 2 years ago • 2 comments

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.

idc9 avatar Aug 08 '22 19:08 idc9

Hi @idc9 - if you want to branch and implement a solution we will add a test.

cooperlab avatar Aug 09 '22 01:08 cooperlab

Will do. May take sometime.

idc9 avatar Aug 09 '22 16:08 idc9

@subinkitware while you are working on the nuclear feature code, perhaps you might be able address this?

cooperlab avatar Aug 18 '23 20:08 cooperlab

@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.

subinkitware avatar Aug 19 '23 13:08 subinkitware