imagej / pyimagej

Use ImageJ from Python
https://pyimagej.readthedocs.io/
Other
473 stars 82 forks source link

Add dimension re-ordering support to `to_dataset()` method #304

Open elevans opened 6 months ago

elevans commented 6 months ago

We can do better here and detect what the input image is and take the appropriate steps to re-order the dataset. If you try to re-order an imglib2 image with to_dataset(img, dim_order=['X', 'Y', 'Channel']) only the first two dimensions will be appropriately assigned. All other dimensions are discarded and unknown is assigned as the dimension label.

ctrueden commented 6 months ago

To be clear: in the case of img being an Img, there is no "reordering" happening, but rather dimensional assignment to match the given dim_order. So this case should IMHO be easy to do. The trickier one is if you call to_dataset on something that is already an ImgPlus or Dataset—then what? Is the user expecting the dimensions to be swapped around? Or just relabeled? (When passing an xarray, what do we do? I forgot.)