Dear list,
I wrote a macro using the ROI-Manager. I observe a strange result when running the macro in BatchMode. Unfortunately I couldn`t find the exact command that causes the error but I attached the code and 3 sample images. The macro is supposed to identify nuclei in one of the images and subsequently copy a ROI from each of the images that contains the nucleus. Further more the ROIs get concatenated and saved to disk. (if you try please coorect the absolute patch at the end of the code). Whereas the ROIs get detected, processed and saved correctly in non-BatchMode, in BatchMode one and the same ROI gets saved as many times as there are ROIs in the manager. since the code works without BatchMode I suppose its a bug specific to batchMode . Best Regards Eik Code:: //setBatchMode(true); selectWindow("blue.tif"); //Cell detection in the blue channel run("Select None"); run("Duplicate...", "title=mask"); run("Subtract Background...", "rolling=50 slice"); run("Convert to Mask", " "); run("Dilate", "slice"); roiManager("reset"); run("Analyze Particles...", "size=300-40000 circularity=0.4-1 show=Nothing exclude include add"); close(); for(i=1;i<=roiManager("count");i++){ //Prozedere für jedes erkannte Objekt selectWindow("blue.tif"); roiManager("select", i-1); run("Enlarge...", "enlarge=-1 pixel"); getSelectionBounds(x,y,width,height); run("Specify...", "width=120 height=120 x="+(x+width/2)+" y="+(y+height/2)+" slice=1 centered"); run("Duplicate...", "title=blue"+i); selectWindow("green.tif"); roiManager("select", i-1); run("Specify...", "width=120 height=120 x="+(x+width/2)+" y="+(y+height/2)+" slice=1 centered"); run("Duplicate...", "title=green"+i); selectWindow("red.tif"); roiManager("select", i-1); run("Specify...", "width=120 height=120 x="+(x+width/2)+" y="+(y+height/2)+" slice=1 centered"); run("Duplicate...", "title=red"+i); run("Concatenate...", "stack1=blue"+i+" stack2=green"+i+" title=concat"); run("Concatenate...", "stack1=concat stack2=red"+i+" title=concat"); run("Save", "save=C:\\temp\\concat"+i+".tif"); close(); } //setBatchMode(false); ![]() ![]() ![]() |
On Sep 30, 2011, at 7:46 AM, Eik Schumann wrote:
> Dear list, > > I wrote a macro using the ROI-Manager. I observe a strange result when > running the macro in BatchMode. > Unfortunately I couldn`t find the exact command that causes the error > but I attached the code and 3 sample images. > The macro is supposed to identify nuclei in one of the images and > subsequently copy a ROI from each of the images that contains the nucleus. > Further more the ROIs get concatenated and saved to disk. (if you try > please coorect the absolute patch at the end of the code). > Whereas the ROIs get detected, processed and saved correctly in > non-BatchMode, in BatchMode one and the same ROI gets saved as many > times as there are ROIs in the manager. > > since the code works without BatchMode I suppose its a bug specific to > batchMode. According to the release notes (http://imagej.nih.gov/ij/notes.html), this bug was fixed in ImageJ 1.45c. 1.45c 10 March 2011 Thanks to Bill Mohler, fixed a bug that caused the Image>Stacks>Tools>Concatenate command to not work as expected in batch mode macros. -wayne > Code:: > > //setBatchMode(true); > selectWindow("blue.tif"); //Cell detection in the blue channel > run("Select None"); > > run("Duplicate...", "title=mask"); > run("Subtract Background...", "rolling=50 slice"); > run("Convert to Mask", " "); > run("Dilate", "slice"); > > roiManager("reset"); > run("Analyze Particles...", "size=300-40000 circularity=0.4-1 > show=Nothing exclude include add"); > close(); > > for(i=1;i<=roiManager("count");i++){ //Prozedere für jedes erkannte > Objekt > selectWindow("blue.tif"); > roiManager("select", i-1); > run("Enlarge...", "enlarge=-1 pixel"); > getSelectionBounds(x,y,width,height); > > run("Specify...", "width=120 height=120 x="+(x+width/2)+" > y="+(y+height/2)+" slice=1 centered"); > run("Duplicate...", "title=blue"+i); > > selectWindow("green.tif"); > roiManager("select", i-1); > run("Specify...", "width=120 height=120 x="+(x+width/2)+" > y="+(y+height/2)+" slice=1 centered"); > run("Duplicate...", "title=green"+i); > > selectWindow("red.tif"); > roiManager("select", i-1); > run("Specify...", "width=120 height=120 x="+(x+width/2)+" > y="+(y+height/2)+" slice=1 centered"); > run("Duplicate...", "title=red"+i); > > run("Concatenate...", "stack1=blue"+i+" stack2=green"+i+" title=concat"); > run("Concatenate...", "stack1=concat stack2=red"+i+" title=concat"); > run("Save", "save=C:\\temp\\concat"+i+".tif"); close(); > > } > //setBatchMode(false); > > > <blue.tif><green.tif><red.tif> |
Free forum by Nabble | Edit this page |