Simplify ImgPlus creation
- Dominant language
- Java
- Stars
- 94
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
Consider this script that take a single frame and add it as a second channel to a stack (single frame is duplicated to match the number of frame in the stack) :
```python
# @Dataset(label="Single Frame") singleFrame
# @Dataset(label="Stack") stack1
# @ImageJ ij
# @OUTPUT Dataset stack
from net.imglib2.view import Views
from net.imglib2.img import ImgView
from net.imglib2.img.array import ArrayImgFactory
from net.imagej.axis import Axes
from net.imagej import ImgPlus
nFrames = stack1.getFrames()
stack1 = Views.dropSingletonDimensions(stack1)
stack2_list = list([singleFrame.duplicate() for i in range(nFrames)])
stack2 = Views.stack(stack2_list)
stack2 = Views.dropSingletonDimensions(stack2)
stack = Views.stack(list([stack1, stack2]))
stack = ImgPlus(ImgView.wrap(stack, ArrayImgFactory()), "", [Axes.X, Axes.Y, Axes.TIME, Axes.CHANNEL])
stack = ij.dataset().create(stack)
```
I found the `stack = ImgPlus(ImgView.wrap(stack, ArrayImgFactory()), "", [Axes.X, Axes.Y, Axes.TIME, Axes.CHANNEL])` a bit complicated.
Could we imagine an ops that take the output of a `Views.stack()` + a list of `Axes` and return the correct `ImgPlug` ?
If you think it's a good idea and as straightforward as embedding `stack = ImgPlus(ImgView.wrap(stack, ArrayImgFactory()), "", [Axes.X, Axes.Y, Axes.TIME, Axes.CHANNEL])` in a ops class, I can submit a PR.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the example script and review how Views.stack, ImgPlus, ImgView.wrap, ArrayImgFactory, and Axes are used to assemble the result. Confirm the proposed operation's intended inputs and verify that done means returning the correctly dimensioned ImgPlus from a stacked view and axis list.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, python
- Domain
- computer-vision
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100