pyvips icon indicating copy to clipboard operation
pyvips copied to clipboard

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

Open tuttelikz opened this issue 1 year ago • 4 comments

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

tuttelikz avatar Feb 22 '24 08:02 tuttelikz

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.

jcupitt avatar Feb 22 '24 10:02 jcupitt

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.

tuttelikz avatar Feb 27 '24 06:02 tuttelikz

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

jcupitt avatar Feb 27 '24 10:02 jcupitt

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

tuttelikz avatar Mar 04 '24 17:03 tuttelikz