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
1 Like

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