caMicroscope icon indicating copy to clipboard operation
caMicroscope copied to clipboard

Low correlation between the classification model loaded in caMicroscope and the model created in Python

Open LinaRuiz10 opened this issue 3 years ago • 13 comments

I'm using caMicroscope to load a dataset containing images in JPEG format. I read in an old issue that this format is not allowed to load, so I converted each image to a TIFF pyramid with VIPS. After that, I was able to load and view images without problem. Also, I have a classification model loaded in caMicroscope, when I do the prediction for some reason, I get a different result with respect to the result obtained making the forward in a Python environment. Checking the patches extracted by the tool, I can see that are extracted wrong (you can see this in the attached image), or even it is as if it extracts a patch that does not correspond to the selected one.

The process has been:

  1. Load the image converted from JPG to TIFF pyramid into the viewer.
  2. Load the classification model and select the 'Predict' button.
  3. Select the region to predict.
  4. Pressing F12 key and 'Network'. In this part, we can visualize the result of each patch.

I expect that the model result loaded in caMicroscope coincides with the result of the Python model. I'm using Ubuntu 18.04 and Google Chrome.

WhatsApp Image 2021-03-01 at 7 43 33 PM

LinaRuiz10 avatar Mar 02 '21 01:03 LinaRuiz10

Thanks for reporting! Is this something you're interested in taking a look at? No pressure, if not, we will :)

birm avatar Mar 02 '21 02:03 birm

I have already checked, and I suspect the error is in extracting the patch or converting the JPG image to TIFF, but I am not sure.

LinaRuiz10 avatar Mar 02 '21 14:03 LinaRuiz10

The biggest symptom of bad VIPS conversion has been, in my experience, shifting as zoom levels change. That IIIF call's preview (thanks for including it) does look substantially worse than I'd expect even at that though.

Would you be able/willing to share the converted file? Also, if it's any help, here are the vips flags I've been using - https://github.com/camicroscope/SlideLoader/blob/122437a6dd038a5fe1b41ca07ef9d4567b2e1805/SlideServer.py#L73

birm avatar Mar 04 '21 03:03 birm

Yes, I think the same. I'm going to try with the parameters you shared with me. To which email address could I send you the image?

LinaRuiz10 avatar Mar 04 '21 15:03 LinaRuiz10

you can use ryan.birmingham - at - dbmi.emory.edu

birm avatar Mar 04 '21 15:03 birm

is the bug resolved? if not, i would like to make effort in the direction to solve it.

harry-dev98 avatar Mar 26 '21 05:03 harry-dev98

Indeed, the bug hasn't been resolved yet. We are still trying to make effort to solve it. Would you like to help us?

LinaRuiz10 avatar Mar 26 '21 15:03 LinaRuiz10

yupp.. i am already exploring the project, any suggestions where to start from?

harry-dev98 avatar Mar 26 '21 15:03 harry-dev98

@harry-dev98 I'm unsure if this is an issue with the vips conversion or the tile server (or both). A good first step would be to isolate which component is causing this issue.

birm avatar Mar 26 '21 17:03 birm

That will load all the JPG image in the current directory, assemble them into a huge grid, 20 images across, and write as a TIFF pyramid. You'd need to check the size of your grid, obviously, and adjust the across parameter.

The $() part sorts the filenames of the form x_y.jpg by y first, then x, in numeric order. Without that, the tiles will be transposed, annoyingly.

That's assuming overlap 0. If your tiles have an overlap, you'll need to set the hspacing and vspacing options to control how tiles are positioned. For example: vips arrayjoin "$(ls *.jpg | sort -t_ -k2g -k1g)" x.tif --across 20 --hspacing 254 --vspacing 254

AbhisekOmkar avatar Apr 06 '21 03:04 AbhisekOmkar

I did the conversion with VIPS array join and it works. RoI extraction and shifting as zoom levels change works. However, the regions to predict extracted by IIIF are still wrong. It extracts regions that don't match the selected region

LinaRuiz10 avatar Apr 11 '21 21:04 LinaRuiz10

has the issue been resolved yet? If not can someone guide me in the correct direction, I would like to help for the same.

aditya-agrawal-30502 avatar May 21 '21 04:05 aditya-agrawal-30502

I don't think this has been resolved. I'm still not confident if it's a vips or iip issue (or both).

I have some thoughts on how someone may investigate further: To test if it's vips, try the conversion a few different ways, and see if they all exhibit similar issues. To test if it's iip, try fetching different regions of a known good image using different protocols. From caMicroscope, the urls look something like http://localhost:4010/img/IIP/raw/?FIF=/images/sample.svs&WID=200&CVT=png

Thank you for your interest, and I hope this helps.

birm avatar May 21 '21 15:05 birm