ROIs selection of a stack

Hello,
my question is about the ROIs of a stack. I am writing a pluggin and I would like to select for a given image all the ROIs that correspond to it. Knowing that each image of the Stack does not necessarily have the same number of ROIs. This selection would allow me to associate them later with the XOR function.
Thanks

Hi @Pierre,

Welcome to the forum!

I’m not an expert on this, but many people seem to like using the ROI Manager for stuff like this.

If you’re using the macro language, there’s some information here.

This forum discussion may help too.

Please reply if your still have questions,
John

thank you but my question was a bit more technical. I solved it as follows:

	run("Image Sequence...", "open=["+dir1+"/Lab/"+name1+"L.tif]  starting=1 increment=1 scale=100 file=[L] or=[] sort use ");
	setSlice(j);
	run("Duplicate...", "use");
	setOption("BlackBackground", false);
	run("Convert to Mask");
	run("Analyze Particles...", "size=0.50-Infinity add in_situ"); m2=getValue("results.count");
	name = getMetadata("Label"); print(name);
	roiManager("Show None");
	n1=roiManager('count');
	for (k=0; k<n1; k++) 
		{
		roiManager("Select", k);
		 List.setMeasurements();
		Roi.setProperty(name);
		}
	roiManager('deselect');
	path = getDirectory('temp')+'tmp.zip';
	roiManager('save', path);
	roiManager("reset");
	wait (1000);
	roiManager('open', path);
	array  =selectROIS(name);
	roiManager ('select', array);
	roiManager("XOR");
	roiManager("Add");
	roiManager("Save",  dir1+"/Results/"+name+"RoiSet.zip");
	close("*");
	run("Image Sequence...", "open=["+dir1+"/Lab/"+name1+"L.tif]  starting=1 increment=1 scale=100 file=[L] or=[] number=n sort use ");
	setSlice(j);
	roiManager("Select", n1);
	run("Set Measurements...", "area mean modal min display redirect=None decimal=1");
	roiManager("Measure");
	close("*");
	close("ROI Manager");
	}


	function selectROIS (keyword)
		 {
		ids=newArray(0);
		for (l=0;l<roiManager('count');l++) 
			{
			roiManager("select",l);
			if (Roi.getProperty(keyword)) 
				{
				ids=Array.concat(ids,l);
				}
			}
		return ids;
		}

}

1 Like