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

Sliding Window configuration #30

Closed michelbotros closed 1 year ago

michelbotros commented 1 year ago

Hi Mart,

I am working with the Sliding Window configuration as shown in: https://github.com/DIAGNijmegen/pathology-whole-slide-data/blob/main/notebooks/tiger/sliding_window/slidingwindowconfig.yml

Is it possible to use a sliding window configuration without the ASAP backend? I can’t install ASAP or use Docker on the server that I am working on currently (working on getting this fixed). But in the meantime I am looking for a workaround.

Let me know whether this is possible.

Thank you,

Michel

martvanrijthoven commented 1 year ago

Dear Michel,

It might be a bit confusing, but there are two types of a 'sliding window'

The first one is based on a tissue mask. That type needs a configuration you mentioned. This is mainly for looping over a tissue mask such that a model only needs to predict patches where there is tissue. This requires ASAP, because openslide has trouble reading monochrome images. Pyvips might work but I have not implemented this yet.

The second one is a sliding window loop over the annotations in a dataset, such that all annotated regions are retrieved in a sliding window fashion. This does not depend on any backend. You can find a notebook and config in the notebooks folder.

Please let me know if you have any questions about it.

Best wishes, Mart

michelbotros commented 1 year ago

@martvanrijthoven I needed the second option and its working perfectly.

Thank you for the example!

martvanrijthoven commented 1 year ago

Dear Michel,

Great to hear that it works for you!

Best wishes, Mart

michelbotros commented 1 year ago

@martvanrijthoven Small follow up question: How can I use this configuration for an overlapping sliding window approach? For example where tiles overlap 50%.

martvanrijthoven commented 1 year ago

Hi Michel,

You can change the tile size: https://github.com/DIAGNijmegen/pathology-whole-slide-data/blob/799683950e406ce701f1cf8d510ee4e834039a9c/notebooks/configs/slidingwindowsampling.yml#L24

In that example, the input size is 256. If you set the tile_size to 128 instead of 256, you should get a 50% overlap.

Best wishes, Mart

michelbotros commented 1 year ago

Thanks Mart, it went over my head that it takes into account the ratio between the batch shape spacing and spacing level 0 in the image as well.