ImageJ List,
I am trying to analyze the number of particles in a group of images. I have a macro to cycle through the directories, open the correct image, and threshold. I run the analyze particles: run("Analyze Particles...", "size=7-Infinity circularity=0.75-1.00 show=Nothing clear summarize"); which gives me a summary of particle count. I then want to save the summary: run("Text...", "save="+listdirect+"bead_count.txt"); // saves results This works fine for a few directories but then stops with an error: "This command requires a TextWindow such as the "Log" window or an "Info for..." window." I assumed this was because the analyze particles hadn't finished and the summary window wasn't up yet. I put in a wait(3000) before saving but still got the error. Even with a wait(10000) the error arose. Is there a way to wait until processing of analyze particles is done? Or even better is there a way to directly send the summary of analyze particles to a text file? Thanks for any help. I've included my code below if needed. Colin Sturm fitdirectory = getDirectory("Select a Directory") // prompts what directory to take images from for processing setBatchMode(true); for (i = 1; i <=40; i++) { // changes directory if (i<=9){ listdirect = fitdirectory+"0"+i+"/"; // sets directory } if (i>9){ listdirect = fitdirectory+i+"/"; // sets directory } list = getFileList(listdirect); // gets list of files for working directory if (list.length==0){ // checks if no files found print("Stopped at directory "+listdirect); exit // stops code } open(listdirect+"bandpass_fitc.tif"); // open fitc image setThreshold(0, 60000); // sets threshold of 16-bit image run("Convert to Mask"); // removes everything that isn't thresholded setThreshold(0, 254); // sets threshold so particles can be analyzed run("Analyze Particles...", "size=7-Infinity circularity=0.75-1.00 show=Nothing clear summarize"); close(); wait(3000); run("Text...", "save="+listdirect+"bandpass_fitc_bead_count.txt"); // saves results run("Close"); // closes results open(listdirect+"bandpass_tritc.tif"); // open tritc image setThreshold(0, 60000); // same as above except for tritc image run("Convert to Mask"); setThreshold(0, 254); run("Analyze Particles...", "size=7-Infinity circularity=0.5-1.00 show=Nothing clear summarize"); close(); wait(3000); run("Text...", "save="+listdirect+"bandpass_tritc_bead_count.txt"); run("Close"); } setBatchMode(false); |
On Monday 02 April 2007 16:17:32 Colin Sturm wrote:
> This works fine for a few directories but then stops with an error: > "This command requires a TextWindow such as the "Log" window or an "Info > for..." window." You could test whether the Results window is open, if so, save it and close it, otherwise wait: isOpen("Title") Returns true if the window with the specified title is open. Cheers, G. |
Is there a way to continue to the next iteration of a for loop if a
criteria is met? I tried using continue; but didn't work. Ex: for (i=1; i<=8; i++){ if(i==5) continue; print(i); } So the desired output would be: 1 2 3 4 6 7 8 Thanks |
Chris,
You can do this: for (i=1; i<=8; i++){ if(i<>5) print(i); } Bill Christens-Barry On Mon, 2 Apr 2007 15:54:45 -0400, Colin Sturm <[hidden email]> wrote: >Is there a way to continue to the next iteration of a for loop if a >criteria is met? >I tried using continue; but didn't work. > >Ex: >for (i=1; i<=8; i++){ > if(i==5) > continue; > print(i); >} |
In reply to this post by Colin Sturm
Hi
I think you have to save it like this: saveAs("Measurements",listdirect+"bandpass_tritc_bead_count"); or saveAs("Measurements",listdirect+"bandpass_tritc_bead_count.xls"); Thomas Colin Sturm a écrit : > ImageJ List, > > I am trying to analyze the number of particles in a group of images. > I have a macro to cycle through the directories, open the correct > image, and threshold. > I run the analyze particles: > run("Analyze Particles...", "size=7-Infinity circularity=0.75-1.00 > show=Nothing clear summarize"); > which gives me a summary of particle count. > I then want to save the summary: > run("Text...", "save="+listdirect+"bead_count.txt"); // saves > results > This works fine for a few directories but then stops with an error: > "This command requires a TextWindow such as the "Log" window or an > "Info for..." window." > > I assumed this was because the analyze particles hadn't finished and > the summary window wasn't up yet. I put in a wait(3000) before saving > but still got the error. Even with a wait(10000) the error arose. > > Is there a way to wait until processing of analyze particles is done? > Or even better is there a way to directly send the summary of analyze > particles to a text file? > > Thanks for any help. > I've included my code below if needed. > > Colin Sturm > > > > fitdirectory = getDirectory("Select a Directory") // prompts what > directory to take images from for processing > setBatchMode(true); > for (i = 1; i <=40; i++) { // changes directory > if (i<=9){ > listdirect = fitdirectory+"0"+i+"/"; // sets directory > } > if (i>9){ > listdirect = fitdirectory+i+"/"; // sets directory > } > list = getFileList(listdirect); // gets list of files for > working directory > if (list.length==0){ // checks if no files found > print("Stopped at directory "+listdirect); > exit // stops code > } > open(listdirect+"bandpass_fitc.tif"); // open fitc image > setThreshold(0, 60000); // sets threshold of 16-bit > image > run("Convert to Mask"); // removes everything that > isn't thresholded > setThreshold(0, 254); // sets threshold so particles > can be analyzed > run("Analyze Particles...", "size=7-Infinity circularity=0.75-1.00 > show=Nothing clear summarize"); > close(); > wait(3000); run("Text...", > "save="+listdirect+"bandpass_fitc_bead_count.txt"); // saves > results run("Close"); // closes results > open(listdirect+"bandpass_tritc.tif"); // open tritc image > setThreshold(0, 60000); // same as above except for > tritc image > run("Convert to Mask"); > setThreshold(0, 254); > run("Analyze Particles...", "size=7-Infinity circularity=0.5-1.00 > show=Nothing clear summarize"); > close(); > wait(3000); > run("Text...", "save="+listdirect+"bandpass_tritc_bead_count.txt"); > run("Close"); > } > setBatchMode(false); > |
Free forum by Nabble | Edit this page |