Skip to content

Slicing net.imagej.Dataset returns an IntervalView which does not support dimension metadata #226

Open
@elevans

Description

@elevans

Here is a minimal example using the test_timeseries.tif sample data from the PyImageJ repo.

import imagej

# initialize ImageJ
ij = imagej.init()

# load data
dataset = ij.io().open("doc/sample-data/test_timeseries.tif")
xarr = ij.py.from_java(dataset)

# slice data
xarr_slice = xarr[10, :, :, :]
dataset_slice = dataset[ :, :, :, 10]

The xarray slice maintains the associated image metadata:

>>>  xarr_slice.shape
>>>  (250, 250, 3)
>>>  xarr_slice.dims
>>>  ('row', 'col', 'ch')

But the dataset slice (net.imglib2.view.IntervalView) looses the metadata.

>>>  dataset_slice.shape
>>>  (250, 250, 3)
>>>  dataset_slice.dims
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'net.imglib2.view.IntervalView' object has no attribute 'dims'

We should and can do better here. Instead of IntervalView we should wrap slices as net.imagej.Datasets with the appropriate metadata.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions