Copy / Paste ROI contents into stack

Hi all,

So, I can:

  1. select an ROI and copy the contents to another image and move it to the desired location.
  2. select a stack of images and insert it into another stack at the desired (x,y) position.

This can be done in an IJM macro with a few commands.

Is there a simple way to select a region (xy) and, for all elements in the stack copy a volume from a first stack and paste the contents into another stack?

Of course I could use method 1 and repeat that for all slices , but I want to check if I don’t overlook a simpler method.


[EDIT: RH, I am looking for a way to do this in the CLIJ2 routine :slight_smile: ]

1 Like

Hey @Fred_ckx,

if your ROI is rectangular/cuboidal, the crop&paste tutorial demonstrates how to do this in #clij. It works in 3D analogously to 2D.


No, my ROIs are not rectangular / cuboidal unfortunately. This is the reason why stitching them with stack insertion does not work (see yesterday’s screenshot) No idea if a command exists in non-CLIJ2 the world?

My ROIs are static regions (their shape and position do not vary over time but their pixel values can).
I am reading ROI related passages in your CLIJ docs. If I understand that well, I can not use ROIs in the IJM way. But I try if I see options with available CLIJ methods. If not, I need to do it inside the loop over frames, but in the CPU.

At the same time I learn if labeling and connected bodies can bring me something for a different task…

1 Like

You could mask a region and use maximumImages to put parts together. I’m sure you’ll find a way. If not, please share some example images and code to explain what you’re trying to achieve :wink:

1 Like

That’s a clever one. Overwrite only the zero or black regions :slight_smile: . Could work. My ROIs do not overlap. Only their bounding boxes do.

In maxiumImages both images probably need to have the same size? So I paste each ROI in a fresh black image of the desired canvas size. And then do maximumImages with the composition every time…
@haesleinhuepf, in the cheat sheet I see that mask and maximumImages are 2D or 3D routines.
Doing it on a stack would indeed be efficient !

When I want to do your suggested trick on a 3D stack in one go, do I have to construct a 3D mask also? Even if it is the same in all frames?