Closed ciaobladoo closed 3 weeks ago
Hi @ciaobladoo , thanks for opening this issue! The pipeline is designed to handle any WSI as long as the required resolution is available, but I am guessing something else is wrong in your instance.
First, the required resolution (in microns per pixel) are defined here Including what the pipeline understands as 20x or 40x magnification.
Do you mind posting the output of this snippet for the WSI you are trying to run? You can e.g. put it into a pastebin or upload a txt. (and remove e.g. the filename).
import openslide
sl = openslide.open_slide("/path/to/aaa.mrxs")
print(sl.properties)
Also, are you trying to run the pannuke model or lizard model?
Thanks @eliasbaumann for the quick response. I am running the Pannuke model as of now - I have been using HoverNet trained on Pannuke for years and wanted to compare HoverNext's performance when trained on the same data. Here is the properties of my WSI with file name redacted (it is in SVS format).
<_PropertyMap {'aperio.AppMag': '20', 'aperio.DSR ID': 'spectrum', 'aperio.Date': '12/16/19', 'aperio.DisplayColor': '0', 'aperio.Exposure Scale': '0.000001', 'aperio.Exposure Time': '32', 'aperio.Filename': 'REDACT', 'aperio.Focus Offset': '-0.000500', 'aperio.ICC Profile': 'AT2', 'aperio.ImageID': 'REDACT', 'aperio.Left': '19.990498', 'aperio.LineAreaXOffset': '0.003218', 'aperio.LineAreaYOffset': '-0.008448', 'aperio.LineCameraSkew': '-0.000502', 'aperio.MPP': '0.5029', 'aperio.OriginalHeight': '18919', 'aperio.OriginalWidth': '24384', 'aperio.Parmset': 'Clinical: Faintly Stained and No Skipping', 'aperio.ScanScope ID': 'SS7283', 'aperio.SessonMode': 'NR', 'aperio.StripeWidth': '2032', 'aperio.Time': '17:36:51', 'aperio.Time Zone': 'GMT-06:00', 'aperio.Top': '17.793673', 'aperio.User': '00000000-0000-0000-0000-000000000000', 'openslide.comment': 'Aperio Image Library v12.0.15 \r\n24384x18919 [0,100 23904x18819] (240x240) JPEG/RGB Q=70|AppMag = 20|StripeWidth = 2032|ScanScope ID = SS7283|Filename = REDACT|Date = 12/16/19|Time = 17:36:51|Time Zone = GMT-06:00|User = 00000000-0000-0000-0000-000000000000|Parmset = Clinical: Faintly Stained and No Skipping|MPP = 0.5029|Left = 19.990498|Top = 17.793673|LineCameraSkew = -0.000502|LineAreaXOffset = 0.003218|LineAreaYOffset = -0.008448|Focus Offset = -0.000500|DSR ID = spectrum|ImageID = REDACT|Exposure Time = 32|Exposure Scale = 0.000001|DisplayColor = 0|SessonMode = NR|OriginalWidth = 24384|OriginalHeight = 18919|ICC Profile = AT2', 'openslide.level-count': '3', 'openslide.level[0].downsample': '1', 'openslide.level[0].height': '18819', 'openslide.level[0].tile-height': '240', 'openslide.level[0].tile-width': '240', 'openslide.level[0].width': '23904', 'openslide.level[1].downsample': '4.0003188775510203', 'openslide.level[1].height': '4704', 'openslide.level[1].tile-height': '240', 'openslide.level[1].tile-width': '240', 'openslide.level[1].width': '5976', 'openslide.level[2].downsample': '8.0006377551020407', 'openslide.level[2].height': '2352', 'openslide.level[2].tile-height': '240', 'openslide.level[2].tile-width': '240', 'openslide.level[2].width': '2988', 'openslide.mpp-x': '0.50290000000000001', 'openslide.mpp-y': '0.50290000000000001', 'openslide.objective-power': '20', 'openslide.quickhash-1': 'b7b3071fd0c036a5626fff83b97384081711308ec38b8204a2bcce1559ddf4f8', 'openslide.vendor': 'aperio', 'tiff.ImageDescription': 'Aperio Image Library v12.0.15 \r\n24384x18919 [0,100 23904x18819] (240x240) JPEG/RGB Q=70|AppMag = 20|StripeWidth = 2032|ScanScope ID = SS7283|Filename = REDACT|Date = 12/16/19|Time = 17:36:51|Time Zone = GMT-06:00|User = 00000000-0000-0000-0000-000000000000|Parmset = Clinical: Faintly Stained and No Skipping|MPP = 0.5029|Left = 19.990498|Top = 17.793673|LineCameraSkew = -0.000502|LineAreaXOffset = 0.003218|LineAreaYOffset = -0.008448|Focus Offset = -0.000500|DSR ID = spectrum|ImageID = REDACT|Exposure Time = 32|Exposure Scale = 0.000001|DisplayColor = 0|SessonMode = NR|OriginalWidth = 24384|OriginalHeight = 18919|ICC Profile = AT2', 'tiff.ResolutionUnit': 'inch'}>
Okay so according to this output 'openslide.mpp-x': '0.50290000000000001', 'openslide.mpp-y': '0.50290000000000001',
, your image is scanned at 0.5mpp which is too low res for pannuke. If you want this to run anyways, you can overwrite the required mpp resolution in src/constants, but I would not recommend this, since the pannuke training tiles are from 0.25mpp scans.
I see. In your code the mpp for 20X should be 0.485, correct? Did you observe in your experiments that this kind of discrepancy will make a big difference in terms of segmentation/classification performance? Will I be able to run lizard model on this slide? If not I may need to create a branch and hack into your code so it can take any 20X images regardless of actual mpp.
I havent experimented with this. In the training, zoom and resizing are included as augmentation methods, so I would assume that there is some robustness to different magnifications. Yet the model is only evaluated against the high resolution images. The lizard model should run fine, if not please let me know. If you modify this line and for example include your own check to run at 20x anyways if there is no 40x mag you would get what you want.
Hi @eliasbaumann I dig into your code and now understood the inference can run properly for a 20X WSI with pannuke model (the tiles extracted from 20X will be rescaled to 40X). Only that post-process will report NotImplementedError. I may try to implement this myself. Could you let me know what is the main challenge that is preventing this to be implemented (is it in processing the prediction map to get the nuclei, or stitching tile results to a WSI)? Thanks!
Hi @ciaobladoo , sorry for not getting back to you about this sooner: If I remember correctly, I simply put this NotImplementedError there because I never tried and verified whether it works. I just ran a sample which only has 0.5mpp as highest resolution and uncommented lines 650-653 and the output seems fine? If you try this and experience any issues in the output, please let me know.
Sorry I forgot to reply. Yes your suggestion worked. The results on our dataset is pretty good. Except that the models trained on Lizard dataset was missing some nuclei in our dataset compared to the models that trained on pannuke. But overall it is very good. Thank you.
No worries, thanks for getting back to me. For the Lizard model, you could manually adjust the object size thresholds to make sure more small objects are included. The thresholds are optimized for the Lizard dataset, which may not always be the best choice in practice
Thanks for this amazing work. I am trying it on our WSIs. I got this warning "Slide magnifications 40 do not match expected target magnification". (This is interesting since original Hovernet expects 40X rather than 20X). Is there an option to downsample the WSI (i.e., using level 1 instead of level 0 when loading with openslide). Thanks!