CZI label and scene woes with QuPath

Can I start by saying I LOVE QuPath, it’s hands down my favourite image analysis software.

I have two recurring issues reading .CZI files from our Axioscan that I’m hoping someone might be able to help with?

Firstly, the label image always looks black, I gather that’s because it somehow ends up as a 16 bit image? I can export as png and adjust until visible but it’s not practical if you’re working with lots of images and need to quickly check what the slide label is. Is there a workaround? I tried Pete’s QuPath-extract_label script but it isn’t happy (v0.2.3 of QuPath, I can post the script and error if helpful?)

Secondly, CZI files with more than one scene import as separate scenes in the image list. Usually I put multiple tissues from one experiment onto a slide and would prefer QuPath not to split scenes, is there a way to specify the concatenate series option from BioFormats when opening CZIs so scenes stay together?

Thank you

2 Likes

Great! :partying_face:

How are you accessing the label? Does you see something like the image below at the bottom of the ‘Image’ tab? If so, you can double-click an image to view it and it should do some contrast adjustment.

Screenshot 2020-12-07 at 19.19.02

I’m not aware of any Bio-Formats option that would keep the scenes together. There is a "zeiss.autostitch" option, but this should already be turned on and I believe it does something else to what you want.

See this discussion for more:

2 Likes

The label image from our Axioscan has an irritating 1 pixel white border on the left side that messes with autocontrast. My workaround:

  1. Open ImageJ by sending any region at all with the ImageJ button:
    image
    Close that image, you don’t need it.
  2. Open the label image. Copy it with Edit > Copy
  3. Go to ImageJ and create a new image from clipboard:
    image
  4. Adjust brightness/contrast manually
2 Likes

Yes, I think I have the same issues as @smcardle pointed out, looks like there’s a band of white pixels on the left.

Is that an issue with Zen rather than QuPath? Any way around it in QuPath? I can export it and adjust like @smcardle points out but when you’ve got a lot of slides in a project it’s quite time consuming.

Sorry, should have been clearer, this post from @sebi06 shows how to do it with the BioFormats plugin Configuration in Fiji I think opening-multiscene-czi-files-with-fiji

Yes, that’s the ‘autostitch’ option I’m referring to. It is turned on in Bio-Formats (and therefore QuPath) by default, but as @sebi06’s post shows you would still get 2 distinct scenes. With the option turned off, I believe you’d get a multitude of tiles instead.

I think the link in my last answer has more relevant information.

I didn’t know about the white pixel border before; any .czi images I’ve worked with didn’t have this and so the autocontrast in QuPath worked. And most other scanners I’ve encountered have RGB images for labels and so it hasn’t mattered.

Therefore any solution in the short term would require a script. I’ve written so many over the years that I don’t know which is the one you refer to in your original post – if a script would address your need, please do include a link & the error you see.

1 Like

I got the impression you could keep scenes together by specifying the preference “concatenate series when compatible”, apologies if I’ve misunderstood.

Thanks, here’s the script I tried https://gist.github.com/petebankhead/863352f92d17facb15bb5cf35ed03f56.js

Error below

ERROR: MissingMethodException at line 27: No signature of method: qupath.lib.images.servers.bioformats.BioFormatsImageServer$BioFormatsReaderManager.getPrimaryReader() is applicable for argument types: (qupath.lib.images.servers.bioformats.BioFormatsImageServer, String) values: [Bio-Formats: BioFormatsImageServer: file:/Users/*** ...]

ERROR: org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70)
    org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
    org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
    Script1.run(Script1.groovy:28)
    org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317)
    org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155)
    qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:926)
    qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:859)
    qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:782)
    qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1271)
    java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    java.base/java.lang.Thread.run(Unknown Source)

I’ve updated the script so it should work with QuPath v0.2:

1 Like

Amazing, thank you it works perfectly! :grinning_face_with_smiling_eyes:

Do you think there’s a way to keep scenes together when opening CZI files?

Not through Bio-Formats options alone, I’m afraid. This question has come up quite often – I’m having trouble finding relevant conversations for QuPath specifically, but here’s a general one

1 Like

Hi, the label image is produced with the 12 bit preview camera so the data are 16 bit. But the white line shouldn’t be there. Is there a way you can post a link to an example CZI where you see this? I can have a look.

2 Likes

I would also have a look.

Sure, have sent you both links to the whole .CZI

Thanks

Thanks for sending, this is indeed weird. We have tried to reproduce this with one of our Axio Scan.Z1’s and could not reproduce this, there is no white line anywhere around the edges. I would recommend to file a support case with your local ZEISS reps. What would be helpful is also to create an error log with logging level “debug” and send this with the report.

2 Likes

We are currently looking into it. This is indeed a bit “weird”.

  • metadata show bgr48
  • image information shows 36bit
  • when “hovering” over the image you see pixel values like (180, 190, 231)
  • when hovering over the white line exactly one will see (65535, 65535, 65535)

So I can only speculate what went wrong here. The image has one channel in ZEN, which is actually an BGR composite. While CZI itself supports having different pixeltypes per channel, this one seemed to have gotten mixed up. It maybe has to do with the older versions of the preview camera etc. (just speculating).

At least I have no idea right know, how it would be even possible to create such an CZI. Let’s see …

1 Like

With respect to the question to “keep” multiple scenes together I have some remarks.

  • the option to keep multiple scenes (tile regions etc.) in their spatial context was one of the design criteria of the CZI file formats
  • on the other side is having all scenes in one CZI file the reason why it not easy to read this via BioFormats without losing this context → no offense, but OME-TIFF was just not designed for this in the first place
  • so our ZEISS solution to keep any file incl single scenes in “context” in called ZEN Connect + ZEN Data Storage (incl. WebViewer)
  • an with ZEN’s 3rd party import (we have a commercial licence for BioFormats) this allows the user to keep all their files in the spatial context, even if they were not acquired on one of our systems

And as @Christian_Tischer pointed out, one very important use case for use is what we call “Guided Acquisition”

  • start ZEN Connect project
  • system acquires low-res overview scan of sample → store in ZEN Connect automatically
  • image analysis incl DeepLearning and external code “finds” the interesting regions
  • experiment is automatically modifies based on the IA results
  • systems loops over the regions → one CZI per loop → store in ZEN Connect
  • ZEN Connect in the end shows and stored the spatial context
  • all the data incl the IA results can be stored inside ZEN Data Storage (data base) and can be viewed etc. via the ZEN Data Explorer (WebViewer)

@JTpath @sebi06 : we found out, what the problem is: when you rotate the label image in ZEN’s Info tab, it creates the white line. In the original acquired label there is no white line. Good catch! Will try to get a hotfix for this.

5 Likes

Amazing, thank you! I did wonder why it was just me, will unrotate the labels for now. :grinning_face_with_smiling_eyes:

2 Likes