You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The scripting service handles only a very limited set of parameter options. For example, this Beanshell parameter that cropped up in a coding session with @schmiedc fails:
The error javax.script.ScriptException: Invalid attribute: 'Door B' is hidden in the standard error stream.
The reason is that parameters that are even mildly complex are not handled correctly can be found here: It is assumed that the attributes (i.e. the "label = 'Monty Hall', choices = { 'Door A', 'Door B', 'Door C' }" of the example above) can be parsed simply by cutting it apart at every comma.
Please note that this parser would already fail to handle something as simple as @String(label = "Hello, world!") label.
Alas, there is already a full-fledged JSON parser in scijava-common, as part of the IndexReader we use to read the indexed annotations.
It would most likely require only a gentle amount of refactoring to turn this into a JSONReader that could be put into org.scijava.util. A cursory look makes this person believe that the only thing that would need to be factored out is the getLegacyReader() method.
To support the script parameters use case, the JSONReader would probably need to sprout a public char peek() method that would skip white space, continue parsing upon encountering a comma, finalize the parameters upon seeing a closing parenthesis, and erroring out otherwise.
In the meantime, we will have to resort to using code like the following:
[EDIT: Since Firefox started to crash frequently here when editing GitHub issues on MacOSX here, I had to paste the diff within a time window of 3 seconds, and edit the comment on another machine on which I did not have that diff. Sorry.]
I tried (and need) to get a drop down list. Saw Curtis Rueden's tutorial from the Image J conference (very nice), then this issue #156. My parameter specification (from Jython code):
# @File(label = "Path", description = "Choose the path to the /Images/ directory e.g. ./EXPT_004/SEAN_384_10x_EPI_470_60ms_19.02.2016_144300/Images/", style = "directory") images_dir
# @Integer(label = "Limit", description = "Limit the number of directories to process", value="2") dir_lim_in
# @String(label = "Monty Hall", choices = { "Door A", "Door B", "Door C" } montyHall
It gives... :(
[ERROR] Invalid parameter syntax for script: /Users/seanwalsh/DOCS/IMAGEJ/siam_z_stitch_and_merge.py
javax.script.ScriptException: Invalid parameter: String(label = "Monty Hall", choices = { "Door A", "Door B", "Door C" } montyHall
at org.scijava.script.ScriptInfo.parseParam(ScriptInfo.java:338)
at org.scijava.script.ScriptInfo.parseParameters(ScriptInfo.java:245)
at org.scijava.module.AbstractModuleInfo.initParameters(AbstractModuleInfo.java:295)
at org.scijava.module.AbstractModuleInfo.inputList(AbstractModuleInfo.java:257)
at org.scijava.module.AbstractModuleInfo.inputs(AbstractModuleInfo.java:103)
at org.scijava.module.DefaultModuleService.getSingleInput(DefaultModuleService.java:255)
at net.imagej.display.process.SingleInputPreprocessor.getSingleInput(SingleInputPreprocessor.java:82)
at net.imagej.display.process.SingleInputPreprocessor.process(SingleInputPreprocessor.java:68)
at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:104)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:156)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:191)
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)
I updated to v1.5.0i and then to the daily build...still no joy
javax.script.ScriptException: Invalid attribute: "Door B"
at org.scijava.script.ScriptInfo.parseAttrs(ScriptInfo.java:382)
at org.scijava.script.ScriptInfo.parseParam(ScriptInfo.java:345)
at org.scijava.script.ScriptInfo.parseParameters(ScriptInfo.java:245)
at org.scijava.module.AbstractModuleInfo.initParameters(AbstractModuleInfo.java:295)
at org.scijava.module.AbstractModuleInfo.inputList(AbstractModuleInfo.java:257)
at org.scijava.module.AbstractModuleInfo.inputs(AbstractModuleInfo.java:103)
at org.scijava.module.DefaultModuleService.getSingleInput(DefaultModuleService.java:255)
at net.imagej.display.process.SingleInputPreprocessor.getSingleInput(SingleInputPreprocessor.java:82)
at net.imagej.display.process.SingleInputPreprocessor.process(SingleInputPreprocessor.java:68)
at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:104)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:156)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:191)
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)
@seanvw Are you using Java-8, with the Java-8 update site enabled? At the moment, we are in the middle of a transition from Java 6 to Java 8, and only the Java-8 update site is receiving updated versions of components. So this bug-fix was only uploaded to the Java-8 version of ImageJ2.
The easiest way to get the Java-8 version of ImageJ2 is to simply download Fiji from http://fiji.sc/#download
Alternately, you can:
rename the java folder from your Fiji.app folder to java6
make sure you have Java 8 installed
launch Fiji again and make sure the status bar indicates "Java 1.8.0"
run Help ▶ Update..., click "Manage update sites" and turn on the Java-8 site
Activity
dscho commentedon Mar 30, 2015
This would be an appropriate diff to start from, in this humble person's opinion:
[EDIT: Since Firefox started to crash frequently here when editing GitHub issues on MacOSX here, I had to paste the diff within a time window of 3 seconds, and edit the comment on another machine on which I did not have that diff. Sorry.]
ExpressionParserTest: test SJC parameter syntax
ScriptInfo: use SJEP for more robust attr parsing
seanvw commentedon Apr 20, 2016
hi @hinerm et al
I tried (and need) to get a drop down list. Saw Curtis Rueden's tutorial from the Image J conference (very nice), then this issue #156. My parameter specification (from Jython code):
It gives... :(
I updated to v1.5.0i and then to the daily build...still no joy
What am i doing wrong please?
hinerm commentedon Apr 20, 2016
Hi @seanvw!
It looks like your parameter is missing a closing parenthesis. I just tried using:
instead and it worked for me.
Thanks for testing this feature out. Let us know if you run into any more problems.
seanvw commentedon Apr 20, 2016
Thanks for that tip :)
Yeah, sorry, bit of a typo in trying all combinations of braces and quotes. Now back to this error :(
# @String(label = "Monty Hall", choices = { "Door A", "Door B", "Door C" }) montyHalljavax.script.ScriptException: Invalid attribute: "Door B"
at org.scijava.script.ScriptInfo.parseAttrs(ScriptInfo.java:382)
at org.scijava.script.ScriptInfo.parseParam(ScriptInfo.java:345)
at org.scijava.script.ScriptInfo.parseParameters(ScriptInfo.java:245)
at org.scijava.module.AbstractModuleInfo.initParameters(AbstractModuleInfo.java:295)
at org.scijava.module.AbstractModuleInfo.inputList(AbstractModuleInfo.java:257)
at org.scijava.module.AbstractModuleInfo.inputs(AbstractModuleInfo.java:103)
at org.scijava.module.DefaultModuleService.getSingleInput(DefaultModuleService.java:255)
at net.imagej.display.process.SingleInputPreprocessor.getSingleInput(SingleInputPreprocessor.java:82)
at net.imagej.display.process.SingleInputPreprocessor.process(SingleInputPreprocessor.java:68)
at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:104)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:156)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:191)
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)
ctrueden commentedon Apr 20, 2016
@seanvw Are you using Java-8, with the Java-8 update site enabled? At the moment, we are in the middle of a transition from Java 6 to Java 8, and only the Java-8 update site is receiving updated versions of components. So this bug-fix was only uploaded to the Java-8 version of ImageJ2.
The easiest way to get the Java-8 version of ImageJ2 is to simply download Fiji from http://fiji.sc/#download
Alternately, you can:
javafolder from yourFiji.appfolder tojava6seanvw commentedon Apr 20, 2016
@hinerm, @ctrueden
Turning on the Java-8 site as you suggested fixed the issue for me. Thanks so much for the super rapid help.
Now then, do i win a car or the goat? :)
ctrueden commentedon Apr 20, 2016
Programming is like pinball. The reward for doing it well is the opportunity to do it again. 👍