Dana-Farber-AIOS / pathml

Tools for computational pathology
https://pathml.org
GNU General Public License v2.0
387 stars 82 forks source link

Error with spams package in vahadane stain normalisation with StainNormalizationHE() #356

Closed VarunUllanat closed 5 months ago

VarunUllanat commented 1 year ago

Describe the bug

Running the vahadane stain normalisation with StainNormalizationHE() gives the following error:

2023-05-31 19:03:16,903 - distributed.worker - WARNING - Compute Failed
Key:       apply-0996075e0772a725d8bb46bdb2e46419
Function:  apply
args:      (Tile(coords=(1536, 256),
    name=None,
    image shape: (256, 256, 3),
    slide_type=SlideType(stain=HE, platform=None, tma=None, rgb=None, volumetric=None, time_series=None),
    labels=None,
    masks=None,
    counts=None))
kwargs:    {}
Exception: 'AttributeError("module \'numpy\' has no attribute \'bool\'.\\n`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\\nThe aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\\n    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations")'

The error seems to be with the spam package used to run the optimisation since np.bool is deprecated and replace with bool.

To Reproduce

image_path = '..'
wsi = SlideData(image_path, name = "example", backend = "openslide", stain = 'HE')
pipeline = Pipeline([StainNormalizationHE(stain_estimation_method='vahadane'), 
                     NucleusDetectionHE(mask_name='cell'),
                     TissueDetectionHE(mask_name = "tissue", min_region_size=500,
                      threshold=30, outer_contours_only=True)])

wsi.run(pipeline)

Expected behavior

I can downgrade my numpy version to support np.bool for a quick fix, but I was wondering if we could circumvent this deprecation altogether.

jacob-rosenthal commented 1 year ago

Python-spams is poorly supported and has caused lots of issues with installation in the past. I'd suggest recreating your environment following the exact same steps in the readme/test workflows - we test against those environments so we know that things work in them. Or, use one of the other stain estimation methods. If you have ideas for a better long-term fix, that would also be most welcome!

VarunUllanat commented 5 months ago

Fixed in #429.