mahmoodlab / CLAM

Data-efficient and weakly supervised computational pathology on whole slide images - Nature Biomedical Engineering
http://clam.mahmoodlab.org
GNU General Public License v3.0
1.12k stars 362 forks source link

Error occurred when patching #280

Open lsk-china opened 1 week ago

lsk-china commented 1 week ago

cmdline: python repositories/CLAM/create_patches.py --source ../image_and_convert/wsi --patch_size 224 --seg --patch --stitch --save_dir patch --no_auto_skip output:

source:  ../image_and_convert/wsi
patch_save_dir:  patch/patches
mask_save_dir:  patch/masks
stitch_save_dir:  patch/stitches
source : ../image_and_convert/wsi
save_dir : patch
patch_save_dir : patch/patches
mask_save_dir : patch/masks
stitch_save_dir : patch/stitches
{'seg_params': {'seg_level': -1, 'sthresh': 8, 'mthresh': 7, 'close': 4, 'use_otsu': False, 'keep_ids': 'none', 'exclude_ids': 'none'}, 'filter_params': {'a_t': 100, 'a_h': 16, 'max_n_holes': 8}, 'patch_params': {'white_thresh': 5, 'black_thresh': 40, 'use_padding': True, 'contour_fn': 'four_pt'}, 'vis_params': {'vis_level': -1, 'line_thickness': 250}}

progress: 0.00, 0/1
processing T1.svs
Creating patches for:  T1 ...
Bounding Box: 45632 20224 9985 8897
Contour Area: 36016128.0
patches extracted: 585
Bounding Box: 96064 0 29953 25665
Contour Area: 403767296.0
patches extracted: 4419
Bounding Box: 55360 0 12225 9473
Contour Area: 42829824.0
patches extracted: 704
Bounding Box: 32832 0 88065 67137
Contour Area: 2974095360.0
patches extracted: 45717
Bounding Box: 0 0 46209 66945
Contour Area: 1459935232.0
patches extracted: 21715
original size: 126336 x 67200
downscaled size for stiching: 1974 x 1050
number of patches: 56543
Traceback (most recent call last):
  File "/data/cancer/work/repositories/CLAM/create_patches.py", line 281, in <module>
    seg_times, patch_times = seg_and_patch(**directories, **parameters,
  File "/data/cancer/work/repositories/CLAM/create_patches.py", line 178, in seg_and_patch
    heatmap, stitch_time_elapsed = stitching(file_path, downscale=64)
  File "/data/cancer/work/repositories/CLAM/create_patches.py", line 15, in stitching
    heatmap = StitchPatches(file_path, downscale=downscale, bg_color=(0,0,0), alpha=-1, draw_grid=False)
  File "/data/Github/CLAM/wsi_core/wsi_utils.py", line 225, in StitchPatches
    img_shape = dset[0].shape
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/data/cancer/env/lib/python3.9/site-packages/h5py/_hl/dataset.py", line 779, in __getitem__
    if self._fast_read_ok and (new_dtype is None):
  File "/data/cancer/env/lib/python3.9/site-packages/h5py/_hl/base.py", line 532, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/data/cancer/env/lib/python3.9/site-packages/h5py/_hl/dataset.py", line 761, in _fast_read_ok
    self._extent_type == h5s.SIMPLE
  File "/data/cancer/env/lib/python3.9/site-packages/h5py/_hl/base.py", line 532, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/data/cancer/env/lib/python3.9/site-packages/h5py/_hl/dataset.py", line 652, in _extent_type
    return self.id.get_space().get_simple_extent_type()
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5d.pyx", line 348, in h5py.h5d.DatasetID.get_space
RuntimeError: Unable to synchronously get dataspace (invalid dataset identifier)

Using conda environment provided in the env.yml. I wonder if the WSI file I'm using is broken, or I'm using a wrong version of h5py?

dodoflyy commented 2 days ago

You can use exiftool or tifffile to check your WSI file.