ROIManager

Posted by Glen MacDonald-3 on
URL: http://imagej.273.s1.nabble.com/ROIManager-tp5022037.html

A user drew ovals around nuclei and saved the rois in ROIManager.  
I want to automate copying the nuclear profiles from the original 3-channel 16-bit image into a blank channel in a new 3-channel 16-bit image stack.  
Problem:
The following bare bones macro works to a point.  somewhere, the macro loses control of the coordinates and begins pasting the nuclear profiles in the center of the target slice.  

//assumes the roiManager list is open
origid=getImageID();//original stack
basename=File.nameWithoutExtension;
run("Select All”);
run("Duplicate...","title=["+basename+"] duplicate");//make target stack, select all required
dupid=getImageID();
setBackgroundColor(0,0,0);
run("Select All");
run("Clear","stack");//clear target
roiManager("Show All");//avoid prevent double counting
roic=roiManager("count");
for (i = 0; i < roic; i++) {
        selectImage(origid);
        Stack.setActiveChannels("100");
        roiManager("select", i);
        run("Copy");
        selectImage(dupid);
        Stack.setActiveChannels("100");
        run("Paste");
}

any suggestion appreciated.  MacBookPro, OS10.14.3. IJ 1.52n, Java 1.8.0_162.

thanks,
Glen
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html