Saving results automatically without going through save as dialog.

Posted by djw23 on
URL: http://imagej.273.s1.nabble.com/Saving-results-automatically-without-going-through-save-as-dialog-tp5018135.html

Hi,

I've written a macro that will save each of the results from my images as separate csv files.  However, each time I run this,  the dialog box opens upon the get directory command and I keep having to select the output directory before the macro runs.    It does this in batch processing too.   Is there anyway I can bypass this so all of my csv files save automatically without me having to select the output directory?

Thanks in advance

Here is my macro:

dir = getDirectory("path");
T=getTitle();
name = getTitle;
dotIndex = indexOf(name, ".");
name = substring(name, 0, dotIndex);
setBatchMode(true);
selectWindow(T);
run("Split Channels");
selectWindow("C3-"+T);
rename("BDNF");
run("Red");
selectWindow("C2-"+T);
close();
selectWindow("C1-"+T);
rename("DAPI");
run("Blue");
//run("Brightness/Contrast...");
run("Enhance Contrast", "saturated=0.35");
run("8-bit");
run("Gaussian Blur...", "sigma=10");
run("Subtract Background...", "rolling=50");
setAutoThreshold("Moments dark");
//run("Threshold...");
setAutoThreshold("Moments dark");
setThreshold(10, 255);
//setThreshold(10, 255);
run("Convert to Mask");
run("Watershed");
selectWindow("BDNF");
run("8-bit");
run("Subtract Background...", "rolling=16");
run("Mean", "block_radius_x=2 block_radius_y=2");
setAutoThreshold("Moments dark");
//run("Threshold...");
setAutoThreshold("Moments dark");
run("Convert to Mask");
run("Set Measurements...", "area mean standard min integrated redirect=[DAPI] decimal=3");
run("Analyze Particles...", "size=6-150 pixel show=[Overlay Masks] display exclude summarize");
selectWindow("Results");
saveAs("Results",  dir + name + ".csv");