Skip to content

Feature/remote backends#221

Closed
jonasteuwen wants to merge 254 commits intomainfrom
feature/remote-backends
Closed

Feature/remote backends#221
jonasteuwen wants to merge 254 commits intomainfrom
feature/remote-backends

Conversation

@jonasteuwen
Copy link
Contributor

Add remote backends

jonasteuwen and others added 30 commits June 7, 2021 18:48
* New API for tiling, WholeSlideImage
* Added basic tests, drafted new API
* Use pre-commit fixes, adding pydantic to dev req
* Added tox 
* Implemented CI with Github Actions (Closes #8)
* New CLI interface for tiling (Closes #3)

Co-authored-by: Leonardo Romor <leonardo.romor@gmail.com>
Co-authored-by: Mensel123 <43986008+Mensel123@users.noreply.github.com>
Co-authored-by: Francesco Dal Canton <francidalca@gmail.com>
- Bugfix to improper int casting which was sometimes breaking the read_region method.
- Improved read_region() docstring.
- Added related testcase.
Update Docker
- Make resulting docker smaller
- Install pixman and cairo from scratch
- Compile pytorch and torchvision specifically for dlup
* Update documentation
- Added warning to installation.rst that pixman 0.40 or higher is required.

* Update documentation
- Added line about virtual environment, move pixman warning up.

* Update documentation
- Added information about openslide versions.
* Improved SlideImage initialization exception messages.
* Convert tiling tool to new Dataset class
* Improve mypy and pylint parsing
* Create Dataset class that reads from tiles
* Updated docstrings
* Few CI fixes
* Removed previous glue code to ease development and introduce caching. (#29)
* Removed TiledRegionView class, replaced with a leaner Lattice class that serves as
  interface to generate a lattice.
* Added LRU cache on top of the dataset, to reduce memory requirements.
* Bump version: 0.2.0-dev0 → 0.2.0-dev3

Co-authored-by: Leonardo Romor <leonardo.romor@gmail.com>
* Remove pytorch dependency (Closes #18)
* Add possibility to check if pytorch is available
- Added support for an extra parameter during Grid() creation to specify a global offset for
every coordinate.
- Improved naming and docstring
Use multiprocessing for tile extraction
* Refactored dataset class
* Added TiledROIsSlideDataset class to allow flexible tiling, at different mpps for different ROIs.
* Added more parameters to returned dictionary to backtrack original grid of a tile.
* Remove joblib
* Added dataset example to documentation https://docs.aiforoncology.nl/dlup/dataset_examples.html

Co-authored-by: Jonas Teuwen <j.teuwen@nki.nl>
…turn rgba pil in SlideImageDataset, return rgb pil for thumbnail (#43)

Consistently output RGBA PIL Images for DLUP datasets (closes #43)
* Return RGBA PIL Images for DLUP Datasets
* Return RGBA PIL Images for SlideImage.thumbnail
* Add TypedDicts to specify the returned objects of each dataset class
* Generally improve typing and docstrings
Allow saving the masks in cli tool
* Added FileNotFoundError to from_file_path()

* Raised FileNotFoundError while reading WSI.
* Add more flexibility for passing filepath to load WSI from in SlideImage
* Import sequence from `collections.abc`, not from `collections`. This is soon deprecated.
* Upgrade scikit-image version to version above 0.19
* Add example shell tool to tile entire directory of wsis
* Update documentation
* Added experimental multiscale dataset
* Add out-of-region reading and pad with zeros
BPdeRooij and others added 3 commits August 14, 2024 00:16
* Add z_index to geojson properties when importing and exporting
* Fix annotation crop for Polygons in read_region and test_annotations
* Created new AnnotatedGeometry, adhere to shapely dunder and functions
* Add helper function to utils and Enum for Darwin/ASAP annotation types
* Add darwin_annotation_type to color look up and move Darwin util function to utils
* Bugfix for WsiAnnotations.filter function
@codecov
Copy link

codecov bot commented Aug 29, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@BPdeRooij BPdeRooij marked this pull request as ready for review September 6, 2024 11:24
@BPdeRooij
Copy link
Contributor

BPdeRooij commented Sep 6, 2024

PR overview

This PR implements three new backends. These new backends are an abstract class RemoteSlideBackend, DeepZoomSlide and SlideScoreSlide. DeepZoomSlide is mainly created to support the remote SlideScoreSlide backend, which uses API calls to a DeepZoom tile server provided by SlideScore.

To use the SlideScoreSlide backend:

  1. Install the optional dependencies (slidescore_remote)
  2. Export your slidescore API key (with the correct privileges) using dlup.backends.slidescore_backend.export_api_key
  3. Use a SlideScore URL (from a study for which your API key has the correct privileges) as the input for filename (SlideScoreSlide), wsi_file_path (SlideImage.from_file_path), or path (TiledWsiDataset).
  4. Use the initialized wsi object how you normally would.

Changes

  • Introduced new backends RemoteSlideBackend, DeepZoomSlide and SlideScoreSlide.
  • Added backend utility functions to parse deep zoom dzi and xml files.
  • Allow RemoteSlideBackend to use strings as wsi_file_path in dlup._image
  • Added optional dependecy slidescore_remote, which installs aiohttp for asynchronous requests to SlideScore's tile server.

Notes

  • The focus of this PR was mainly on the SlideScoreSlide backend. The DeepZoomSlide has been tested using several different conversion methods (libvips vs openslide, different overlaps, different tile sizes, etc.), but is not guaranteed to work in every scenario.
  • When creating deep zoom files with libvips, cmyk colourspace can be used. This will also output images, which use the same colourspace. Converting to rgb is possible, but this will create altered colours when this conversion is done with pyvips. RGB colours seem correct when the conversion is done with PILLOW. SlideScore API calls will output images with RGB colours. Do we always want to convert output images to RGB?
  • Using pyvips.arrayjoin in the read_region would probably be faster than inserting each tile into the blank canvas, but this is not possible due to edge tiles having different sizes.
  • A maximum of 6 simultaneous asynchronous requests are made to the Slidescore tile server. This limit was set after discussion with Jan Hudecek. Using a lot of simultaneous calls can cause the tile server to crash. Therefore, this backend is better suited for inference or without using multiprocessing.
  • ICC profiles are stripped when creating deep zoom tiles and slidescore does not (yet) support retrieval of the ICC profile. Thus, ICC profiles are not included. (Update: I am currently in contact with Jan to get ICC profiles supported for SlideScoreSlide)
  • No tests are written for the new backends.

Please let me know what you think of these new features and any potential changes you would like to see!

from dlup.backends.common import AbstractSlideBackend


class RemoteSlideBackend(AbstractSlideBackend):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what this is haha. Maybe some docs could help :)

jonasteuwen and others added 3 commits September 26, 2024 10:56
- Add DLUP XML output
- Rewrite setup to use meson-py

---------

Co-authored-by: Bart de Rooij <33282665+BPdeRooij@users.noreply.github.com>
Co-authored-by: Jonas Teuwen <j.teuwen@.nki.nl>
Co-authored-by: JorenB <jorenb@gmail.com>
- Use dynamic loading for annotation reading and writing
@github-actions github-actions bot added the Stale label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.