This post was updated on .
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("count"); i++) { roiManager("select", i); run("Create Mask"); MaskFile = fileWithoutEnding + "_Mask_" + i + ".tif"; saveAs("Tiff", 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,... 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("AND create", MaskFile, XYRawFile); XYMaskFile = fileWithoutEnding + "_XY Mask_" + i + ".tif"; saveAs("Tiff", resultPath + File.separator + XYMaskFile); } --------------------------------------------------------------------- THANKS FOR YOUR HELP! |
Is there no one out there who could possibly help me solving this problem??!
|
In reply to this post by lillly
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("count"); i++) { > roiManager("select", i); > run("Create Mask"); > MaskFile = fileWithoutEnding + "_Mask_" + i + ".tif"; > saveAs("Tiff", 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,... > > <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("AND create", MaskFile, XYRawFile); > XYMaskFile = fileWithoutEnding + "_XY Mask_" + i + > ".tif"; > saveAs("Tiff", resultPath + File.separator + XYMaskFile); > } > --------------------------------------------------------------------- > > <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 |
Free forum by Nabble | Edit this page |