imagej / imagej/imagej-common

DefaultDatasetView out of bounds error

Open
#113 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12
Forks
15
PR merge metrics
No merged PRs in 30d

Description

When rebuilding an `ImageDisplay`, the `DefaultDatasetView` method `getCurrentLUT` causes an array index out of bounds error if the channel axis is dimension 0 or 1. Lines 554-557 in DefaultDatasetView.java:
```
private ColorTable getCurrentLUT(final int cPos) {
final Position pos = getPlanePosition();
if (channelDimIndex >= 0) {
pos.setPosition(cPos, channelDimIndex - 2);
}
```

The code here assumes that channelDimIndex will be at least value 2, though doesn't check for that, or have any contingency for channel indices valued 0 or 1. I know that in general the order is XYCZT, but it seems like it comes so close to working with alternative orders.

If you're curious, I discovered this when attempting to project the index 0 or 1 axis using ops.transform().project() on a dataset where this index had been set as Axes.Z type. Redefining the type alone worked great to rotate the image display perspective, but projecting the data fails at this point.

Error message:

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
at net.imglib2.AbstractInterval.min(AbstractInterval.java:208)
at net.imagej.Position.setPosition(Position.java:324)
at net.imagej.Position.setPosition(Position.java:367)
at net.imagej.display.DefaultDatasetView.getCurrentLUT(DefaultDatasetView.java:556)
at net.imagej.display.DefaultDatasetView.updateLUTs(DefaultDatasetView.java:543)
at net.imagej.display.DefaultDatasetView.rebuild(DefaultDatasetView.java:398)
at net.imagej.display.DefaultImageDisplay.rebuild(DefaultImageDisplay.java:134)
at net.imagej.display.DefaultImageDisplay.display(DefaultImageDisplay.java:272)
at org.scijava.display.DefaultDisplayService.createDisplayQuietly(DefaultDisplayService.java:228)
at org.scijava.display.DefaultDisplayService.createDisplay(DefaultDisplayService.java:210)
at org.scijava.display.DefaultDisplayService.createDisplay(DefaultDisplayService.java:205)
at Draw3DROI.updateDisplay(Draw3DROI.java:428)
at Draw3DROI.viewChoice(Draw3DROI.java:188)
at Draw3DROI.preview(Draw3DROI.java:134)
at org.scijava.widget.DefaultWidgetModel.lambda$setValue$0(DefaultWidgetModel.java:171)
at org.scijava.thread.DefaultThreadService.lambda$wrap$1(DefaultThreadService.java:233)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
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:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
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)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in DefaultDatasetView.java at getCurrentLUT, especially lines 554-557, and trace how rebuild updates LUTs for an ImageDisplay. Reproduce the failure with ops.transform().project() when the channel axis is 0 or 1, then verify that rebuilding the display no longer raises ArrayIndexOutOfBoundsException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
desktop-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.