Batch process ROI between two sets of images

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

Batch process ROI between two sets of images

dc1312
I'm afraid I am completely new to writing macros for ImageJ and so I'm struggling and would really appreciate any help.

How do use one set of images to mask out another set of images in a batch process? For example I have two sets of images; the first set contains images only with a mask, the second set contains cells with my "interesting" data in. So for one cell I do this:

1. Open "mask" image
2. Create selection
3. Save as ROI
4. Open "interesting" image
5. Apply ROI
6. Set selection to value="NaN"
7. Save new "interesting" image

I can't work out a way to batch process many images. The tricky bit is saving the ROI from the mask and applying it to the appropriate cell.

Thank you for any help!

David
Reply | Threaded
Open this post in threaded view
|

Re: Batch process ROI between two sets of images

ctrueden
Hi David,

> I'm afraid I am completely new to writing macros for ImageJ and so I'm
> struggling and would really appreciate any help.

Have you seen these wiki pages?
http://imagej.net/Segmentation
http://imagej.net/Introduction_into_Macro_Programming#The_recorder

> I can't work out a way to batch process many images. The tricky bit is
> saving the ROI from the mask and applying it to the appropriate cell.

See the Process > Batch > Macro command:
http://imagej.net/docs/guide/146-29.html#toc-Subsubsection-29.12.3

To move a ROI from a mask back to the original image, use the "Restore
Selection" command.

The #1 tip to remember is: press L for the Command Finder to run commands.
Much faster than searching the menus for them!

Regards,
Curtis


On Wed, Aug 6, 2014 at 9:55 AM, dc1312 <[hidden email]> wrote:

> I'm afraid I am completely new to writing macros for ImageJ and so I'm
> struggling and would really appreciate any help.
>
> How do use one set of images to mask out another set of images in a batch
> process? For example I have two sets of images; the first set contains
> images only with a mask, the second set contains cells with my
> "interesting"
> data in. So for one cell I do this:
>
> 1. Open "mask" image
> 2. Create selection
> 3. Save as ROI
> 4. Open "interesting" image
> 5. Apply ROI
> 6. Set selection to value="NaN"
> 7. Save new "interesting" image
>
> I can't work out a way to batch process many images. The tricky bit is
> saving the ROI from the mask and applying it to the appropriate cell.
>
> Thank you for any help!
>
> David
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Batch-process-ROI-between-two-sets-of-images-tp5009046.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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

Re: Batch process ROI between two sets of images

dc1312
Hi Curtis,

Thank you for the help, much appreciated.

I want to:
1. Open the first "A" image
2. Create a selection
3. Copy this selection to the first "B" image
4. Set selection to "value = NaN"
5. Save the new "B" image
6. Repeat for the second A and B image

Here's what I have but I suspect it's very wrong!

inputA = getDirectory("Choose the A images input folder");
inputB = getDirectory("Choose the B images input folder");      
output = getDirectory("Choose the output folder");
 
setBatchMode(true);
list = getFileList(inputA);
for (i = 0; i < list.length; i++)
        process(inputA, output, list[i]);
setBatchMode(false);
 
function process(inputA, output, filename)
{
    open (inputA + filename);
        run("Create Selection");  
        open (inputB + filename);
    run("Restore Selection");
        run("Set...", "value=NaN");
    saveAs("Tiff", output + filename);        
    close();                  
}

Any help much appreciated.

David