Saving ResultsTable as TXT does not work from Python Script when running in headless mode

Hi guys,

I have a strange problem, where I need help. I created a python script for Fiji, which is up-to date on my Windows 10 system. The script works fine when started from Fiji itself.

When I run the script now in headless mode from the commandline i get the output below. There is no error message or something, but the TXT file is just not saved.

c:\Users\m1srh\Documents\Fiji
λ Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/c:/Users/m1srh/DOCUME~1/Fiji/jars/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/c:/Users/m1srh/DOCUME~1/Fiji/jars/slf4j-simple-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
17:34:44,981 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [jar:file:/c:/Users/m1srh/DOCUME~1/Fiji/jars/mitobo-1.8.4.jar!/logback-test.xml]
17:34:44,982 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback-test.xml] occurs multiple times on the classpath.
17:34:44,982 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback-test.xml] occurs at [jar:file:/c:/Users/m1srh/DOCUME~1/Fiji/jars/mitobo-1.8.4.jar!/logback-test.xml]
17:34:44,982 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback-test.xml] occurs at [jar:file:/c:/Users/m1srh/DOCUME~1/Fiji/plugins/Mosaic_ToolSuite/MosaicSuite-1.0.8_Full.jar!/logback-test.xml]
17:34:45,008 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@27ead29e - URL [jar:file:/c:/Users/m1srh/DOCUME~1/Fiji/jars/mitobo-1.8.4.jar!/logback-test.xml] is not of type file
17:34:45,154 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
17:34:45,157 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
17:34:45,168 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
17:34:45,178 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
17:34:45,267 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
17:34:45,267 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
17:34:45,268 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
17:34:45,269 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@4c060c8f - Registering current configuration as safe fallback point

SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
[INFO] Overriding BIOP Run Macro...; identifier: command:ch.epfl.biop.macrorunner.B_Run_Macro; jar: file:/c:/Users/m1srh/DOCUME~1/Fiji/plugins/BIOP/B_Run_Macro-1.0.0-SNAPSHOT.jar
[INFO] Overriding Save Image As Tiff Without Prompt; identifier: script:ZenIntegration/Save_Image_As_Tiff_Without_Prompt.java; jar: file:/c:/Users/m1srh/DOCUME~1/Fiji/jars/scijava-common-2.65.0.jar
Okt 24, 2017 5:34:48 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
[INFO] Script Directory: c:\Users\m1srh\Documents\Fiji\Scripts
c:\Users\m1srh\Downloads\test\OverViewScan_Test_raw_stitched.czi
[INFO] Filename                      : c:\Users\m1srh\Downloads\test\OverViewScan_Test_raw_stitched.czi
[INFO] BinFactor                     : 4
[INFO] Filter Radius                 : 3
[INFO] Min. Partice Size             : 1000
[INFO] Min. Circularity              : 0.99
[INFO] Max. Circularity              : 0.01
[INFO] Add Particles to ROI-Manger   : False
[INFO] Save Particles as Image       : True
[INFO] Save Format                   : txt
[INFO] Save Results                  : True
[INFO] --------------  START IMAGE ANALYSIS --------------
[INFO] Opening Image ...
[INFO] File Extension   : .czi
[INFO] Resolution Count : 1
[INFO] SeriesCount      : 2
[INFO] Getting Image Series : 0
[INFO] Start Processing ...
[INFO] Apply Binning ...
[INFO] Apply Filter ...
[INFO] Convert to 8-bit ...
[INFO] Apply Threshold ...
[INFO] Saving Processed Image to : c:\Users\m1srh\Downloads\test\OverViewScan_Test_raw_stitched_PA.ome.tiff
[INFO] Save Results to : c:\Users\m1srh\Downloads\test\OverViewScan_Test_raw_stitched_RESULTS.txt
[INFO] FileCheck Result : False
[INFO] Done.

The respective part of the python script is shown beloe and works fine when running the script from the Fiji Script Editor, but not in headless mode. But I can still remember seen it working also in headless a while ago.

I could really need help here since I currently have no workaround to save the table otherwise yet.

# run image analysis pipeline
pastack, results = run(imagefile)

if PASAVE:
    # save the particle stack
    savepath_pastack = ExportTools.savedata(pastack, imagefile,
                                            suffix=SUFFIX_PA,
                                            extension=SAVEFORMAT)
    log.info('Saving Processed Image to : ' + savepath_pastack)

if RESULTSAVE:
    # save the result table as file
    rtsavelocation = AnalyzeTools.create_resultfilename(imagefile,
                                                        suffix=SUFFIX_RT,
                                                        extension=SAVEFORMAT_RT)
    results.saveAs(rtsavelocation)
    log.info('Save Results to : ' + rtsavelocation)

    filesaveOK = os.path.exists(rtsavelocation)
    log.info('FileCheck Result : ' + str(filesaveOK))

Hi guys,

I found it and as expected I was just too stupid… I mixed up min and max particle size for the noe-working approach. That always resulted in zero detections and therefore no results. Consequently this could not be saved.