Skip to content

DefaultDatasetView out of bounds error #113

@andmccall

Description

@andmccall

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions