help write macro for saving each ROI in ROIManager as separate file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

help write macro for saving each ROI in ROIManager as separate file

DHNguyen
Hi all,

Could someone help me write a macro to save each ROI in an ROIManager as a separate file?



Here are the variables:

TotalNumROI = this is inputted by the user, which is different for each image that has many ROIs in it.

N = an integer: 0, 1, 2, etc., up to TotalNumofROI


Here are the core steps:

roiManager("Select", N); run("Copy");
newImage("Untitled-N", "RGB black", 400, 400, 1);
run("Paste");
saveAs("Jpeg", PATH);
close();

--

I want to be able to open the an image and it's ROI manager, then input the total number of ROIs into the macro script, and run the macro such that each ROI is saved as a separate jpeg.

How do I create a loop that changes the integer N by increments of 1 until, and including, the last ROI is saved as a separate jpeg?

Thanks,

Dave


Reply | Threaded
Open this post in threaded view
|

Re: help write macro for saving each ROI in ROIManager as separate file

Lachlan Whitehead
Hi Dave,

A simple for loop is what you're looking for:

for(N=0;N<roiManager("Count");N++){
   roiManager("Select",N);
   run("Copy");
   newImage("Untitled-"+N, "RGB black", 400, 400, 1);
   run("Paste");
   saveAs("Jpeg", PATH);
   close();
}



----- Original Message -----
From: "DHNguyen" <[hidden email]>
To: [hidden email]
Sent: Tuesday, 23 August, 2016 3:44:14 AM
Subject: help write macro for saving each ROI in ROIManager as separate file

Hi all,

Could someone help me write a macro to save each ROI in an ROIManager as a
separate file?



Here are the variables:

TotalNumROI = this is inputted by the user, which is different for each
image that has many ROIs in it.

N = an integer: 0, 1, 2, etc., up to TotalNumofROI


Here are the core steps:

roiManager("Select", *N*); run("Copy");
newImage("Untitled-*N*", "RGB black", 400, 400, 1);
run("Paste");
saveAs("Jpeg", PATH);
close();

--

I want to be able to open the an image and it's ROI manager, then input the
total number of ROIs into the macro script, and run the macro such that each
ROI is saved as a separate jpeg.

How do I create a loop that changes the integer N by increments of 1 until,
and including, the last ROI is saved as a separate jpeg?

Thanks,

Dave






--
View this message in context: http://imagej.1557.x6.nabble.com/help-write-macro-for-saving-each-ROI-in-ROIManager-as-separate-file-tp5017095.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
______________________________________________________________________

The information in this email is confidential and intended solely for the addressee.
You must not disclose, forward, print or use it without the permission of the sender.
______________________________________________________________________

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: help write macro for saving each ROI in ROIManager as separate file

DHNguyen
Hi Lachlan,

This is very  helpful.

Are you a researcher?

Best,

Dave

On Mon, Aug 22, 2016 at 6:35 PM, Lachlan Whitehead [via ImageJ] <[hidden email]> wrote:
Hi Dave,

A simple for loop is what you're looking for:

for(N=0;N<roiManager("Count");N++){
   roiManager("Select",N);
   run("Copy");
   newImage("Untitled-"+N, "RGB black", 400, 400, 1);
   run("Paste");
   saveAs("Jpeg", PATH);
    close();
}



----- Original Message -----
From: "DHNguyen" <[hidden email]>
To: [hidden email]
Sent: Tuesday, 23 August, 2016 3:44:14 AM
Subject: help write macro for saving each ROI in ROIManager as separate file

Hi all,

Could someone help me write a macro to save each ROI in an ROIManager as a
separate file?



Here are the variables:

TotalNumROI = this is inputted by the user, which is different for each
image that has many ROIs in it.

N = an integer: 0, 1, 2, etc., up to TotalNumofROI


Here are the core steps:

roiManager("Select", *N*); run("Copy");
newImage("Untitled-*N*", "RGB black", 400, 400, 1);
run("Paste");
saveAs("Jpeg", PATH);
close();

--

I want to be able to open the an image and it's ROI manager, then input the
total number of ROIs into the macro script, and run the macro such that each
ROI is saved as a separate jpeg.

How do I create a loop that changes the integer N by increments of 1 until,
and including, the last ROI is saved as a separate jpeg?

Thanks,

Dave






--
View this message in context: http://imagej.1557.x6.nabble.com/help-write-macro-for-saving-each-ROI-in-ROIManager-as-separate-file-tp5017095.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
______________________________________________________________________

The information in this email is confidential and intended solely for the addressee.
You must not disclose, forward, print or use it without the permission of the sender.
______________________________________________________________________

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



If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/help-write-macro-for-saving-each-ROI-in-ROIManager-as-separate-file-tp5017095p5017099.html
To unsubscribe from help write macro for saving each ROI in ROIManager as separate file, click here.
NAML