NCRF: slide/mask mismatch

If I follow the instructions for testing as given in readme. I get the following error

Traceback (most recent call last):
  File "wsi/bin/probs_map.py", line 163, in <module>
    main()
  File "wsi/bin/probs_map.py", line 159, in main
    run(args)
  File "wsi/bin/probs_map.py", line 115, in run
    args, cfg, flip='NONE', rotate='NONE')
  File "wsi/bin/probs_map.py", line 87, in make_dataloader
    flip=flip, rotate=rotate),
  File "/media/udion/a2c5c487-f939-4b82-a348-86b3d1bdb024/udion_home/Projects/NCRF/wsi/bin/../../wsi/data/wsi_producer.py", line 42, in __init__
    self._preprocess()
  File "/media/udion/a2c5c487-f939-4b82-a348-86b3d1bdb024/udion_home/Projects/NCRF/wsi/bin/../../wsi/data/wsi_producer.py", line 55, in _preprocess
    .format(X_slide, X_mask, Y_slide, Y_mask))
Exception: Slide/Mask dimension does not match , X_slide / X_mask : 98304 / 1536, Y_slide / Y_mask : 103936 / 2048

what’s the issue?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 30

Most upvoted comments

@yil8 @udion

I upgraded my OpenSlide binary to 3.4.1 and the slides have the same dimension as mentioned by @yil8:

In [1]: import openslide

In [2]: slide = openslide.OpenSlide('./test_026.tif')

In [3]: slide.level_dimensions
Out[3]: 
((98304, 103936),
 (49152, 51968),
 (24576, 25984),
 (12288, 12992),
 (6144, 6496),
 (3072, 3248),
 (1536, 1624),
 (768, 812),
 (384, 406))

@meetshah1995 my binary version:

openslide-show-properties --version
openslide-show-properties 3.4.1, using OpenSlide 3.4.1
Copyright (C) 2007-2015 Carnegie Mellon University and others

OpenSlide is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License, version 2.1.
<http://gnu.org/licenses/lgpl-2.1.html>

OpenSlide comes with NO WARRANTY, to the extent permitted by law.  See the
GNU Lesser General Public License for more details.

@yil8 The slide does not keep a consistent ratio occurs in Training dataset(almost all ). Tumor026: (97280, 220672) (48640, 110592) (24576, 55296) (12288, 27648) (6144, 13824) (3072, 7168) (1536, 3584) (1024, 2048) (512, 1024) (512, 512) Here is my solution in tisuue_mask.py:

    slide = openslide.OpenSlide(args.wsi_path)
    dims_tuple =  (int(slide.level_dimensions[0][0]/(2**args.level)), int(slide.level_dimensions[0][1]/(2**args.level)))
    #print(dims_tuple)
    # note the shape of img_RGB is the transpose of slide.level_dimensions
    img_RGB = np.transpose(np.array(slide.read_region((0, 0),
                           args.level,
                           slide.level_dimensions[args.level]).convert('RGB')),
                           axes=[1, 0, 2])
    #print((img_RGB.shape))
    img_RGB = cv2.resize(img_RGB,(dims_tuple[1],dims_tuple[0]))

@meetshah1995 Thanks so much for spotting this potential issue! I’ll add this into README.

I’m splitting the file using tiffsplit which created one tif file for each level:

tiffsplit <input_multilevel_tiff>

@udion I was using the data from Google drive. BTW, there seems to be a application free download link from GigaDB, and I just downloaded test_026.tif, which gave me the correct level_dimensions:

In [1]: import openslide

In [2]: slide = openslide.OpenSlide('./test_026.tif')

In [3]: slide.level_dimensions
Out[3]: 
((98304, 103936),
 (49152, 51968),
 (24576, 25984),
 (12288, 12992),
 (6144, 6496),
 (3072, 3248),
 (1536, 1624),
 (768, 812),
 (384, 406))