1 year ago

#378563

test-img

user18715468

ImageJ/Fiji - Save CSV using macro

I am not a coder but trying to turn ThunderSTORM's batch process into an automated one where I have a single input folder and a single output folder.

input_directory = newArray("C:\\Users\\me\\Desktop\\Images");
output_directory = ("C:\\Users\\me\\Desktop\\Results");

for(i = 0; i < input_directory.length; i++) {
    open(input_directory[i]);
    originalName = getTitle();
    originalNameWithoutExt = replace( originalName , ".tif" , "" );
    fileName = originalNameWithoutExt;
    run("Run analysis", "filter=[Wavelet filter (B-Spline)] scale=2.0 order=3 detector "+
        "detector=[Local maximum] connectivity=8-neighbourhood threshold=std(Wave.F1) "+
        "estimator=[PSF: Integrated Gaussian] sigma=1.6 method=[Weighted Least squares] fitradius=3 mfaenabled=false "+
        "renderer=[Averaged shifted histograms] magnification=5.0 colorizez=true shifts=2 "+
        "repaint=50 threed=false");
    saveAs(fileName+"_Results", output_directory);
}

This probably looks like a huge mess but the original batch file used arrays and I can't figure out what that is. Taking it out brakes it so I left it in. The main issues I have revolve around the saveAs part not working.

Using run("Export Results") works but I need to manually pick a location and file name. I tried to set this up to take the file name and rename it to the generic image name so it can save a CSV using that name.

Any help pointing out why I'm a moron? I would also love to only open one file at a time (this opens them all) and close it when the analysis is complete. But I will settle for that happening on a different day if I can just manage to save the damn CSV automatically.

For the most part, I broke the code a whole bunch of times but it's in a working condition like this.

I appreciate any and all help. Thank you!

imagej

fiji

imagej-macro

0 Answers

Your Answer

Accepted video resources