Re: Saving results automatically without going through save as dialog.

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

Good day no-name,

I think

        dir = getDirectory("path");

is not a valid option.

Here is some code snippet that saves the content of the results table to
the directory from which you've opened the last image:

setBatchMode(true);
dir = File.directory;
name = File.nameWithoutExtension;
run("Measure");
saveAs("results",  dir + name + ".csv");
setBatchMode(false);


HTH

Herbie

:::::::::::::::::::::::::::::::::::
Am 18.02.17 um 16:26 schrieb djw23:

> 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");
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Saving-results-automatically-without-going-through-save-as-dialog-tp5018135.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