NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 752 - "Profile Plot Options..." exception via macro/batch mode
"Profile Plot Options..." exception via macro/batch mode
Status: RESOLVED FIXED
Product: Fiji
Classification: Unclassified
Component: ImageJ2
unspecified
PC Mac OS
: P3 major
Assigned To: ImageJ Developers Mailing List
Depends on:
Blocks:
 
Reported: 2014-05-23 00:15 CDT by bryan.callahan
Modified: 2014-06-16 16:47 CDT
4 users (show)

See Also:


Attachments
Macro Log (7.61 KB, text/plain)
2014-05-23 00:15 CDT, bryan.callahan
Data image used. (5.20 KB, image/png)
2014-06-05 09:36 CDT, bryan.callahan

Description bryan.callahan 2014-05-23 00:15:09 CDT
Created attachment 151
Macro Log

When running "Profile Plot Options" via macro...

run("Profile Plot Options...", "width=450 height=200 minimum=0 maximum=0 interpolate");

...the following exception appears consistently across all platforms/builds in headless mode. Any input or help would be /greatly/ appreciated.

java.lang.IllegalArgumentException: Width (-62) and height (-245) must be > 0
	at java.awt.image.SampleModel.<init>(SampleModel.java:108)
	at java.awt.image.ComponentSampleModel.<init>(ComponentSampleModel.java:128)
	at java.awt.image.PixelInterleavedSampleModel.<init>(PixelInterleavedSampleModel.java:69)
	at java.awt.image.Raster.createInterleavedRaster(Raster.java:638)
	at java.awt.image.Raster.createInterleavedRaster(Raster.java:265)
	at java.awt.image.Raster.createInterleavedRaster(Raster.java:194)
	at java.awt.image.ComponentColorModel.createCompatibleWritableRaster(ComponentColorModel.java:2808)
	at java.awt.image.BufferedImage.<init>(BufferedImage.java:409)
	at ij.plugin.JpegWriter.saveAsJpeg(JpegWriter.java:40)
	at ij.plugin.JpegWriter.save(JpegWriter.java:28)
	at ij.io.FileSaver.saveAsJpeg(FileSaver.java:355)
	at ij.io.FileSaver.saveAsJpeg(FileSaver.java:347)
	at ij.plugin.filter.Writer.run(Writer.java:24)
	at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:262)
	at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:111)
	at ij.IJ.runPlugIn(IJ.java:171)
	at ij.Executer.runCommand(Executer.java:131)
	at ij.Executer.run(Executer.java:64)
	at ij.IJ.run(IJ.java:269)
	at ij.IJ.run(IJ.java:323)
	at ij.IJ.saveAs(IJ.java:1722)
	at ij.IJ.saveAs(IJ.java:1654)
	at ij.macro.Functions.saveAs(Functions.java:2846)
	at ij.macro.Functions.doFunction(Functions.java:155)
	at ij.macro.Interpreter.doStatement(Interpreter.java:226)
	at ij.macro.Interpreter.doStatements(Interpreter.java:214)
	at ij.macro.Interpreter.run(Interpreter.java:111)
	at ij.macro.Interpreter.run(Interpreter.java:81)
	at ij.macro.Interpreter.run(Interpreter.java:92)
	at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:153)
	at ij.plugin.Macro_Runner.runMacroFile(Macro_Runner.java:137)
	at ij.IJ.runMacroFile(IJ.java:130)
	at ij.ImageJ.main(ImageJ.java:678)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at imagej.patcher.LegacyEnvironment.main(LegacyEnvironment.java:374)
	at fiji.Main.main(Main.java:155)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at imagej.ClassLauncher.launch(ClassLauncher.java:222)
	at imagej.ClassLauncher.run(ClassLauncher.java:159)
	at imagej.ClassLauncher.main(ClassLauncher.java:72)
Comment 1 bryan.callahan 2014-05-23 00:18:33 CDT
Just to clarify, the full macro I'm running is:

run("Profile Plot Options...", "width=450 height=200 minimum=0 maximum=0 interpolate");
open("data.jpg");
run("Plot Profile");
saveAs("Jpeg", "profile.jpg");

...and it works fine on Fiji and ImageJ2 (as a macro) when not in headless mode. My only goal is to disable the grey grid generated in the line profile but ran into this snag. Thanks again! Please let me know how I can help! :)
Comment 2 bryan.callahan 2014-06-04 15:45:27 CDT
Is there anything I can help with? I'm still having this issue and trying to get it to test by the end of the week.

Thanks so much,

Bryan
Comment 3 Johannes Schindelin 2014-06-04 16:10:56 CDT
Could you provide the 'data.jpg' file so we can try to reproduce the issue here?
Comment 4 bryan.callahan 2014-06-04 16:12:48 CDT
Sure thing. I'll try to get that attached tonight. I don't think it even gets to that point, however, since it fails on this line...

run("Profile Plot Options...", "width=450 height=200 minimum=0 maximum=0 interpolate");

Thanks
Comment 5 bryan.callahan 2014-06-05 09:36:00 CDT
Created attachment 155
Data image used.
Comment 6 bryan.callahan 2014-06-14 12:21:48 CDT
Anything I can help on? Are you able to reproduce this issue? If not, I can see if I can get additional bounds on the error case.

Thanks,

Bryan
Comment 7 Curtis Rueden 2014-06-14 21:09:40 CDT
Apologies for letting this sit for so long. We have been swamped fixing ImageJ2-related issues.

I tried your macro with your data, using the command:

 $FIJI_DIR/Contents/MacOS/ImageJ-macosx --headless -macro bryan.ijm

Where "bryan.ijm" is your macro:
 
 run("Profile Plot Options...", "width=450 height=200 minimum=0 maximum=0 interpolate");
 open("data.jpg");
 run("Plot Profile");
 saveAs("Jpeg", "profile.jpg");

On my system, this gives the error:

 Unsupported format or not found
 File is not in a supported format, a reader
 plugin is not available, or it was not found.

So I changed "data.jpg" to "data.png" and then received:

 Line or rectangular selection required

So I added a makeLine call:

 run("Profile Plot Options...", "width=450 height=200 minimum=0 maximum=0 interpolate");
 open("data.png");
 makeLine(18, 36, 252, 15);
 run("Plot Profile");
 saveAs("Jpeg", "profile.jpg");

And _then_ I finally see the exception you reported.

Investigating now...
Comment 8 Curtis Rueden 2014-06-14 21:28:23 CDT
This bug is caused by the Profiler plugin attempting to crop the maximum Profile Plot size to stay within the bounds of the screen; see:

https://github.com/imagej/ImageJA/blob/master/src/main/java/ij/plugin/Profiler.java#L66-L72

The problem is that in headless mode, IJ.getScreenSize() returns (0, 0).

Personally, I think limiting the Profile Plot size in this way is a bug, since there are legitimate reasons to plot extremely large graphs larger than the bounds of the screen, regardless of being in headless mode.

In any case, this is a bug that would need to be fixed in the ImageJ1 source by Wayne Rasband.

In the meantime, if you leave off the "Profile Plot Options" call at the beginning, the macro works. So, I was thinking that you could work around this bug by first setting the desired Profile Plot Options in the UI, then quitting ImageJ and invoking your headless macro(s) to generate and save plot profiles. Unfortunately, it seems that the previous Profile Plot settings are not used for some reason when the macro executes in this manner.
Comment 9 Curtis Rueden 2014-06-14 21:30:13 CDT
Actually, I take back that last part: the Plot Profile size _is_ respected -- it's just padded by the axes etc., so the JPEG is slightly larger than the values given in the configuration dialog. But it _does_ seem to work to set them in the UI, quit, and then run the macro headless without the Plot Profile Options configuration.
Comment 10 Wayne Rasband 2014-06-15 01:05:38 CDT
This bug is fixed in the ImageJ 1.49c13 daily build. The Profiler plugin no longer attempts to crop the maximum profile plot size to stay within the screen bounds. Unfortunately, the source code changes are not shown at

   https://github.com/imagej/imagej1/commits/

because I always get this error

   ssh: connect to host github.com port 22: Operation timed out
   fatal: The remote end hung up unexpectedly

when I attempt to do a "git push".
Comment 11 Johannes Schindelin 2014-06-15 09:12:54 CDT
> ssh: connect to host github.com port 22: Operation timed out

You can also push via https...
Comment 12 Wayne Rasband 2014-06-15 12:53:07 CDT
How do I get 'get push' to use https?
Comment 13 Johannes Schindelin 2014-06-15 14:05:28 CDT
> How do I get 'get push' to use https?

Maybe this is the wrong ticket to discuss Git issues, but in general, you call "git push" this way:

    git push <URL> <branch>...

For convenience, you can specify <nickname> instead of <URL> if <nickname> is listed in the output of "git remote -v".

For further convenience, you can also skip <branch>... (in which case Git < 2.0.0 will push *all* branches which are present locally and remotely, Git >= 2.0.0 will only push the current branch) and even <nickname>, in which case Git falls back to using "origin", i.e. the special nickname for the remote from which the current repository was cloned.

Not specifying these parameters is sloppy.

In your case, you should be able to call "git push https://github.com/imagej/imagej1 master" and it should ask you for your GitHub credentials.

This is only one of many "tricks" that are described in http://www.git-scm.com/book. I strongly encourage reading that book, in particular how to use Git effectively, including fine-grained, well documented commits. I would also suggest another resource to help with mastering the art of making excellent commits: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
Comment 14 Curtis Rueden 2014-06-16 16:47:36 CDT
I am guessing the "git push" failure was a temporary GitHub outage. In the future, it is probably sufficient to just try "git push" again after an hour or two.

I see that Wayne did manage to successfully push the fix:
https://github.com/imagej/imagej1/commit/c03d956e0d661d2793f59b77515faa0c71005fd7

So the bug is closed. Thanks!