Run Fiji Python Script with parameters on Windows

python
scripting
Tags: #<Tag:0x00007fb87d5de228> #<Tag:0x00007fb87d5da970>

#1

Hi guys,

I check the tutorial and Scripting pages but must admit, that I am a bit stuck… I want to run a python script from the commandline on my windows 7 system. The script has the follwing input parameters:

# @File(label = "Image File", persit=True) FILENAME
# @Integer(label = "Binning Factor", value=4, persit=False) BINFACTOR
# @Float(label = "Filter Radius", value=3.0, perist=False) RADIUS
# @Integer(label = "PA - Min.Size", value=100000, perist=False) MINSIZE
# @Float(label = "PA - Min. Circularity", value=0.01,perist=True) MINCIRC
# @Float(label = "PA - Max. Circularity", value=0.99, perist=True) MAXCIRC
# @OUTPUT String FILENAME
# @OUTPUT Integer BINFACTOR
# @OUTPUT float RADIUS
# @OUTPUT Integer MINSIZE
# @OUTPUT float MINCIRC
# @OUTPUT float MAXCIRC

import os
...

Is this actually possible, because I read something about a bug for windows on Jython scripts in headless mode? Does this mean I should better switch back to the macro language (I would prefer to stick to python)?

Any help is appreciated.

Sebi


#2

Why don’t you try? For me, the following python script:

#@ File FILENAME
#@ Integer BINFACTOR
#@ Float RADIUS

print FILENAME
print BINFACTOR
print RADIUS

was giving the expected output when run by this command:

ImageJ-win64.exe --ij2 --headless --console --run Test_Script.py FILENAME='C:/temp',BINFACTOR=2,RADIUS=0.1
C:\temp
2
0.10000000149

The warning on the Headless page is referring to a bug report from 2015, I’m not sure if it’s still relevant, as we’re currently on Jython 2.7.0. (@ctrueden or @tinevez might be able to share more info)


Also:

Mind your typos :wink: None of your parameters above will have a persist behavior as desired…


#3

Thanks for the hint with the typos … :slight_smile:
I tried the following and run into problems …

PS C:\Users\Public\Documents\Fiji> .\ImageJ-win64.exe --ij2 --headless --console --run c:\Users\Public\Documents\Fiji\scripts\GuidedAcq_ROI.py FILENAME="c:\Users\M1SRH\Documents\Testdata_Zeiss\RareEvent_Test_Wizard\OverV
iewScan_Test_raw-Stitching.ome.tiff", BINFACTOR=4, RADIUS=3.0, MINSIZE=10000, MINCIRC=0.01, MAXCIRC=0.99
PS C:\Users\Public\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/Public/DOCUME~1/Fiji/jars/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/Public/DOCUME~1/Fiji/jars/slf4j-simple-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/Public/DOCUME~1/Fiji/plugins/bioformats_package.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
17:27:05,302 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [jar:file:/C:/Users/Public/DOCUME~1/Fiji/jars/mitobo-1.8.4.jar!/logback-test.xml]
17:27:05,304 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback-test.xml] occurs multiple times on the classpath.
17:27:05,304 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback-test.xml] occurs at [jar:file:/C:/Users/Public/DOCUME~1/Fiji/jars/mitobo-1.8.4.jar!/logback-test.xml]
17:27:05,304 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback-test.xml] occurs at [jar:file:/C:/Users/Public/DOCUME~1/Fiji/plugins/Mosaic_ToolSuite/MosaicSuite-1.0.5_Full.jar!/logback-test.xml]

17:27:05,331 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@7f4037ed - URL [jar:file:/C:/Users/Public/DOCUME~1/Fiji/jars/mitobo-1.8.4.jar!/logback-test.xml] is not of type file
17:27:05,498 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
17:27:05,501 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
17:27:05,521 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
17:27:05,530 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
17:27:05,601 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
17:27:05,601 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
17:27:05,603 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
17:27:05,604 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@24e8de5c - Registering current configuration as safe fallback point

SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
C:\Users\Public\DOCUME~1\Fiji\plugins\ilastik_HDF5-0.1.4.jar: java.util.zip.ZipException: error in opening zip file
C:\Users\Public\DOCUME~1\Fiji\plugins\ilastik_HDF5-0.1.4.jar: java.util.zip.ZipException: error in opening zip file
[INFO] Overriding Save Image As Tiff Without Prompt; identifier: script:ZenIntegration/Save_Image_As_Tiff_Without_Prompt.java; jar: file:/C:/Users/Public/DOCUME~1/Fiji/jars/scijava-common-2.64.0.jar
Error while executing the main() method of class 'net.imagej.Main':
java.lang.IllegalArgumentException: Invalid character at index 12
        at org.scijava.parse.Position.die(Position.java:70)
        at org.scijava.parse.ExpressionParser$ParseOperation.parsePostfix(ExpressionParser.java:210)
        at org.scijava.parse.ExpressionParser.parsePostfix(ExpressionParser.java:113)
        at org.scijava.parse.eval.AbstractEvaluator.evaluate(AbstractEvaluator.java:87)
        at org.scijava.parse.DefaultParseService$ItemsList.parseItems(DefaultParseService.java:104)
        at org.scijava.parse.DefaultParseService$ItemsList.<init>(DefaultParseService.java:72)
        at org.scijava.parse.DefaultParseService.parse(DefaultParseService.java:58)
        at org.scijava.parse.ParseService.parse(ParseService.java:56)
        at org.scijava.run.console.RunArgument.handle(RunArgument.java:83)
        at org.scijava.console.DefaultConsoleService.processArgs(DefaultConsoleService.java:102)
        at net.imagej.legacy.LegacyConsoleService.processArgs(LegacyConsoleService.java:81)
        at org.scijava.AbstractGateway.launch(AbstractGateway.java:95)
        at net.imagej.Main.main(Main.java:55)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at net.imagej.launcher.ClassLauncher.launch(ClassLauncher.java:279)
        at net.imagej.launcher.ClassLauncher.run(ClassLauncher.java:186)
        at net.imagej.launcher.ClassLauncher.main(ClassLauncher.java:77)

PS C:\Users\Public\Documents\Fiji>

#4

Yes, I had similar issues in my quick tests. Try using single quotes (') for the FILENAME parameter as well as replacing backslashes (\) by slashes (/) or escaping them with an additional backslash (\\) and see if that helps.


#5

Hi Jan,

i tried:

PS C:\Users\Public\Documents\Fiji> .\ImageJ-win64.exe --ij2 --headless --console --run c:\Users\Public\Documents\Fiji\scripts\GuidedAcq_ROI.py FILENAME='c:\\Users\\M1SRH\\Documents\\Testdata_Zeiss\\RareEvent_Test_Wizard\
\OverViewScan_Test_raw-Stitching.ome.tiff', BINFACTOR=4, RADIUS=3.0, MINSIZE=10000, MINCIRC=0.01, MAXCIRC=0.99

and got another error:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000022b9985, pid=11320, tid=16936
#
# JRE version: Java(TM) SE Runtime Environment (8.0_66-b18) (build 1.8.0_66-b18)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.66-b18 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# V  [jvm.dll+0x109985]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x0000000002a8b800):  GCTaskThread [stack: 0x0000000012220000,0x0000000012420000] [id=16936]

siginfo: ExceptionCode=0xc0000005, reading address 0x0000000000000018

Registers:
RAX=0x0000000000000002, RBX=0x0000000000000010, RCX=0x0000000000000003, RDX=0x00000004dbf410c0
RSP=0x000000001241fc20, RBP=0x00000007c034c368, RSI=0x00000004dbf410c0, RDI=0x000000002a6d2430
R8 =0x00000004dbf52401, R9 =0x0000000000000000, R10=0x000000000000021d, R11=0x00000004dbf524d0
R12=0x0000000000000001, R13=0x0000000000000000, R14=0x00000007c034c608, R15=0x00000004dbf41098
RIP=0x00000000022b9985, EFLAGS=0x0000000000010202

Top of Stack: (sp=0x000000001241fc20)
0x000000001241fc20:   00000004c890c500 000000002a6d2430
0x000000001241fc30:   0000000000000005 00000004dbf410b8
0x000000001241fc40:   00000004dbf524d3 000000002a6d2430
0x000000001241fc50:   0000000000000000 00000007c034c600
0x000000001241fc60:   00000004dbf410c4 00000000022ba791
0x000000001241fc70:   00000004dbf410c0 00000007c034c368
0x000000001241fc80:   000000002a6d2430 00000000022e2a41
0x000000001241fc90:   00000004dbf1b760 000000000000000c
0x000000001241fca0:   0000000002a8c018 0000000000000000
0x000000001241fcb0:   0000000002a7a6d0 00000339000001d1
0x000000001241fcc0:   000000002a6d2330 0000000002a875d0
0x000000001241fcd0:   000000000000021c 00000000025b3a78
0x000000001241fce0:   00000007c034c368 000000000000021a
0x000000001241fcf0:   0000000002a875d0 00000007c034c608
0x000000001241fd00:   00000338000001d1 00000339000001d1
0x000000001241fd10:   0000000002a87668 0000038000000122 

Instructions: (pc=0x00000000022b9985)
0x00000000022b9965:   e3 48 03 1d 0b be 68 00 48 3b 5f 50 0f 83 ea 00
0x00000000022b9975:   00 00 80 3d f3 68 6f 00 00 48 89 6c 24 58 74 15
0x00000000022b9985:   8b 53 08 8b 0d 02 be 68 00 48 d3 e2 48 03 15 f0
0x00000000022b9995:   bd 68 00 eb 04 48 8b 53 08 48 8b 2b 48 8b cb 40 


Register to memory mapping:

RAX=0x0000000000000002 is an unknown value
RBX=0x0000000000000010 is an unknown value
RCX=0x0000000000000003 is an unknown value
RDX=0x00000004dbf410c0 is pointing into object: 0x00000004dbf41098
javassist.bytecode.stackmap.TypeData$TypeVar 
 - klass: 'javassist/bytecode/stackmap/TypeData$TypeVar'
RSP=0x000000001241fc20 is an unknown value
RBP=0x00000007c034c368 is pointing into metadata
RSI=0x00000004dbf410c0 is pointing into object: 0x00000004dbf41098
javassist.bytecode.stackmap.TypeData$TypeVar 
 - klass: 'javassist/bytecode/stackmap/TypeData$TypeVar'
RDI=0x000000002a6d2430 is an unknown value
R8 =0x00000004dbf52401 is pointing into object: 0x00000004dbf523f8
[Ljava.lang.Object; 
 - klass: 'java/lang/Object'[]
 - length: 2
R9 =0x0000000000000000 is an unknown value
R10=0x000000000000021d is an unknown value
R11=0x00000004dbf524d0 is an oop
java.util.ArrayList 
 - klass: 'java/util/ArrayList'
R12=0x0000000000000001 is an unknown value
R13=0x0000000000000000 is an unknown value
R14=0x00000007c034c608 is pointing into metadata
R15=0x00000004dbf41098 is an oop
javassist.bytecode.stackmap.TypeData$TypeVar 
 - klass: 'javassist/bytecode/stackmap/TypeData$TypeVar'


Stack: [0x0000000012220000,0x0000000012420000],  sp=0x000000001241fc20,  free space=2047k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0x109985]
V  [jvm.dll+0x10a791]
V  [jvm.dll+0x403a78]
V  [jvm.dll+0x403b0b]
V  [jvm.dll+0x401a15]
V  [jvm.dll+0x27cc60]
V  [jvm.dll+0x29a0fa]
C  [MSVCR100.dll+0x21d9f]
C  [MSVCR100.dll+0x21e3b]
C  [kernel32.dll+0x159cd]
C  [ntdll.dll+0x2a561]


---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x000000002493e800 JavaThread "Service Thread" daemon [_thread_blocked, id=17296, stack(0x0000000025f10000,0x0000000026110000)]
  0x0000000024905000 JavaThread "C1 CompilerThread2" daemon [_thread_blocked, id=1168, stack(0x0000000025d10000,0x0000000025f10000)]
  0x00000000248ac000 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=13900, stack(0x0000000025b10000,0x0000000025d10000)]
  0x00000000248a9000 JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=2172, stack(0x0000000025910000,0x0000000025b10000)]
  0x00000000248a7800 JavaThread "Attach Listener" daemon [_thread_blocked, id=16632, stack(0x0000000025710000,0x0000000025910000)]
  0x00000000248a6000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=7296, stack(0x0000000025510000,0x0000000025710000)]
  0x00000000248a2800 JavaThread "Surrogate Locker Thread (Concurrent GC)" daemon [_thread_blocked, id=13416, stack(0x0000000025310000,0x0000000025510000)]
  0x0000000024847000 JavaThread "Finalizer" daemon [_thread_blocked, id=13496, stack(0x0000000025020000,0x0000000025220000)]
  0x0000000024840000 JavaThread "Reference Handler" daemon [_thread_blocked, id=15952, stack(0x0000000024e20000,0x0000000025020000)]
  0x000000000039f000 JavaThread "main" [_thread_blocked, id=6988, stack(0x0000000000030000,0x0000000000230000)]

Other Threads:
  0x0000000024839800 VMThread [stack: 0x0000000024c20000,0x0000000024e20000] [id=3232]
  0x000000002494a000 WatcherThread [stack: 0x0000000026110000,0x0000000026310000] [id=11732]

=>0x0000000002a8b800 (exited) GCTaskThread [stack: 0x0000000012220000,0x0000000012420000] [id=16936]

VM state:at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread:  ([mutex/lock_event])
[0x0000000002a78a00] Threads_lock - owner thread: 0x0000000024839800
[0x0000000002a78f80] Heap_lock - owner thread: 0x000000000039f000

Heap:
 par new generation   total 78656K, used 78656K [0x00000004c5400000, 0x00000004ca950000, 0x00000004da0c0000)
  eden space 69952K, 100% used [0x00000004c5400000, 0x00000004c9850000, 0x00000004c9850000)
  from space 8704K, 100% used [0x00000004ca0d0000, 0x00000004ca950000, 0x00000004ca950000)
  to   space 8704K, 100% used [0x00000004c9850000, 0x00000004ca0d0000, 0x00000004ca0d0000)
 concurrent mark-sweep generation total 174784K, used 31419K [0x00000004da0c0000, 0x00000004e4b70000, 0x00000007c0000000)
 Metaspace       used 18782K, capacity 18974K, committed 19072K, reserved 1064960K
  class space    used 3351K, capacity 3423K, committed 3456K, reserved 1048576K

Card table byte_map: [0x0000000012820000,0x0000000014000000] byte_map_base: 0x00000000101f6000

Marking Bits: (CMSBitMap*) 0x0000000002ad51d8
 Bits: [0x0000000015b70000, 0x00000000214ed000)

Mod Union Table: (CMSBitMap*) 0x0000000002ad5298
 Bits: [0x00000000214f0000, 0x00000000217d5f40)

Polling page: 0x0000000000300000

CodeCache: size=245760Kb used=7710Kb max_used=7723Kb free=238049Kb
 bounds [0x0000000002c60000, 0x00000000033f0000, 0x0000000011c60000]
 total_blobs=2416 nmethods=2087 adapters=241
 compilation: enabled

Compilation events (10 events):
Event: 4.546 Thread 0x00000000248ac000 nmethod 2100 0x00000000033e2310 code [0x00000000033e2a80, 0x00000000033e8810]
Event: 4.546 Thread 0x00000000248ac000 1953       4       javassist.bytecode.ConstPool::readOne (363 bytes)
Event: 4.569 Thread 0x00000000248ac000 nmethod 1953 0x00000000033c7150 code [0x00000000033c7540, 0x00000000033c8bf0]
Event: 4.569 Thread 0x00000000248ac000 2126       4       javassist.bytecode.stackmap.MapMaker::mergeMap (99 bytes)
Event: 4.576 Thread 0x00000000248ac000 nmethod 2126 0x00000000033bead0 code [0x00000000033bec60, 0x00000000033bf1d8]
Event: 4.576 Thread 0x00000000248ac000 2059       4       javassist.bytecode.stackmap.MapMaker::recordTypeData (52 bytes)
Event: 4.579 Thread 0x00000000248ac000 nmethod 2059 0x00000000033ca290 code [0x00000000033ca3e0, 0x00000000033ca678]
Event: 4.579 Thread 0x00000000248ac000 2101       4       javassist.CtClassType::getDeclaredField2 (67 bytes)
Event: 4.589 Thread 0x00000000248ac000 nmethod 2101 0x00000000033c3f90 code [0x00000000033c4120, 0x00000000033c4998]
Event: 4.589 Thread 0x00000000248ac000 2061       4       javassist.bytecode.stackmap.TypeData$TypeVar::fixTypes1 (94 bytes)

GC Heap History (10 events):
Event: 1.693 GC heap after
Heap after GC invocations=1 (full 0):
 par new generation   total 78656K, used 6610K [0x00000004c5400000, 0x00000004ca950000, 0x00000004da0c0000)
  eden space 69952K,   0% used [0x00000004c5400000, 0x00000004c5400000, 0x00000004c9850000)
  from space 8704K,  75% used [0x00000004ca0d0000, 0x00000004ca744b48, 0x00000004ca950000)
  to   space 8704K,   0% used [0x00000004c9850000, 0x00000004c9850000, 0x00000004ca0d0000)
 concurrent mark-sweep generation total 174784K, used 0K [0x00000004da0c0000, 0x00000004e4b70000, 0x00000007c0000000)
 Metaspace       used 5699K, capacity 5796K, committed 5888K, reserved 1056768K
  class space    used 649K, capacity 692K, committed 768K, reserved 1048576K
}
Event: 2.224 GC heap before
{Heap before GC invocations=1 (full 0):
 par new generation   total 78656K, used 76562K [0x00000004c5400000, 0x00000004ca950000, 0x00000004da0c0000)
  eden space 69952K, 100% used [0x00000004c5400000, 0x00000004c9850000, 0x00000004c9850000)
  from space 8704K,  75% used [0x00000004ca0d0000, 0x00000004ca744b48, 0x00000004ca950000)
  to   space 8704K,   0% used [0x00000004c9850000, 0x00000004c9850000, 0x00000004ca0d0000)
 concurrent mark-sweep generation total 174784K, used 0K [0x00000004da0c0000, 0x00000004e4b70000, 0x00000007c0000000)
 Metaspace       used 8512K, capacity 8580K, committed 8832K, reserved 1056768K
  class space    used 1531K, capacity 1556K, committed 1664K, reserved 1048576K
Event: 2.248 GC heap after
Heap after GC invocations=2 (full 0):
 par new generation   total 78656K, used 6445K [0x00000004c5400000, 0x00000004ca950000, 0x00000004da0c0000)
  eden space 69952K,   0% used [0x00000004c5400000, 0x00000004c5400000, 0x00000004c9850000)
  from space 8704K,  74% used [0x00000004c9850000, 0x00000004c9e9b600, 0x00000004ca0d0000)
  to   space 8704K,   0% used [0x00000004ca0d0000, 0x00000004ca0d0000, 0x00000004ca950000)
 concurrent mark-sweep generation total 174784K, used 4530K [0x00000004da0c0000, 0x00000004e4b70000, 0x00000007c0000000)
 Metaspace       used 8512K, capacity 8580K, committed 8832K, reserved 1056768K
  class space    used 1531K, capacity 1556K, committed 1664K, reserved 1048576K
}
Event: 2.856 GC heap before
{Heap before GC invocations=2 (full 1):
 par new generation   total 78656K, used 76397K [0x00000004c5400000, 0x00000004ca950000, 0x00000004da0c0000)
  eden space 69952K, 100% used [0x00000004c5400000, 0x00000004c9850000, 0x00000004c9850000)
  from space 8704K,  74% used [0x00000004c9850000, 0x00000004c9e9b600, 0x00000004ca0d0000)
  to   space 8704K,   0% used [0x00000004ca0d0000, 0x00000004ca0d0000, 0x00000004ca950000)
 concurrent mark-sweep generation total 174784K, used 4530K [0x00000004da0c0000, 0x00000004e4b70000, 0x00000007c0000000)
 Metaspace       used 12552K, capacity 12612K, committed 12672K, reserved 1058816K
  class space    used 2602K, capacity 2644K, committed 2688K, reserved 1048576K
Event: 2.865 GC heap after
Heap after GC invocations=3 (full 1):
 par new generation   total 78656K, used 6773K [0x00000004c5400000, 0x00000004ca950000, 0x00000004da0c0000)
  eden space 69952K,   0% used [0x00000004c5400000, 0x00000004c5400000, 0x00000004c9850000)
  from space 8704K,  77% used [0x00000004ca0d0000, 0x00000004ca76d4f8, 0x00000004ca950000)
  to   space 8704K,   0% used [0x00000004c9850000, 0x00000004c9850000, 0x00000004ca0d0000)
 concurrent mark-sweep generation total 174784K, used 7783K [0x00000004da0c0000, 0x00000004e4b70000, 0x00000007c0000000)
 Metaspace       used 12552K, capacity 12612K, committed 12672K, reserved 1058816K
  class space    used 2602K, capacity 2644K, committed 2688K, reserved 1048576K
}
Event: 3.362 GC heap before
{Heap before GC invocations=3 (full 1):
 par new generation   total 78656K, used 76725K [0x00000004c5400000, 0x00000004ca950000, 0x00000004da0c0000)
  eden space 69952K, 100% used [0x00000004c5400000, 0x00000004c9850000, 0x00000004c9850000)
  from space 8704K,  77% used [0x00000004ca0d0000, 0x00000004ca76d4f8, 0x00000004ca950000)
  to   space 8704K,   0% used [0x00000004c9850000, 0x00000004c9850000, 0x00000004ca0d0000)
 concurrent mark-sweep generation total 174784K, used 7783K [0x00000004da0c0000, 0x00000004e4b70000, 0x00000007c0000000)
 Metaspace       used 17346K, capacity 17598K, committed 17664K, reserved 1062912K
  class space    used 3242K, capacity 3327K, committed 3328K, reserved 1048576K
Event: 3.367 GC heap after
Heap after GC invocations=4 (full 1):
 par new generation   total 78656K, used 4571K [0x00000004c5400000, 0x00000004ca950000, 0x00000004da0c0000)
  eden space 69952K,   0% used [0x00000004c5400000, 0x00000004c5400000, 0x00000004c9850000)
  from space 8704K,  52% used [0x00000004c9850000, 0x00000004c9cc6f30, 0x00000004ca0d0000)
  to   space 8704K,   0% used [0x00000004ca0d0000, 0x00000004ca0d0000, 0x00000004ca950000)
 concurrent mark-sweep generation total 174784K, used 7783K [0x00000004da0c0000, 0x00000004e4b70000, 0x00000007c0000000)
 Metaspace       used 17346K, capacity 17598K, committed 17664K, reserved 1062912K
  class space    used 3242K, capacity 3327K, committed 3328K, reserved 1048576K
}
Event: 4.130 GC heap before
{Heap before GC invocations=4 (full 1):
 par new generation   total 78656K, used 74523K [0x00000004c5400000, 0x00000004ca950000, 0x00000004da0c0000)
  eden space 69952K, 100% used [0x00000004c5400000, 0x00000004c9850000, 0x00000004c9850000)
  from space 8704K,  52% used [0x00000004c9850000, 0x00000004c9cc6f30, 0x00000004ca0d0000)
  to   space 8704K,   0% used [0x00000004ca0d0000, 0x00000004ca0d0000, 0x00000004ca950000)
 concurrent mark-sweep generation total 174784K, used 7782K [0x00000004da0c0000, 0x00000004e4b70000, 0x00000007c0000000)
 Metaspace       used 18752K, capacity 18974K, committed 19072K, reserved 1064960K
  class space    used 3351K, capacity 3423K, committed 3456K, reserved 1048576K
Event: 4.152 GC heap after
Heap after GC invocations=5 (full 1):
 par new generation   total 78656K, used 8704K [0x00000004c5400000, 0x00000004ca950000, 0x00000004da0c0000)
  eden space 69952K,   0% used [0x00000004c5400000, 0x00000004c5400000, 0x00000004c9850000)
  from space 8704K, 100% used [0x00000004ca0d0000, 0x00000004ca950000, 0x00000004ca950000)
  to   space 8704K,   0% used [0x00000004c9850000, 0x00000004c9850000, 0x00000004ca0d0000)
 concurrent mark-sweep generation total 174784K, used 15016K [0x00000004da0c0000, 0x00000004e4b70000, 0x00000007c0000000)
 Metaspace       used 18752K, capacity 18974K, committed 19072K, reserved 1064960K
  class space    used 3351K, capacity 3423K, committed 3456K, reserved 1048576K
}
Event: 4.594 GC heap before
{Heap before GC invocations=5 (full 1):
 par new generation   total 78656K, used 78656K [0x00000004c5400000, 0x00000004ca950000, 0x00000004da0c0000)
  eden space 69952K, 100% used [0x00000004c5400000, 0x00000004c9850000, 0x00000004c9850000)
  from space 8704K, 100% used [0x00000004ca0d0000, 0x00000004ca950000, 0x00000004ca950000)
  to   space 8704K,   0% used [0x00000004c9850000, 0x00000004c9850000, 0x00000004ca0d0000)
 concurrent mark-sweep generation total 174784K, used 15016K [0x00000004da0c0000, 0x00000004e4b70000, 0x00000007c0000000)
 Metaspace       used 18782K, capacity 18974K, committed 19072K, reserved 1064960K
  class space    used 3351K, capacity 3423K, committed 3456K, reserved 1048576K

Deoptimization events (10 events):
Event: 3.535 Thread 0x000000000039f000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00000000031b8874 method=javassist.bytecode.ClassFile.isDuplicated(Ljavassist/bytecode/MethodInfo;Ljava/lang/String;Ljava/lang/String;Ljavassist/bytecode/MethodInfo;Ljava/util/ListIterator;)Z @ 8
Event: 3.594 Thread 0x000000000039f000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00000000031683c0 method=javassist.bytecode.LongVector.addElement(Ljavassist/bytecode/ConstInfo;)V @ 26
Event: 3.612 Thread 0x000000000039f000 Uncommon trap: reason=bimorphic action=maybe_recompile pc=0x00000000031adf78 method=java.util.HashMap.putVal(ILjava/lang/Object;Ljava/lang/Object;ZZ)Ljava/lang/Object; @ 253
Event: 3.612 Thread 0x000000000039f000 Uncommon trap: reason=bimorphic action=maybe_recompile pc=0x00000000031adf78 method=java.util.HashMap.putVal(ILjava/lang/Object;Ljava/lang/Object;ZZ)Ljava/lang/Object; @ 253
Event: 3.621 Thread 0x000000000039f000 Uncommon trap: reason=unloaded action=reinterpret pc=0x0000000003183a50 method=javassist.bytecode.ConstPool.readOne(Ljava/io/DataInputStream;)I @ 124
Event: 3.700 Thread 0x000000000039f000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000003195abc method=java.io.DataInputStream.readUTF(Ljava/io/DataInput;)Ljava/lang/String; @ 112
Event: 3.805 Thread 0x000000000039f000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00000000032ea50c method=javassist.compiler.Lex.readSeparator(I)I @ 233
Event: 3.818 Thread 0x000000000039f000 Uncommon trap: reason=unloaded action=reinterpret pc=0x00000000032fca4c method=javassist.bytecode.ConstPool.readOne(Ljava/io/DataInputStream;)I @ 300
Event: 3.819 Thread 0x000000000039f000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00000000032cabc8 method=javassist.bytecode.AttributeInfo.read(Ljavassist/bytecode/ConstPool;Ljava/io/DataInputStream;)Ljavassist/bytecode/AttributeInfo; @ 58
Event: 4.161 Thread 0x0000000024847000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x000000000314ea38 method=java.lang.ref.Finalizer.remove()V @ 10

Internal exceptions (10 events):
Event: 2.993 Thread 0x000000000039f000 Exception <a 'java/security/PrivilegedActionException'> (0x00000004c685cde8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u66\5298\hotspot\src\share\vm\prims\jvm.cpp, line 1386]
Event: 3.005 Thread 0x000000000039f000 Exception <a 'java/security/PrivilegedActionException'> (0x00000004c6a040d8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u66\5298\hotspot\src\share\vm\prims\jvm.cpp, line 1386]
Event: 3.005 Thread 0x000000000039f000 Exception <a 'java/security/PrivilegedActionException'> (0x00000004c6a044d0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u66\5298\hotspot\src\share\vm\prims\jvm.cpp, line 1386]
Event: 3.018 Thread 0x000000000039f000 Exception <a 'java/io/FileNotFoundException'> (0x00000004c6ba9c58) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u66\5298\hotspot\src\share\vm\prims\jni.cpp, line 709]
Event: 3.068 Thread 0x000000000039f000 Exception <a 'java/security/PrivilegedActionException'> (0x00000004c7506bf0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u66\5298\hotspot\src\share\vm\prims\jvm.cpp, line 1386]
Event: 3.068 Thread 0x000000000039f000 Exception <a 'java/security/PrivilegedActionException'> (0x00000004c75071d0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u66\5298\hotspot\src\share\vm\prims\jvm.cpp, line 1386]
Event: 3.068 Thread 0x000000000039f000 Exception <a 'java/security/PrivilegedActionException'> (0x00000004c75088e8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u66\5298\hotspot\src\share\vm\prims\jvm.cpp, line 1386]
Event: 3.068 Thread 0x000000000039f000 Exception <a 'java/security/PrivilegedActionException'> (0x00000004c7508ec8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u66\5298\hotspot\src\share\vm\prims\jvm.cpp, line 1386]
Event: 3.318 Thread 0x000000000039f000 Exception <a 'java/lang/NoSuchFieldError': method resolution failed> (0x00000004c9443c70) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u66\5298\hotspot\src\share\vm\prims\methodHandles.cpp, line 1146]
Event: 3.319 Thread 0x000000000039f000 Exception <a 'java/lang/NoSuchFieldError': method resolution failed> (0x00000004c9451330) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u66\5298\hotspot\src\share\vm\prims\methodHandles.cpp, line 1146]

Events (10 events):
Event: 4.161 Thread 0x0000000024847000 DEOPT UNPACKING pc=0x0000000002ca582a sp=0x000000002521f3c8 mode 2
Event: 4.204 Thread 0x000000000039f000 DEOPT PACKING pc=0x00000000032fbad1 sp=0x0000000000228f00
Event: 4.204 Thread 0x000000000039f000 DEOPT UNPACKING pc=0x0000000002ca787f sp=0x0000000000228c20 mode 0
Event: 4.212 Thread 0x000000000039f000 DEOPT PACKING pc=0x00000000033781e4 sp=0x0000000000229220
Event: 4.212 Thread 0x000000000039f000 DEOPT UNPACKING pc=0x0000000002ca787f sp=0x0000000000228f10 mode 0
Event: 4.227 Executing VM operation: EnableBiasedLocking
Event: 4.232 Executing VM operation: EnableBiasedLocking done
Event: 4.249 Thread 0x000000000039f000 DEOPT PACKING pc=0x0000000003357046 sp=0x0000000000228fa0
Event: 4.249 Thread 0x000000000039f000 DEOPT UNPACKING pc=0x0000000002ca787f sp=0x0000000000228c98 mode 0
Event: 4.594 Executing VM operation: GenCollectForAllocation


Dynamic libraries:
0x0000000000400000 - 0x000000000042f000 	C:\Users\Public\Documents\Fiji\ImageJ-win64.exe
0x00000000779d0000 - 0x0000000077b7a000 	C:\windows\SYSTEM32\ntdll.dll
0x00000000778b0000 - 0x00000000779cf000 	C:\windows\system32\kernel32.dll
0x000007fefd830000 - 0x000007fefd89a000 	C:\windows\system32\KERNELBASE.dll
0x000007feffb80000 - 0x000007feffc5b000 	C:\windows\system32\ADVAPI32.dll
0x000007fefddd0000 - 0x000007fefde6f000 	C:\windows\system32\msvcrt.dll
0x000007feffa50000 - 0x000007feffa6f000 	C:\windows\SYSTEM32\sechost.dll
0x000007fefeff0000 - 0x000007feff11d000 	C:\windows\system32\RPCRT4.dll
0x00000000777b0000 - 0x00000000778aa000 	C:\windows\system32\USER32.dll
0x000007feff450000 - 0x000007feff4b7000 	C:\windows\system32\GDI32.dll
0x000007feff770000 - 0x000007feff77e000 	C:\windows\system32\LPK.dll
0x000007feff780000 - 0x000007feff84b000 	C:\windows\system32\USP10.dll
0x000007feffcb0000 - 0x000007feffcde000 	C:\windows\system32\IMM32.DLL
0x000007feffa70000 - 0x000007feffb79000 	C:\windows\system32\MSCTF.dll
0x000007fefd600000 - 0x000007fefd630000 	C:\windows\system32\nvinitx.dll
0x000007fefd5f0000 - 0x000007fefd5fc000 	C:\windows\system32\VERSION.dll
0x0000000075420000 - 0x0000000075426000 	C:\Program Files\NVIDIA Corporation\CoProcManager\detoured.dll
0x000007fefabe0000 - 0x000007fefac18000 	C:\Program Files\NVIDIA Corporation\CoProcManager\nvd3d9wrapx.dll
0x000007fefdb00000 - 0x000007fefdcd7000 	C:\windows\system32\SETUPAPI.dll
0x000007fefd8a0000 - 0x000007fefd8d6000 	C:\windows\system32\CFGMGR32.dll
0x000007fefdce0000 - 0x000007fefddba000 	C:\windows\system32\OLEAUT32.dll
0x000007feff850000 - 0x000007feffa4c000 	C:\windows\system32\ole32.dll
0x000007fefd810000 - 0x000007fefd82a000 	C:\windows\system32\DEVOBJ.dll
0x000007fefabb0000 - 0x000007fefabd4000 	C:\Program Files\NVIDIA Corporation\CoProcManager\nvdxgiwrapx.dll
0x00000000021b0000 - 0x0000000002a39000 	C:\Users\Public\DOCUME~1\Fiji\java\win64\jdk1.8.0_66\jre\bin\server\jvm.dll
0x000007fef8340000 - 0x000007fef8349000 	C:\windows\system32\WSOCK32.dll
0x000007feffc60000 - 0x000007feffcad000 	C:\windows\system32\WS2_32.dll
0x000007fefddc0000 - 0x000007fefddc8000 	C:\windows\system32\NSI.dll
0x000007fefacf0000 - 0x000007fefad2b000 	C:\windows\system32\WINMM.dll
0x0000000077ba0000 - 0x0000000077ba7000 	C:\windows\system32\PSAPI.DLL
0x0000000074980000 - 0x0000000074a52000 	C:\windows\system32\MSVCR100.dll
0x000000006cbc0000 - 0x000000006cbcf000 	C:\Users\Public\DOCUME~1\Fiji\java\win64\jdk1.8.0_66\jre\bin\verify.dll
0x000000006ab20000 - 0x000000006ab49000 	C:\Users\Public\DOCUME~1\Fiji\java\win64\jdk1.8.0_66\jre\bin\java.dll
0x000000006c700000 - 0x000000006c716000 	C:\Users\Public\DOCUME~1\Fiji\java\win64\jdk1.8.0_66\jre\bin\zip.dll
0x000007fefe1e0000 - 0x000007fefef6b000 	C:\windows\system32\SHELL32.dll
0x000007fefda80000 - 0x000007fefdaf1000 	C:\windows\system32\SHLWAPI.dll
0x000007fefd6c0000 - 0x000007fefd6cf000 	C:\windows\system32\profapi.dll
0x000007fef8070000 - 0x000007fef8195000 	C:\windows\system32\dbghelp.dll

VM Arguments:
jvm_args: -Dpython.cachedir.skip=true -Dplugins.dir=C:\Users\Public\DOCUME~1\Fiji -Xmx12204m -Djava.awt.headless=true -Dapple.awt.UIElement=true -Xincgc -XX:PermSize=128m 
java_command: <unknown>
java_class_path (initial): C:\Users\Public\DOCUME~1\Fiji/jars/imagej-launcher-4.0.5.jar
Launcher Type: generic

Environment Variables:
JAVA_HOME=C:\Users\Public\DOCUME~1\Fiji/java/win64/jdk1.8.0_66//jre
CLASSPATH=c:\Program Files\Java\jre1.8.0_131\lib;c:\Program Files\Java\jre1.8.0_131\bin
PATH=%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\Anaconda3\Lib\site-packages\numpy\core;C:\ProgramData\Oracle\Java\javapath;C:\Users\M1SRH\Documents\Software\BioFormats_Package\5.1.10\bftools;c:\Program Files\Java\jre1.8.0_131\bin;C:\Program Files\Java\jdk1.8.0_45\bin;C:\MiKTeX 2.9\miktex\bin;C:\windows\system32;C:\windows;C:\windows\system32\wbem;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Anaconda3;C:\Anaconda3\Scripts;C:\Anaconda3\Library\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\MATLAB\R2017a\runtime\win64;C:\Program Files\MATLAB\R2017a\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\M1SRH\AppData\Local\Pandoc\;C:\Program Files\Java\jre1.8.0_131\bin;C:\Users\M1SRH\AppData\Local\atom\bin;C:\Users\Public\DOCUME~1\Fiji/lib/win64;C:\Users\Public\DOCUME~1\Fiji/mm/win64;C:\Users\Public\DOCUME~1\Fiji/lib/fftw;C:\Users\Public\DOCUME~1\Fiji/lib/jcuda-6.5;C:\Users\Public\DOCUME~1\Fiji/java/win64/jdk1.8.0_66//jre/bin
USERNAME=M1SRH
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 61 Stepping 4, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows 7 , 64 bit Build 7601 (6.1.7601.23807)

CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 61 stepping 4, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, rtm, 3dnowpref, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2, adx

Memory: 4k page, physical 16662832k(6270928k free), swap 24951276k(14389352k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (25.66-b18) for windows-amd64 JRE (1.8.0_66-b18), built on Nov  9 2015 10:51:13 by "java_re" with MS VC++ 10.0 (VS2010)

time: Mon Jul 17 18:20:20 2017
elapsed time: 4 seconds (0d 0h 0m 4s)

#6

Now i tried:

PS C:\Users\Public\Documents\Fiji> .\ImageJ-win64.exe --ij2 --headless --console --run c:/Users/Public/Documents/Fiji/scripts/GuidedAcq_ROI.py FILENAME='c:/Users/M1SRH/Documents/Testdata_Zeiss/RareEvent_Test_Wizard/OverV
iewScan_Test_raw-Stitching.ome.tiff', BINFACTOR=4, RADIUS=3.0, MINSIZE=10000, MINCIRC=0.01, MAXCIRC=0.99

but got again:

Error while executing the main() method of class 'net.imagej.Main':
java.lang.IllegalArgumentException: Invalid character at index 12

But why character at index 12? Which one is it?


#7

I tested, and it seems to no longer be an issue, so I removed the warning, and closed the relevant issue.


#8

You need to either: A) Leave off the spaces after your commas; or B) put the entire expression passing the value map in double quotes.


#9

Hi, that helped. Now I use:

PS C:\Users\Public\Documents\Fiji> .\ImageJ-win64.exe --ij2 --headless --console --run c:\\Users\\Public\\Documents\\Fiji\\scripts\\GuidedAcq_ROI_headless.py "FILENAME='c:\\Users\\M1SRH\\Documents\\Testdata_Zeiss\\RareEv
ent_Test_Wizard\\OverViewScan_Test_raw-Stitching.ome.tiff',BINFACTOR=4,RADIUS=3.0,MINSIZE=10000,MINCIRC=0.01,MAXCIRC=0.99,HEADLESS=true"

but I ran into trouble later on in line 195 of my script (might a stupid mistake by myself …)

rm = RoiManager()

SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
C:\Users\Public\DOCUME~1\Fiji\plugins\ilastik_HDF5-0.1.4.jar: java.util.zip.ZipException: error in opening zip file
C:\Users\Public\DOCUME~1\Fiji\plugins\ilastik_HDF5-0.1.4.jar: java.util.zip.ZipException: error in opening zip file
[INFO] Overriding Save Image As Tiff Without Prompt; identifier: script:ZenIntegration/Save_Image_As_Tiff_Without_Prompt.java; jar: file:/C:/Users/Public/DOCUME~1/Fiji/jars/scijava-common-2.64.0.jar
('Filename: ', c:\Users\M1SRH\Documents\Testdata_Zeiss\RareEvent_Test_Wizard\OverViewScan_Test_raw-Stitching.ome.tiff)
('BinFactor: ', 4)
('Filter Radius: ', 3.0)
('Min. Partice Size: ', 10000)
('Min. Circularity: ', 0.009999999776482582)
('Max. Circularity: ', 0.9900000095367432)
('Headless Mode: ', True)
Opening Image : c:\Users\M1SRH\Documents\Testdata_Zeiss\RareEvent_Test_Wizard\OverViewScan_Test_raw-Stitching.ome.tiff
Binning image ...
Applying Filter - Radius: 3.0
Number of slices:  1
Applying Triangle Threshold ...
Number of slices:  1
Threshold:  26  Corrected:  26  Frame:  1
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 ij.plugin.frame.PlugInFrame.<init>(PlugInFrame.java:13)
        at ij.plugin.frame.RoiManager.<init>(RoiManager.java:76)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at java.lang.Class.newInstance(Class.java:442)
        at ij.IJ.runPlugIn(IJ.java:185)
        at ij.Executer.runCommand(Executer.java:137)
        at ij.Executer.run(Executer.java:66)
        at ij.IJ.run(IJ.java:297)
        at ij.IJ.run(IJ.java:272)
        at ij.plugin.filter.ParticleAnalyzer.saveResults(ParticleAnalyzer.java:922)
        at ij.plugin.filter.ParticleAnalyzer.analyzeParticle(ParticleAnalyzer.java:878)
        at ij.plugin.filter.ParticleAnalyzer.analyze(ParticleAnalyzer.java:586)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
        at org.python.core.PyObject.__call__(PyObject.java:496)
        at org.python.core.PyObject.__call__(PyObject.java:500)
        at org.python.core.PyMethod.__call__(PyMethod.java:156)
        at org.python.pycode._pyx0.analyzeParticles$7(c:\Users\Public\Documents\Fiji\scripts\GuidedAcq_ROI_headless.py:181)
        at org.python.pycode._pyx0.call_function(c:\Users\Public\Documents\Fiji\scripts\GuidedAcq_ROI_headless.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:167)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:138)
        at org.python.core.PyFunction.__call__(PyFunction.java:413)
        at org.python.pycode._pyx0.run$10(c:\Users\Public\Documents\Fiji\scripts\GuidedAcq_ROI_headless.py:221)
        at org.python.pycode._pyx0.call_function(c:\Users\Public\Documents\Fiji\scripts\GuidedAcq_ROI_headless.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:167)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:138)
        at org.python.core.PyFunction.__call__(PyFunction.java:413)
        at org.python.pycode._pyx0.f$0(c:\Users\Public\Documents\Fiji\scripts\GuidedAcq_ROI_headless.py:258)
        at org.python.pycode._pyx0.call_function(c:\Users\Public\Documents\Fiji\scripts\GuidedAcq_ROI_headless.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:167)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.Py.runCode(Py.java:1386)
        at org.python.core.__builtin__.eval(__builtin__.java:497)
        at org.python.core.__builtin__.eval(__builtin__.java:501)
        at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259)
        at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:40)
        at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)
        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
        at org.scijava.script.ScriptModule.run(ScriptModule.java:159)
        at org.scijava.module.ModuleRunner.run(ModuleRunner.java:167)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
        at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
        at org.scijava.thread.DefaultThreadService$3.call(DefaultThreadService.java:237)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

2       OverViewScan_Test_raw-Stitching.ome.tiff        6175660.17      12295.89        1683.37 3147.16 2598.24 1
3       OverViewScan_Test_raw-Stitching.ome.tiff        6537575.42      19303.81        1683.37 3183.76 2799.51 1
4       OverViewScan_Test_raw-Stitching.ome.tiff        4637269.27      2689.73 2579.94 2689.73 2250.59 1
5       OverViewScan_Test_raw-Stitching.ome.tiff        6492377.86      19614.87        10118.49    3220.35     2671.43 1
6       OverViewScan_Test_raw-Stitching.ome.tiff        7578458.40      27665.75        10209.98    3476.52     3019.08 1
7       OverViewScan_Test_raw-Stitching.ome.tiff        5568338.93      11179.74        10996.77    2945.89     2488.45 1
8       OverViewScan_Test_raw-Stitching.ome.tiff        4196007.21      3220.35 11051.66        2488.45 2232.29 1
Traceback (most recent call last):
  File "c:\Users\Public\Documents\Fiji\scripts\GuidedAcq_ROI_headless.py", line 256, in <module>
    roisavepath = roiprocess(img, imagefile)
  File "c:\Users\Public\Documents\Fiji\scripts\GuidedAcq_ROI_headless.py", line 195, in roiprocess
    rm = RoiManager()
        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 ij.plugin.frame.PlugInFrame.<init>(PlugInFrame.java:13)
        at ij.plugin.frame.RoiManager.<init>(RoiManager.java:76)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:211)

java.awt.HeadlessException: java.awt.HeadlessException
[INFO] script:c:\Users\Public\Documents\Fiji\scripts\GuidedAcq_ROI_headless.py = [[FILENAME, BINFACTOR, RADIUS, MINSIZE, MINCIRC, MAXCIRC, HEADLESS], [c:\Users\M1SRH\Documents\Testdata_Zeiss\RareEvent_Test_Wizard\OverVie
wScan_Test_raw-Stitching.ome.tiff, 4, 3.0, 10000, 0.01, 0.99, true]]

Complete script:

    # @File(label = "Image File", persit=True) FILENAME
    # @Integer(label = "Binning Factor", value=4, persist=False) BINFACTOR
    # @Float(label = "Filter Radius", value=3.0, persist=False) RADIUS
    # @Integer(label = "PA - Min.Size", value=100000, persist=False) MINSIZE
    # @Float(label = "PA - Min. Circularity", value=0.01,persist=True) MINCIRC
    # @Float(label = "PA - Max. Circularity", value=0.99, persist=True) MAXCIRC
    # @Boolean(label = "Run in headless mode", value=False, persist=True) HEADLESS
    # @OUTPUT String FILENAME
    # @OUTPUT Integer BINFACTOR
    # @OUTPUT float RADIUS
    # @OUTPUT Integer MINSIZE
    # @OUTPUT float MINCIRC
    # @OUTPUT float MAXCIRC
    # @OUTPUT Boolean HEADLESS

    print('Filename: ', FILENAME)
    print('BinFactor: ', BINFACTOR)
    print('Filter Radius: ', RADIUS)
    print('Min. Partice Size: ', MINSIZE)
    print('Min. Circularity: ', MINCIRC)
    print('Max. Circularity: ', MAXCIRC)
    print('Headless Mode: ', HEADLESS)

    """
    File: GuidedAcq_ROI_headless.py
    Author: Sebastian Rhode
    Date: 2017_07_18
    Version: 0.7
    """

    import os
    from java.lang import Double
    from ij import IJ, ImagePlus, ImageStack, Prefs
    from ij.process import ImageProcessor, ImageConverter
    from ij.plugin import Thresholder, Duplicator
    from ij.plugin.filter import GaussianBlur, RankFilters
    from ij.plugin.filter import BackgroundSubtracter, Binary
    from ij.plugin.filter import ParticleAnalyzer as PA
    from ij.plugin.frame import RoiManager
    from ij.plugin.frame import RoiManager
    from ij.gui import Roi
    from ij.measure import ResultsTable;
    from fiji.threshold import Auto_Threshold
    from loci.plugins import BF
    from loci.common import Region
    from loci.plugins.in import ImporterOptions
    from loci.formats import ImageReader
    from loci.formats import MetadataTools
    from ome.units import UNITS


    def openfile(imagefile, series=0, czifile=False):
    	# Opening the image
    	print 'Opening Image :', imagefile

    	if czifile:
    		# parse metadata
    		czireader = ZeissCZIReader()
    		czireader.setFlattenedResolutions(True)
    		#czireader.allowAutostitching()
    		####################################################
    		omeMeta = MetadataTools.createOMEXMLMetadata()
    		czireader.setMetadataStore(omeMeta)
    		czireader.setId(imagefile)
    		rescount = czireader.getResolutionCount()
    		seriesCount = czireader.getSeriesCount()
    		flatres = czireader.hasFlattenedResolutions()
    		czireader.close()

    	# read in and display ImagePlus(es) with arguments
    	options = ImporterOptions()
    	options.setOpenAllSeries(False)
    	options.setShowOMEXML(False)
    	options.setStitchTiles(False)
    	options.setId(imagefile)
    	imps = BF.openImagePlus(options)

    	return imps


    def getImageStack(imp):
    	# get the stacks
    	try:
    		stack = imp.getStack() # get the stack within the ImagePlus
    		nslices = stack.getSize() # get the number of slices
    	except:
    		stack = imp.getProcessor()
    		nslices = 1
    		print 'Execption with stack'

    	print 'Number of slices: ', nslices

    	return stack, nslices


    def apply_rollingball(imp, rolling_ball, createBackground, lightBackground, useParaboloid, doPresmooth, correctCorners):

    	print 'Substracting Background - Radius:', rolling_ball
    	# Create BackgroundSubtracter instance
    	bs = BackgroundSubtracter()
    	# get the stacks
    	stack, nslices = getImageStack(image)

    	for index in range(1, nslices+1):
    		ip = stack.getProcessor(index)
    		# Run public method rollingBallBackground
    		bs.rollingBallBackground(ip, rolling_ball, createBackground, lightBackground, useParaboloid, doPresmooth, correctCorners)

    	return imp


    def apply_filter(imp, radius=5):

    	print 'Applying Filter - Radius:', radius
    	# get the stacks
    	stack, nslices = getImageStack(imp)
    	for index in range(1, nslices+1):
    		ip = stack.getProcessor(index)

    		# Run Median Filter
    		filter = RankFilters()
    		filter.rank(ip, radius, RankFilters.MEDIAN)

    	return imp


    def apply_threshold(imp, background_threshold='black', corrf=1.0):

    	print('Applying Triangle Threshold ...')
    	# Create THresholder instance
    	th = Thresholder()
    	# get the stacks
    	stack, nslices = getImageStack(imp)

    	for index in range(1, nslices+1):
    		ip = stack.getProcessor(index)
    		# get the histogramm
    		hist = ip.getHistogram()
    		lowthresh = Auto_Threshold.Triangle(hist)
    		# apply correction factor
    		lowth_corr = int(round(lowthresh * corrf, 0))
    		print 'Threshold: ', lowthresh, ' Corrected: ', lowth_corr, ' Frame: ', index
    		ip.threshold(lowth_corr)

    	return imp


    def apply_binning(imp, binning=4, method="Sum"):

    	IJ.run(imp, "Bin...", "x=" + str(binning) + " y=" + str(binning) + " bin=" + method)
    	print('Binning image ...')

    	return imp


    def analyzeParticles(imp):

    	options = PA.SHOW_ROI_MASKS \
    			+ PA.SHOW_RESULTS \
    			+ PA.DISPLAY_SUMMARY \
    			+ PA.ADD_TO_MANAGER \

    	measurements = PA.STACK_POSITION \
    				+ PA.LABELS \
    				+ PA.AREA \
    				+ PA.RECT \

    	results = ResultsTable()
    	p = PA(options, measurements, results, MINSIZE, MAXSIZE, MINCIRC, MAXCIRC)
    	p.setHideOutputImage(True)
    	particlestack = ImageStack(imp.getWidth(), imp.getHeight())

    	for i in range(imp.getStackSize()):
    		imp.setSliceWithoutUpdate(i + 1)
    		ip = imp.getProcessor()
    		IJ.run(imp, "Convert to Mask", "")
    		p.analyze(imp, ip)
    		mmap = p.getOutputImage()
    		particlestack.addSlice(mmap.getProcessor())

    	return particlestack


    def getseries(imps, series=0):
    	imp = imps[series]

    	return imp


    def roiprocess(imp, filename):

    	# get the ROI manager instance
    	rm = RoiManager.getInstance();
    	if (rm==None):
    		rm = RoiManager()

    	rm.runCommand(imp, "Select All")
    	#rm.runCommand("Deselect"); # deselect ROIs to save them all
    	rm.runCommand(imp, 'Show All')
    	# define the path to save the rois as azip file
    	roisavelocation = os.path.splitext(filename)[0] + '_RoiSet.zip'
    	print('ROIs saved: ', roisavelocation)
    	rm.runCommand("Save", roisavelocation)

    	return roisavelocation


    def run(imagefile):

    	imps = openfile(imagefile, series=0, czifile=False)
    	imp = getseries(imps, series=0)

    	# do the processing
    	imp_p = apply_binning(imp, binning=BINFACTOR, method="Sum")
    	imp_p = apply_filter(imp_p, radius=RADIUS)
    	# convert to 8-bit for the thresholding
    	IJ.run(imp_p, "8-bit", "")
    	imp_p = apply_threshold(imp_p, background_threshold='black', corrf=1.0)
    	pastack = analyzeParticles(imp_p)

    	return pastack


    ################################################################################

    ###### Define various parameters ######

    # get the FILENAME as string
    imagefile = FILENAME.toString()
    # imagefile = r'c:\Users\M1SRH\Documents\Testdata_Zeiss\RareEvent_Test_Wizard\OverViewScan_Test_raw.ome.tiff'

    # BINFACTOR = 4
    # RADIUS = 5
    # MINSIZE = 1000
    MAXSIZE = Double.POSITIVE_INFINITY
    # MINCIRC = 0.01
    # MAXCIRC = 0.99

    # for rolling ball
    CREATEBACKGROUND = False
    LIGHTBACKGROUND = False
    USEPARABOLOID = False
    DOPRESMOOTH = True
    CORRECTCORNERS = False

    # run image analysis pipeline
    pastack = run(imagefile)
    #IJ.run(pastack, "Enhance Contrast", "saturated=0.35")

    img = ImagePlus('Particles', pastack)
    if HEADLESS==False:
        img.show()
        IJ.run(img, 'glasbey_inverted', '')

    # save ROIs
    roisavepath = roiprocess(img, imagefile)

    print('Done.')

#10

The ROI Manager is not headless compatible, as it is tightly bound to the java AWT framework and is not currently patched by the ij1-patcher.

This issue was discussed at a few other places here on the forum, e.g.:


You can use ij.gui.Overlay instead to work with multiple ROIs in a script.


#11

Hi Jan,

ok, I was not aware of this. But I must admit that I have no clue (yet) on how to create ROIs after measuring the particles with ij.gui.overlay. Any hints where to start?
I my script the ROIs are created by the ParticleAnalyzer. But how do I moce them to an overlay and save them?


#12

Check out the thread that @imagejan linked. In it, @Wayne gives some sample code illustrating how to get started with overlays.

If these snippets do not address your needs, please feel welcome to follow up here with further questions. :smile: