Login  Register

save summary file

Posted by Colin Sturm on Apr 02, 2007; 4:17pm
URL: http://imagej.273.s1.nabble.com/save-summary-file-tp3699878.html

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);