Skip to content

Export to Qupath does not work in headless mode from a script #9

@guillaumelegoc

Description

@guillaumelegoc
  • ABBA Python version: 0.3.0
  • Python version: 3.7.16
  • Operating System: Windows 10

Description

I want to export registration to the Qupath project programmatically from python.
To do this, I launch an ABBA instance in headless mode, I load a state file and run the export registration command :

aligner = abba.Abba('Adult Mouse Brain - Allen Brain Atlas V3p1', headless=True)
aligner.state_load(os.path.join(inputdir, inputfile))
aligner.select_all_slices()
aligner.export_registration_to_qupath(erase_previous_file=True)

The following line is printed :
Exporting slice img_001.ome.tiff registration to QuPath
But there is nothing written in the Qupath project.

There is an error raised during the loading of the state file (see below), but this error did not prevent me from doing things with abba_python previously (eg. converting coordinates).

Doing the same thing not in headless mode (eg. aligner = abba.Abba('Adult Mouse Brain - Allen Brain Atlas V3p1')), the output is more talkative, those lines are also printed :

Multipositioner : Save slice ROI to quPath project path\to\qproj\data\1\ABBA-RoiSet-Adult Mouse Brain - Allen Brain Atlas V3p1.zip
Multipositioner : Save transformation to quPath project path\to\qproj\data\1\ABBA-Transform-Adult Mouse Brain - Allen Brain Atlas V3p1.json

And the files are indeed exported.

So it seems the multipositionner does not really exist in headless mode and Qupath export relies on it (but converting coordinates does not so that is why the latter works) ?

Output

[java.lang.Enum.toString] [ERROR] Multipositioner : null
[ERROR] Command errored: ABBA - Load State
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at javax.swing.JFrame.<init>(JFrame.java:189)
        at ch.epfl.biop.atlas.aligner.MultiSlicePositioner.lambda$new$2(MultiSlicePositioner.java:134)
        at ch.epfl.biop.atlas.aligner.MultiSlicePositioner.lambda$new$4(MultiSlicePositioner.java:144)
        at ch.epfl.biop.atlas.aligner.MultiSlicePositioner.loadState(MultiSlicePositioner.java:1181)
        at ch.epfl.biop.atlas.aligner.command.ABBAStateLoadCommand.run(ABBAStateLoadCommand.java:27)
        at org.scijava.command.CommandModule.run(CommandModule.java:196)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:125)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:64)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:247)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
[java.lang.Enum.toString] [ERROR] Command errored: ABBA - Load State
java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at javax.swing.JFrame.<init>(JFrame.java:189)
        at ch.epfl.biop.atlas.aligner.MultiSlicePositioner.lambda$new$2(MultiSlicePositioner.java:134)
        at ch.epfl.biop.atlas.aligner.MultiSlicePositioner.lambda$new$4(MultiSlicePositioner.java:144)
        at ch.epfl.biop.atlas.aligner.MultiSlicePositioner.loadState(MultiSlicePositioner.java:1181)
        at ch.epfl.biop.atlas.aligner.command.ABBAStateLoadCommand.run(ABBAStateLoadCommand.java:27)
        at org.scijava.command.CommandModule.run(CommandModule.java:196)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:125)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:64)
        at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:247)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions