Shift and wrap-around voxels transform

Hi all,

I would like to apply a shift in a definite direction (in my case, X) to the voxel values (not the coordinates) of a volume - keeping, thus, origin, spacing and dimensions intact.

Also, I would like to wrap around the voxels that were shifted outside of the region - i.e., if I’m shifting the voxels to the right, the ones that would fall outside of the region start to appear at the other side.

I am trying to use a GridTransform, but I know I’ll have a problem at the wrap around border. Also, it’s a dense transform and what I need is really a manipulation of voxels.

Maybe a custom transform in C++ is the way? Or is there any solution at the Python level?

I would love to know your thought on this. Thanks in advance,

Tiago

You can do almost anything with fancy numpy indexing. It can be a challenge to find the right recipe, but you should be able to easily iterate and inspect the results until you get what you want. Look in the script repository for examples and use LLMs to help with the syntax.