DigitalSlideArchive / HistomicsTK

A Python toolkit for pathology image analysis algorithms.
https://digitalslidearchive.github.io/HistomicsTK/
Apache License 2.0
395 stars 117 forks source link

minor_axis_length calculation error in HistomicsTK #829

Closed pbushel closed 4 years ago

pbushel commented 4 years ago

My operating system is CentOS Linux 7 (Core) using Python v3.6

Following the examples to normalize, deconvolute and segment an RBG tif image of a breast cancer tissue H&E slide, I get the following error when attempting to extract features using the compute_morphometry_features module:

myMorphometry_features = htk.features.compute_morphometry_features(im_nuclei_seg_mask) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib64/python3.6/site-packages/histomicstk/features/compute_morphometry_features.py", line 104, in compute_morphometry_features fdata.at[i, 'Size.MinorAxisLength'] = rprops[i].minor_axis_length File "/usr/local/lib64/python3.6/site-packages/skimage/measure/_regionprops.py", line 293, in minor_axis_length return 4 * sqrt(l2) ValueError: math domain error

The image that causes this error is 0c251941d7bc09d1d42dcfb0af4e2b544565088c.tif available from the Kaggle Histopathologic Cancer Detection competition test data set located here: https://www.kaggle.com/c/histopathologic-cancer-detection/data

I don't know what causes this error.

manthey commented 4 years ago

@pbushel What versions of sckikit-image and scikit-learn are in your environment? If you aren't on the latest scikit-image, can you upgrade it and see if the problem still occurs?

pbushel commented 4 years ago

@manthey Thanks for the reply. I have scikit-image v0.16.2 and scikit-learn 0.22.2.post1 installed which seem to be the most current versions available that aren't development.

pbushel commented 4 years ago

@manthey I commented out the code in compute_morphometry_features.py where the computation of minor_axis_length was performed/used. I'll probably have to figure out why for that image (and possibly others), the following code in _regioprops.py causes the ValueError: math domain error @property def minor_axis_length(self): l2 = self.inertia_tensor_eigvals[-1] return 4 * sqrt(l2)

Leengit commented 4 years ago

@pbushel @manthey I cannot reproduce the error with the indicated image. However, I can construct an example where inertia_tensor_eigvals[-1] comes out ever so slightly negative, which np.sqrt does not like. The problem is in scikit-image, where I have submitted a fix and pull request. I will submit a defensive code fix to HistomicsTK as well so that it works even before the fix to scikit-image is released.

manthey commented 4 years ago

Fixed in #840.