Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROI Manager does not work headless #153

Open
ctrueden opened this issue May 9, 2017 · 3 comments
Open

ROI Manager does not work headless #153

ctrueden opened this issue May 9, 2017 · 3 comments

Comments

@ctrueden
Copy link
Member

ctrueden commented May 9, 2017

The ROI Manager cannot work headless, since it extends PlugInFrame, and unlike GenericDialog, this library does not runtime patch it. We could do so.

For example, any of the following macro calls:

roiManager("reset");
roiManager(("count");
roiManager("select", index);

will throw an exception like:

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:90)
        at ij.macro.Functions.roiManager(Functions.java:2748)
        at ij.macro.Functions.getFunctionValue(Functions.java:230)
        at ij.macro.Interpreter.getFactor(Interpreter.java:1385)
        at ij.macro.Interpreter.getTerm(Interpreter.java:1356)
        at ij.macro.Interpreter.getStringExpression(Interpreter.java:1496)
        at ij.macro.Interpreter.getStringTerm(Interpreter.java:1315)
        at ij.macro.Interpreter.getString(Interpreter.java:1272)
        at ij.macro.Interpreter.doStatement(Interpreter.java:281)
        at ij.macro.Interpreter.doBlock(Interpreter.java:608)
        at ij.macro.Interpreter.doStatement(Interpreter.java:272)
        at ij.macro.Interpreter.doFor(Interpreter.java:530)
        at ij.macro.Interpreter.doStatement(Interpreter.java:254)
        at ij.macro.Interpreter.doBlock(Interpreter.java:608)
        at ij.macro.Interpreter.doStatement(Interpreter.java:272)
        at ij.macro.Interpreter.doFor(Interpreter.java:530)
        at ij.macro.Interpreter.doStatement(Interpreter.java:254)
        at ij.macro.Interpreter.doBlock(Interpreter.java:608)
        at ij.macro.Interpreter.doStatement(Interpreter.java:272)
        at ij.macro.Interpreter.doFor(Interpreter.java:530)
        at ij.macro.Interpreter.doStatement(Interpreter.java:254)
        at ij.macro.Interpreter.doStatements(Interpreter.java:218)
        at ij.macro.Interpreter.run(Interpreter.java:115)
        at ij.macro.Interpreter.run(Interpreter.java:85)
        at ij.macro.Interpreter.run(Interpreter.java:96)
        at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:155)
        at ij.plugin.Macro_Runner.runMacroFile(Macro_Runner.java:139)
        at ij.IJ.runMacroFile(IJ.java:148)
        at net.imagej.legacy.IJ1Helper$4.call(IJ1Helper.java:1056)
        at net.imagej.legacy.IJ1Helper$4.call(IJ1Helper.java:1052)
        at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:986)
        at net.imagej.legacy.IJ1Helper.runMacroFile(IJ1Helper.java:1052)
        at net.imagej.legacy.LegacyCommandline$Macro.handle(LegacyCommandline.java:188)
        at org.scijava.console.DefaultConsoleService.processArgs(DefaultConsoleS ervice.java:93)
        at net.imagej.legacy.LegacyConsoleService.processArgs(LegacyConsoleService.java:81)
        at org.scijava.AbstractGateway.launch(AbstractGateway.java:95)
        at net.imagej.Main.launch(Main.java:62)
        at net.imagej.Main.main(Main.java:68)
        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)
@ctrueden
Copy link
Member Author

ctrueden commented May 9, 2017

One reason we have not implemented this patching yet is because you can use overlays as a workaround. For example, the following code adds ROIs to an overlay, transfers the overlay to another image, and then measures the mean of each ROI in the overlay.

run("Blobs (25K)");
setAutoThreshold("Default");
run("Analyze Particles...", "  show=Overlay");
Overlay.copy
newImage("Untitled", "8-bit ramp", 256, 254, 1);
Overlay.paste
for (i=0; i<Overlay.size; i++) {
  Overlay.activateSelection(i);
  List.setMeasurements;
  mean = List.getValue("Mean");
  print(i+"  "+mean);
}

See this forum thread for details and discussion.

@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/redirect-imagej-fiji-print-macro-to-console/47012/1

@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/headless-roimanager-open-file-path/46561/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants