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

Create svs file with image pyramid, label and macro in pyvips? #455

Open
tuttelikz opened this issue Feb 22, 2024 · 4 comments
Open

Create svs file with image pyramid, label and macro in pyvips? #455

tuttelikz opened this issue Feb 22, 2024 · 4 comments

Comments

@tuttelikz
Copy link

How write/create .svs image and add associated images, label and macro? Is it possible in pyvips?

@jcupitt
Copy link
Member

jcupitt commented Feb 22, 2024

Hi @tuttelikz,

SVS is not a standard TIFF format, so standard TIFF readers and writers can't handle it. pyvips uses the openslide library to read SVS, but there's no SVS writer.

You might be able to write it using a lower level library like tifffile, but it'd be quite a lot of work. Maybe a week's effort? The openslide website has some docs on the layout: https://openslide.org/formats/aperio/

If possible, I would use tiled jpeg pyramidal TIFF. This is very similar to SVS, but is a standard and can be read by most programs. For example:

image.tiffsave("x.tif", compression="jpeg", tile=True, pyramid=True)

It looks like DICOM WG26 will be generally replacing vendor formats like SVS, so you could also consider that.

@tuttelikz
Copy link
Author

Hi @jcupitt,

Thanks for your reply and thanks for keeping this library 👍🏼

Yes, I have been experimenting with the mentioned tiffsave functionality up to now as suggested to save image pyramid.

The task I was trying to solve further, and wondered if pyvips can help for this case;
Making a single tiff file: image pyramid as well as associated images (eg. macro, label or overview), so that QuPath can automatically detect it (openslide or bioformats) with a metadata (resolution, magnification). I attached image screenshot for illustration.

sample
Source:
https://openslide.cs.cmu.edu/download/openslide-testdata/Ventana/Ventana-1.bif

Based your response, it seems I should better check with tifffile (Dicom is not preferred for my particular case).

Actually, there is no principal difference for me, if it's SVS, Roche-Tiff, or other WSI format for TIF.

@jcupitt
Copy link
Member

jcupitt commented Feb 27, 2024

DICOM is the standard non-vendor format for WSI images, so that'd be the one to pick IMO.

QuPath uses OME TIFF, so you could try that. It's pretty simple -- a planar subifd TIFF pyramid, with some XML in the IMAGEDESCRIPTION tag with all the metadata.

I posted some sample pyvips code here:

https://forum.image.sc/t/writing-qupath-bio-formats-compatible-pyramidal-image-with-libvips/51223/14

@tuttelikz
Copy link
Author

Thanks for the recommendation. I will check on OME-TIFF later this week.

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