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

Unable to read in all image layers in .vdi file, only index 0 is read in #364

Open
RYY0722 opened this issue Aug 7, 2023 · 3 comments
Open
Labels
bug Something isn't working

Comments

@RYY0722
Copy link

RYY0722 commented Aug 7, 2023

HESlide and Slidedata only read in the top one image in .vdi file
I use the BioformatsReader in cellprofiler_core.readers.bioformats_reader to read the ets file, which contains three images as shown in QuPath. However, only the image with index 0 is read in.

To Reproduce

from pathml.core import HESlide, SlideData, types
my_zeiss_zvi = HESlide("data/Image_06.vsi",
                         labels = {"target" : "HER-2"},
                         slide_type = types.HE)

It gives

SlideData(name='Image_06.vsi',
        slide_type=SlideType(stain=HE, platform=None, tma=None, rgb=True, volumetric=None, time_series=None),
        filepath='data/Image_06.vsi',
        backend='bioformats',
        image shape: (61115, 130754),
        number of levels: 23,
        0 tiles: [],
        0 masks: [],
        1 labels: ['target'],
        counts=None)

The width and height is concordant with the full-resolution image. Does it indicate that the full resolution image is loaded?
However, it seems that only the label image is loaded. When I run tile = my_zeiss_zvi.extract_region((0,0), (1000,1000), level=3).squeeze()
It gave
image

It seems that only the top one image is loaded.
Expected behavior
Can I specify the associated .ets file to process the full-resolution image in python?

Desktop (please complete the following information):

  • OS: [VERSION="20.04.5 LTS (Focal Fossa)", ID=ubuntu, ID_LIKE=debian]

Thank you very much!!!!! I have been struggled for quite a long time to read .ets and .vsi files in python. Looking forward to the help and advice!!!

@RYY0722 RYY0722 added the bug Something isn't working label Aug 7, 2023
@jacob-rosenthal
Copy link
Collaborator

The image shape printed in the SlideData object is the shape of the largest image level.
It looks like your image has 23 levels, so I guess one of those is probably the full-resolution image.
You should be able to check the shapes of each level's image by looking at my_zeiss_zvi.slide.shape_list to help find the one that you are looking for.
Hope this helps!

@RYY0722
Copy link
Author

RYY0722 commented Aug 8, 2023

Thanks a lot for your reply!

  • But I am wondering whether it can read the full-resolution image since the .vsi file is of only 2.72MB. Should I specify the associated .ets file?
  • How to read the desired image layer or the desired shape? Since when I called my_zeiss_zvi.slide.generate_tiles(), it only reads the label image instead of the HE image.
  • How to handle large image file?
    My .ets file is of 1.76GB and the .vsi file is of 2.72 MB. When I called my_zeiss_zvi.slide.get_thumbnail() or extract_region((0,0), my_zeiss_zvi.slide.get_image_shape()), the following error occurred.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/yuyan/virtual_envs/torch38/lib/python3.8/site-packages/pathml/core/slide_backends.py", line 516, in get_thumbnail
    raise Exception(
Exception: Java arrays allocate maximum 32 bits (~2GB). Image size is (61115, 130754)

Would you give some suggestions regarding this situation?

Thanks again!

@jacob-rosenthal
Copy link
Collaborator

  • We rely on bioformats to know how to handle that image format, including how to handle the data being split into multiple files. I think it should work but I haven't ever tried with that particular file format before so I don't know
  • You should be able to pass level argument to generate_tiles() to specify which level to use
  • Instead of trying to load the entire image into memory, use the tile generator and process the image at tile-level. If you really want to have the full-resolution image in memory, then use the tile generator to extract the tiles into numpy arrays and then stitch the numpy arrays together into the full array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants