SBU-BMI / wsinfer

🔥 🚀 Blazingly fast pipeline for patch-based classification in whole slide images
https://wsinfer.readthedocs.io
Apache License 2.0
55 stars 9 forks source link

bug: it is possible for wsi loader to have a length of 0 (if no patches are detected) #195

Closed kaczmarj closed 4 months ago

kaczmarj commented 9 months ago

see here:

https://github.com/SBU-BMI/wsinfer/blob/d5057345ef0948a3f53488a03331d3b061b36953/wsinfer/modellib/run_inference.py#L164

it is possible that we wrote an h5 file with an empty array. we should catch this and not write the h5 file if no patches were detected.

kaczmarj commented 7 months ago

similar issue is that 'hierarchy' can sometimes be None (if no tissue detected)

Traceback (most recent call last):
  File "/home/jkaczmarzyk/miniforge3/envs/wsinfer/lib/python3.10/site-packages/wsinfer/patchlib/__init__.py", line 361, in segment_and_patch_directory_of_slides
    segment_and_patch_one_slide(
  File "/home/jkaczmarzyk/miniforge3/envs/wsinfer/lib/python3.10/site-packages/wsinfer/patchlib/__init__.py", line 161, in segment_and_patch_one_slide
    polygon, contours, hierarchy = get_multipolygon_from_binary_arr(
  File "/home/jkaczmarzyk/miniforge3/envs/wsinfer/lib/python3.10/site-packages/wsinfer/patchlib/patch.py", line 44, in get_multipolygon_from_binary_arr
    hierarchy = hierarchy.squeeze(0)
AttributeError: 'NoneType' object has no attribute 'squeeze'