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

Is the slide resolution taken into account when extracting tiles ? #8

Open
CharlieCheckpt opened this issue Aug 9, 2023 · 1 comment

Comments

@CharlieCheckpt
Copy link

Hello,
Thank you for this nice package !

I used histoprep on two slides with different resolutions.
One was scanned at a mpp of 0.25, the other one with a mpp of 0.5. It seems that when extracting the tiles with the following code, it reads images of size 512x512 at the lowest openslide level, without taking in account the resolution. This implies that the cell scale etc.. differs between the images extracted on the two different slides (see images below, first is mpp 0.25, second is mpp 0.5).

from histoprep import SlideReader

# Read slide image.
reader = SlideReader("./slides/slide_with_ink.jpeg")
# Detect tissue.
threshold, tissue_mask = reader.get_tissue_mask(level=-1)
# Extract overlapping tile coordinates with less than 50% background.
tile_coordinates = reader.get_tile_coordinates(
    tissue_mask, width=512, overlap=0.5, max_background=0.5
)
# Save tile images with image metrics for preprocessing.
tile_metadata = reader.save_regions(
    "./train_tiles/", tile_coordinates, threshold=threshold, save_metrics=True
)
image image

Is this an intended behaviour or am I missing something?
Best

@jopo666
Copy link
Owner

jopo666 commented Sep 1, 2023

This is intended behaviour. If this feature is something that you need feel free to add a pull request! This could be implemented for example as a helper method get_width_from_mmp, which could then be passed into get tile coordinates.

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

No branches or pull requests

2 participants