DIAGNijmegen / pathology-whole-slide-data

A package for working with whole-slide data including a fast batch iterator that can be used to train deep learning models.
https://diagnijmegen.github.io/pathology-whole-slide-data/
Apache License 2.0
86 stars 24 forks source link

Artifacts from batch iterator #18

Closed sumeetgadagkar closed 2 years ago

sumeetgadagkar commented 2 years ago

When using batch iterator for extracting patches at 8 um/px there are some artifacts in the extracted patches. Few examples of this:

image

image

The user config used:

wholeslidedata:
    default:
        seed: 123
        yaml_source: tigerdatasubset.yml

        label_map:
            roi: 0
            invasive tumor: 1
            tumor-associated stroma: 2
            in-situ tumor: 3 
            healthy glands: 4
            necrosis not in-situ: 5
            inflamed stroma: 6
            rest: 7

        annotation_parser:
            sample_label_names: ['roi']

        batch_shape:
            batch_size: 2
            spacing: 8
            shape: [256, 256, 3]

        point_sampler:
            attribute: RandomPointSampler
            buffer: -128

the data subset used :

--- 
training: 
  - 
    wsa: 
      path: /data/wsirois/wsi-level-annotations/annotations-tissue-cells-xmls/100B.xml
    wsi: 
      path: /data/wsirois/wsi-level-annotations/images/100B.tif

To reproduce this the "Tiger-BatchIterator Introduction" notebook can be run with the above settings. Is this a known issue?

sumeetgadagkar commented 2 years ago

I got this fixed on my local machine by changing the image backend to pyvips. However, on the server where I am working when I try this it throws the error:

Error: no such operation openslideload
  VipsOperation: class "openslideload" not found

I have installed openslide-tools & python-openslide. Any pointers on how to fix this issue?

sumeetgadagkar commented 2 years ago

The solution was to downgrade to a lower version of pyvips and then upgrade to the latest version again. The black images were present only with the openslide image backend. With the pyvips backend this is no longer an issue.

martvanrijthoven commented 2 years ago

Hi,

Thank you for this issue. Great to hear that you could solve it with the pyvips backend!

I am still curious why this happens with the openslide backend.

Are you using a conda environment? If so, this issue might be related to: https://github.com/openslide/openslide/issues/291 A possible solution might be to upgrade pixman: conda install -c anaconda pixman=0.40.0.

If this does not work for you, could you please specify your environment here, such that I can try to reproduce it?

Best wishes, Mart

sumeetgadagkar commented 2 years ago

using pixman=0.40.0 fixed the issue for the openslide image backend. Thanks!