Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remote backends #221

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Feature/remote backends #221

wants to merge 17 commits into from

Conversation

jonasteuwen
Copy link
Contributor

Add remote backends

@github-actions github-actions bot added the Stale label Jun 17, 2024
@github-actions github-actions bot closed this Jul 3, 2024
@BPdeRooij BPdeRooij reopened this Jul 4, 2024
@github-actions github-actions bot removed the Stale label Jul 5, 2024
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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants