Looping "clear outside" through specific channels/slices

Hi all,

the “clear outside” command only allows me to clear a complete stack or only one slice. However, I want to automate it to clear only channel 2 of my 3 channel image. I can´t seem to find a solution for scripting that. I work with 3 channel images, where each channel has 50 slices, so total stack size is 150. I have my ROI in the ROI manager and now want to clear slices 51-100 (=channel 2).

How do I loop that?

Thanks!

Hi @Sreusch
If I understand clearly you have 150 ROI in your manager. And you want to get ride of ROI 51 to 100?
Is this behavior you want?
Try this if it helps.

newImage("Untitled", "8-bit ramp", 512, 512, 1);
//setTool("rectangle");
makeRectangle(36, 44, 91, 73);
roiManager("Add");
makeRectangle(178, 164, 21, 103);
roiManager("Add");
makeRectangle(417, 98, 61, 30);
roiManager("Add");
//setTool("oval");
makeOval(308, 254, 53, 74);
roiManager("Add");
makeOval(129, 230, 48, 71);
roiManager("Add");
makeOval(244, 341, 71, 77);
roiManager("Add");
//setTool("line");
makeLine(53, 267, 161, 268);
roiManager("Add");
makeLine(346, 208, 280, 242);
roiManager("Add");
makeLine(452, 359, 357, 340);
roiManager("Add");
roiManager("Show All");
wait(2000);
n = roiManager("count");
a=Array.getSequence(n);
a2 = Array.slice(a, 3, 6);
roiManager("Select", a2);
roiManager("Combine");
roiManager("Set Fill Color", "blue");
wait(2000);
roiManager("Select", newArray(3,4,5));
roiManager("Delete");
roiManager("Show All");