Skip to content

ValueError: level not present in slide #1

Description

@jasnei

Hi

I'm ready your paper SliDL: Atoolbox for processing whole-slide images in deep learning. just want to do a annotation extraction.

Just simple copy & past from your example notebook 'slidl-tutorial.ipynb, following is the code. Same slide name from CAMELYON16 as your mentioned in the notebook. actually I just want to try the extraction of tile from annotation. but it would let me .

from slidl.slide import Slide
tile_size = 512
fp = 'CAMELYON16/training/tumor/tumor_044.tif'
slide = Slide(fp, level=0, verbose=True)
slide.setTileProperties(tileSize=512, tileOverlap=0, unit='px')
slide.addAnnotations(fp[:-3] + 'xml', negativeClass='negative')
slide.extractAnnotationTiles('data/CMU-1_slidl')

and I got following issue, I think I set all level to all the method, but still cannot fix this issue.

[SliDL] Loading /mnt/f/BaiduNetdiskDownload/CAMELYON16/training/tumor/tumor_044.tif
[SliDL] Successfully loaded
Warning: 'vips-loader' not present in slide properties; verify independently that slide has loaded properly.
[SliDL] 0 properties were successfully imported
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[50], line 1
----> 1 slide.addAnnotations(fp[:-3] + 'xml', negativeClass='negative')

File ~/anaconda3/envs/histo/lib/python3.9/site-packages/slidl/slide.py:636, in Slide.addAnnotations(self, annotationFilePath, classesToAdd, negativeClass, level, overwriteExistingAnnotations, mergeOverlappingAnnotationsOfSameClass, acceptMultiPolygonAnnotations)
    634     raise ValueError('level must be an integer 0 or greater')
    635 if 'openslide.level['+str(level)+'].downsample' not in self.slideProperties:
--> 636     raise ValueError('level not present in slide')
    637 if (classesToAdd) and (not isinstance(classesToAdd, list)):
    638     raise ValueError("classestoAdd must a list")

ValueError: level not present in slide

According to the verbose messege, i try following code, and I got a [], it should be the slide not read properly by the vips, however, I could get the thumbnail properly.

slide.slide.get_fields()

Please advise how could I fix this issue

Thanks
Albert

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions