Login  Register

Re: Image Calculator in a loop using a variable number of images

Posted by George Patterson on Dec 01, 2015; 4:04pm
URL: http://imagej.273.s1.nabble.com/Image-Calculator-in-a-loop-using-a-variable-number-of-images-tp5015045p5015064.html

Hi,
There are a number of changes that need to be made to get the loop with the
imageCalculator to work.
Is there some reason you can't do the image calculation right after
creating your mask?
Something like the edits on your script below?
I have it closing the maskfiles and xymaskfiles after the calculation, but
that is up to you.
If you need to run the imageCalculator after creating all of your mask
files, I can probably help you figure it out.
Best,
George



XYRawFileID=getImageID();//get the ID of the image you are analyzing
waitForUser("Draw the cellular outlines with the polygon tool, press <t>.
Press the OK-button subsequently");
for (i=0 ; i<roiManager("count"); i++) {
roiManager("select", i);
run("Create Mask");
MaskFile = fileWithoutEnding + "_Mask_" + i + ".tif";
MaskFileID=getImageID();
saveAs("Tiff", resultPath + File.separator + MaskFile);
imageCalculator("AND create", MaskFileID, XYRawFileID);
XYMaskFileID=getImageID();
XYMaskFile = fileWithoutEnding + "_XY Mask_" + i + ".tif";
saveAs("Tiff", resultPath + File.separator + XYMaskFile);
selectImage(MaskFileID);
close();
selectImage(XYMaskFileID);
close();
}

On Sat, Nov 28, 2015 at 12:09 PM, lillly <[hidden email]> wrote:

> Hi guys,
>
> I took some IF images of cells. Very important: The number of cells per
> image varies! After using the polygon tool to draw the outlines of each
> cell
> and transferring the regions to RoiManager, I created a mask for each cell,
> respectively, and saved the images.
>
> -------------------------------------------------------------------
> waitForUser("Draw the cellular outlines with the polygon tool, press <t>.
> Press the OK-button subsequently");
> for (i=0 ; i<roiManager(&quot;count&quot;); i++) {
> roiManager(&quot;select&quot;, i);
> run(&quot;Create Mask&quot;);
> MaskFile = fileWithoutEnding + &quot;_Mask_&quot; + i + &quot;.tif&quot;;
> saveAs(&quot;Tiff&quot;, resultPath + File.separator + MaskFile);
> }
> --------------------------------------------------------------------
>
> The first part is fine. The next step is as follows: I have to compare the
> original image with each mask individually by using Image Calculator.
> However, the macro I wrote does apparently not work. I'm now hoping for
> your
> help, suggestions, inputs,...
>
> &lt;b>How can I* compare one image (here: XYRawFile) with a variable number
> of files (here: MaskFile) in a loop?
>
> ---------------------------------------------------------------------
> for (i=0 ; i<Mask File; i++) {
> imageCalculator(&quot;AND create&quot;, MaskFile, XYRawFile);
> XYMaskFile = fileWithoutEnding + &quot;_XY Mask_&quot; + i +
> &quot;.tif&quot;;
> saveAs(&quot;Tiff&quot;, resultPath + File.separator + XYMaskFile);
> }
> ---------------------------------------------------------------------
>
> &lt;b>THANKS FOR YOUR HELP!*
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Image-Calculator-in-a-loop-using-a-variable-number-of-images-tp5015045.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