imagej / imagej/pyimagej

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

Open
#226 1 comment 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
534
Forks
95
PR merge metrics
No merged PRs in 30d

Description

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

```python
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:

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

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

```python
>>> dataset_slice.shape
>>> (250, 250, 3)
>>> dataset_slice.dims
Traceback (most recent call last):
File "", line 1, in
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.Dataset`s with the appropriate metadata.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the minimal slicing example using doc/sample-data/test_timeseries.tif and compare xarray slicing with dataset slicing. Trace how net.imagej.Dataset indexing produces a net.imglib2.view.IntervalView, then determine how the slice can retain appropriate metadata such as dims. Done means dataset slices expose the expected metadata instead of raising AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.