Track an Exception in imageJ-macro

Hey,

I have written a macro and get an java.lang.ArrayIndexOutOfBoundsException every 20-30 images. Sometimes there are additional information in the exception window (e.g. Exception followed by a random number) , sometimes just this one line.

Can I somehow track down which lines the exception causes? I could not find anything regarding this; sorry if my search was not thorough enough.

What is the general reason that I do not get this exception in every picture but rather just after 20-30 images (completely random).

Thanks a lot!

P.S.: I’m happy to share the macro but since its 500 lines I won’t post it just now ^^

The exception should tell you exactly where the error occurred, and what it was. If you paste the exception here, someone might be able to help you further.

To get the most efficient help, you should try to reduce the macro to a minimal, reproducible example that others can use to reproduce the issue. Otherwise, it’s really just guessing…

2 Likes

Hey imagejan,

I ran another 20 images and this is all I get:

"
(Fiji Is Just) ImageJ 2.0.0-rc-65/1.51u; Java 1.8.0_66 [64-bit]; Windows 8.1 6.3; 126MB of 6076MB (2%)

java.lang.ArrayIndexOutOfBoundsException

"
I will try to reproduce the long, annotated version if I can.

Thank you

Dear all,

the full exception(s) read as follows:

(Fiji Is Just) ImageJ 2.0.0-rc-54/1.51g; Java 1.8.0_66 [32-bit]; Windows 7 6.1; 69MB of 2600MB (2%)
 
java.lang.ArrayIndexOutOfBoundsException: 184626
	at ij.process.ByteProcessor.reset(ByteProcessor.java:214)
	at ij.plugin.filter.LutApplier.apply(LutApplier.java:98)
	at ij.plugin.filter.LutApplier.run(LutApplier.java:24)
	at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:265)
	at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:114)
	at ij.IJ.runPlugIn(IJ.java:189)
	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.macro.Functions.doRun(Functions.java:603)
	at ij.macro.Functions.doFunction(Functions.java:96)
	at ij.macro.Interpreter.doStatement(Interpreter.java:230)
	at ij.macro.Interpreter.doBlock(Interpreter.java:608)
	at ij.macro.Interpreter.doStatement(Interpreter.java:272)
	at ij.macro.Interpreter.doIf(Interpreter.java:966)
	at ij.macro.Interpreter.doStatement(Interpreter.java:248)
	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.runMacro(Interpreter.java:143)
	at ij.macro.MacroRunner.run(MacroRunner.java:152)
	at java.lang.Thread.run(Thread.java:745)

second exception:
,
(Fiji Is Just) ImageJ 2.0.0-rc-54/1.51g; Java 1.8.0_66 [32-bit]; Windows 7 6.1; 123MB of 2600MB (4%)
 
java.lang.IllegalArgumentException: Mask size (753x545) != ROI size (1376x1032)
	at ij.process.ByteProcessor.reset(ByteProcessor.java:208)
	at ij.plugin.filter.LutApplier.apply(LutApplier.java:98)
	at ij.plugin.filter.LutApplier.run(LutApplier.java:24)
	at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:265)
	at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:114)
	at ij.IJ.runPlugIn(IJ.java:189)
	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.macro.Functions.doRun(Functions.java:603)
	at ij.macro.Functions.doFunction(Functions.java:96)
	at ij.macro.Interpreter.doStatement(Interpreter.java:230)
	at ij.macro.Interpreter.doBlock(Interpreter.java:608)
	at ij.macro.Interpreter.doStatement(Interpreter.java:272)
	at ij.macro.Interpreter.doIf(Interpreter.java:966)
	at ij.macro.Interpreter.doStatement(Interpreter.java:248)
	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.runMacro(Interpreter.java:143)
	at ij.macro.MacroRunner.run(MacroRunner.java:152)
	at java.lang.Thread.run(Thread.java:745)

Thank you all for your help

Here is another one, this time from the console itself; not from the “Exception”-Window.

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 10722
	at ij.process.ShortProcessor.getHistogram2(ShortProcessor.java:998)
	at ij.process.ShortStatistics.<init>(ShortStatistics.java:34)
	at ij.process.ImageStatistics.getStatistics(ImageStatistics.java:78)
	at ij.ImagePlus.getStatistics(ImagePlus.java:891)
	at ij.ImagePlus.getStatistics(ImagePlus.java:863)
	at ij.ImagePlus.getStatistics(ImagePlus.java:843)
	at ij.plugin.frame.ContrastAdjuster.plotHistogram(ContrastAdjuster.java:610)
	at ij.plugin.frame.ContrastAdjuster.setupNewImage(ContrastAdjuster.java:396)
	at ij.plugin.frame.ContrastAdjuster.setup(ContrastAdjuster.java:317)
	at ij.plugin.frame.ContrastAdjuster.setup(ContrastAdjuster.java:275)
	at ij.plugin.frame.ContrastAdjuster.windowActivated(ContrastAdjuster.java:1149)
	at java.awt.Window.processWindowEvent(Window.java:2070)
	at java.awt.Window.processEvent(Window.java:2017)
	at java.awt.Component.dispatchEventImpl(Component.java:4891)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Window.dispatchEventImpl(Window.java:2750)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:995)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:488)
	at java.awt.Component.dispatchEventImpl(Component.java:4762)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Window.dispatchEventImpl(Window.java:2750)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.SentEvent.dispatch(SentEvent.java:70)
	at java.awt.DefaultKeyboardFocusManager$DefaultKeyboardFocusManagerSentEvent.dispatch(DefaultKeyboardFocusManager.java:217)
	at java.awt.DefaultKeyboardFocusManager.sendMessage(DefaultKeyboardFocusManager.java:244)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:366)
	at java.awt.Component.dispatchEventImpl(Component.java:4762)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Window.dispatchEventImpl(Window.java:2750)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.SequencedEvent.dispatch(SequencedEvent.java:128)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Requested array size exceeds VM limit
	at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:75)
	at java.awt.image.Raster.createPackedRaster(Raster.java:467)
	at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032)
	at sun.awt.Win32GraphicsConfig.createAcceleratedImage(Win32GraphicsConfig.java:258)
	at sun.awt.windows.WComponentPeer.createImage(WComponentPeer.java:760)
	at java.awt.Component.createImage(Component.java:3582)
	at ij.gui.ImageCanvas.paintDoubleBuffered(ImageCanvas.java:504)
	at ij.gui.ImageCanvas.paint(ImageCanvas.java:212)
	at ij.gui.ImageCanvas.update(ImageCanvas.java:201)
	at sun.awt.RepaintArea.updateComponent(RepaintArea.java:255)
	at sun.awt.RepaintArea.paint(RepaintArea.java:232)
	at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:358)
	at java.awt.Component.dispatchEventImpl(Component.java:4967)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 36070
	at ij.process.ShortProcessor.getHistogram2(ShortProcessor.java:998)
	at ij.process.ShortStatistics.<init>(ShortStatistics.java:34)
	at ij.process.ImageStatistics.getStatistics(ImageStatistics.java:78)
	at ij.ImagePlus.getStatistics(ImagePlus.java:891)
	at ij.ImagePlus.getStatistics(ImagePlus.java:863)
	at ij.ImagePlus.getStatistics(ImagePlus.java:843)
	at ij.plugin.frame.ContrastAdjuster.plotHistogram(ContrastAdjuster.java:610)
	at ij.plugin.frame.ContrastAdjuster.setupNewImage(ContrastAdjuster.java:396)
	at ij.plugin.frame.ContrastAdjuster.setup(ContrastAdjuster.java:317)
	at ij.plugin.frame.ContrastAdjuster.setup(ContrastAdjuster.java:275)
	at ij.plugin.frame.ContrastAdjuster.windowActivated(ContrastAdjuster.java:1149)
	at java.awt.Window.processWindowEvent(Window.java:2070)
	at java.awt.Window.processEvent(Window.java:2017)
	at java.awt.Component.dispatchEventImpl(Component.java:4891)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Window.dispatchEventImpl(Window.java:2750)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:995)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:488)
	at java.awt.Component.dispatchEventImpl(Component.java:4762)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Window.dispatchEventImpl(Window.java:2750)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.SentEvent.dispatch(SentEvent.java:70)
	at java.awt.DefaultKeyboardFocusManager$DefaultKeyboardFocusManagerSentEvent.dispatch(DefaultKeyboardFocusManager.java:217)
	at java.awt.DefaultKeyboardFocusManager.sendMessage(DefaultKeyboardFocusManager.java:244)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:366)
	at java.awt.Component.dispatchEventImpl(Component.java:4762)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Window.dispatchEventImpl(Window.java:2750)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.SequencedEvent.dispatch(SequencedEvent.java:128)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 4660
	at ij.process.ShortProcessor.getHistogram2(ShortProcessor.java:998)
	at ij.process.ShortStatistics.<init>(ShortStatistics.java:34)
	at ij.process.ImageStatistics.getStatistics(ImageStatistics.java:78)
	at ij.ImagePlus.getStatistics(ImagePlus.java:891)
	at ij.ImagePlus.getStatistics(ImagePlus.java:863)
	at ij.ImagePlus.getStatistics(ImagePlus.java:843)
	at ij.plugin.frame.ContrastAdjuster.plotHistogram(ContrastAdjuster.java:610)
	at ij.plugin.frame.ContrastAdjuster.setupNewImage(ContrastAdjuster.java:396)
	at ij.plugin.frame.ContrastAdjuster.setup(ContrastAdjuster.java:317)
	at ij.plugin.frame.ContrastAdjuster.setup(ContrastAdjuster.java:275)
	at ij.plugin.frame.ContrastAdjuster.windowActivated(ContrastAdjuster.java:1149)
	at java.awt.Window.processWindowEvent(Window.java:2070)
	at java.awt.Window.processEvent(Window.java:2017)
	at java.awt.Component.dispatchEventImpl(Component.java:4891)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Window.dispatchEventImpl(Window.java:2750)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:995)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:488)
	at java.awt.Component.dispatchEventImpl(Component.java:4762)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Window.dispatchEventImpl(Window.java:2750)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.SentEvent.dispatch(SentEvent.java:70)
	at java.awt.DefaultKeyboardFocusManager$DefaultKeyboardFocusManagerSentEvent.dispatch(DefaultKeyboardFocusManager.java:217)
	at java.awt.DefaultKeyboardFocusManager.sendMessage(DefaultKeyboardFocusManager.java:244)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:366)
	at java.awt.Component.dispatchEventImpl(Component.java:4762)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Window.dispatchEventImpl(Window.java:2750)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.SequencedEvent.dispatch(SequencedEvent.java:128)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

corresponding exception window:

(Fiji Is Just) ImageJ 2.0.0-rc-54/1.51g; Java 1.8.0_66 [32-bit]; Windows 7 6.1; 109MB of 2600MB (4%)
 
java.lang.ArrayIndexOutOfBoundsException: 86350
	at ij.process.ByteProcessor.reset(ByteProcessor.java:214)
	at ij.plugin.filter.LutApplier.apply(LutApplier.java:98)
	at ij.plugin.filter.LutApplier.run(LutApplier.java:24)
	at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:265)
	at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:114)
	at ij.IJ.runPlugIn(IJ.java:189)
	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.macro.Functions.doRun(Functions.java:603)
	at ij.macro.Functions.doFunction(Functions.java:96)
	at ij.macro.Interpreter.doStatement(Interpreter.java:230)
	at ij.macro.Interpreter.doBlock(Interpreter.java:608)
	at ij.macro.Interpreter.doStatement(Interpreter.java:272)
	at ij.macro.Interpreter.doIf(Interpreter.java:966)
	at ij.macro.Interpreter.doStatement(Interpreter.java:248)
	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.runMacro(Interpreter.java:143)
	at ij.macro.MacroRunner.run(MacroRunner.java:152)
	at java.lang.Thread.run(Thread.java:745)

These errors occur in 32 bit and 64 bit imageJ versions on two different computers.

1 Like

Hey,

took me quite a while, but I think I solved it.

There was no apparent coding-error.
I set the macro (>500 lines) inside of the BatchMode and this solved the problem.

I think my computer was a little bit too slow ^^

:slight_smile:

1 Like

@spamhunter
I get this error: java.lang.arrayindexoutofboundsexception 0 imagej macro with no other explanation. do you have any suggestion? what do you mean by BatchMode?
Thanks a lot in advance

BatchMode is used in the macro language to hide the images while processing.

https://imagej.nih.gov/ij/developer/macro/functions.html#S

setBatchMode(true) starts the batchmode and setBatchMode(false) ends it. If you want to display images during the procedure, for example because you want to manually draw a ROI, you can display the image with setBatchMode(“show”) and hide it again after the drawing with setBatchMode(“hide”).

Purpose is that imageJ takes time and computing power to display the images which can make the macro slower. In my example, I suspected that “for” loops that included image processing steps would go out of bounds because the imageJ GUI was too slow to keep up with the image computation and therefore caused errors. However, to this day I do not completely understand the error message nor am I sure that this is a correct assumption.

Do you mind sharing the macro code to reproduce the error? Is the error message only sometimes or consistently?

1 Like

@spamhunter It happens sometimes I believe. It is a very long code and hard to cut it.

Hey,

one way would be to upload the macro via a secondary website.

Anyway, did you try to run the macro in batchmode? Just add “setBatchMode(true)” as a first line and “setBatchMode(false)” as the last line. That did the trick for me (also a very long macro with error messages sometimes).

Just one more question: Is the error on specific images or completely random? If the error pops up everytime for a specific image, there might be a coding error.

You also might want to consider scripting languages as discussed here, especially if you want to code more long macros like you have:

It would help if we could see the complete contents of the “Exception” window, which shows the ImageJ version, method names and line numbers. Here is an example created using

debug("throw");

ImageJ 1.52p39; Java 1.8.0_172 [64-bit]; Mac OS X 10.12.6; 28MB of 10000MB (<1%)
 
java.lang.IllegalArgumentException
	at ij.macro.Functions.debug(Functions.java:5609)
	at ij.macro.Functions.getStringFunction(Functions.java:279)
	at ij.macro.Interpreter.getStringTerm(Interpreter.java:1407)
	at ij.macro.Interpreter.getString(Interpreter.java:1385)
	at ij.macro.Interpreter.doStatement(Interpreter.java:329)
	at ij.macro.Interpreter.doStatements(Interpreter.java:261)
	at ij.macro.Interpreter.run(Interpreter.java:157)
	at ij.macro.Interpreter.run(Interpreter.java:91)
	at ij.macro.MacroRunner.run(MacroRunner.java:139)
	at java.lang.Thread.run(Thread.java:748)