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 |
Dear Glen,
Before you copy the ROI to the new Image you have to tell where you want to add the ROI otherwise it will be in the centre of your image. So add roiManager("select", i); before run("Paste"); and I think it will work Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester www.le.ac.uk/advanced-imaging-facility ImageJ workshops 15 and 16 July, Leicester, UK. For registration visit https://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/workshops/imagej-workshops-July-2019 -----Original Message----- From: Glen MacDonald <[hidden email]> Sent: 10 April 2019 02:36 To: [hidden email] Subject: ROIManager 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: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&data=02%7C01%7Ckrs5%40leicester.ac.uk%7Cc66d9feee9744801712e08d6bd5b50af%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C636904597242110340&sdata=uLb1m8%2FCGWiUmq2gB0y9GOgwkCwNsb%2F7Br0QIc4zjc4%3D&reserved=0 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
thank you Kees, that was it! I had assumed that 2nd 'roiManager("select", i);’ was redundant and commented out when I cleaned up the macro.
Regards, Glen > On Apr 10, 2019, at 4:00 AM, Straatman, Kees (Dr.) <[hidden email]> wrote: > > Dear Glen, > > Before you copy the ROI to the new Image you have to tell where you want to add the ROI otherwise it will be in the centre of your image. So add > > roiManager("select", i); > > before run("Paste"); > > and I think it will work > > Best wishes > > Kees > > > Dr Ir K.R. Straatman > Senior Experimental Officer > Advanced Imaging Facility > Centre for Core Biotechnology Services > University of Leicester > www.le.ac.uk/advanced-imaging-facility > > ImageJ workshops 15 and 16 July, Leicester, UK. For registration visit https://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/workshops/imagej-workshops-July-2019 > > -----Original Message----- > From: Glen MacDonald <[hidden email]> > Sent: 10 April 2019 02:36 > To: [hidden email] > Subject: ROIManager > > 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: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&data=02%7C01%7Ckrs5%40leicester.ac.uk%7Cc66d9feee9744801712e08d6bd5b50af%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C636904597242110340&sdata=uLb1m8%2FCGWiUmq2gB0y9GOgwkCwNsb%2F7Br0QIc4zjc4%3D&reserved=0 > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |