Best way to add (hyper)slice to multidimensional RAI

Hi ImageJ fans!

I have a “best practice” question. What is the best way to add data to a RAI? I have a 3D dataset with some z-shift between channels. I have calculated the value of z-shift and sould like to align channels together. Using legacy ImageJ API I would split the stack to individual slices and insert empty slices at the beginning or end of the stack, so all channels have same number of slices that align nicely.

I guess that splitting stack into slices (using for example crop op) is not the best way to achieve the same outcome, is it? I thought of creating a new RAI with the correct dimensions and copying pixel values, but that seems memory-intensive, especially for large datasets (2048x2048x150x5 xyzc). Do you have any suggestions? Is there a way to modify RAI in place? This could also be applicable to aligning timeseries, etc…

Best,

Radek

Hi Radek,

Have a look at Views.hyperslice and Views.concatenate and Views.stack, I think what you want is to have an independent transformation for each channel and then to compose them back into a 4D image? That would be done by a sequence of

Views.hyperslice

Views.extend

Views.interpolate

RealViews.transform

Views.raster

Views.interval

Views.stack

None of these operations generate data but are executed on the fly.

1 Like

Hi Stephan!

Great to hear from you! Basically what I want to achieve is to add a number of black slices in the beggining of some channels and in the end of others. If I understood JavaDocs correctly, Views.hyperslice will allow me to select a channel hyperslice, Views.extend will extend my hyperslice with 0 values, until infinity. But I do not understand the need for Views.interpolate, RealViews.transform and Views.raster. Wouldn’t Views.interval be sufficient to now crop the infinitely extended hyperslice to desired dimensions? Followed by Views.stack to put all channels back together? I do not need to set any values on the inserted slices, nor I want to modify the original data in any way.

Thanks for the tips!

Best,

Radek

The transforms stuff is for the independent transformations for each channel. I read that from your OP, but if you don’t need it, you will only need hyperslice, extend, offsetInteval, stack ;).

1 Like