0

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!

  • This is hard to answer without knowing more about ThunderSTORM. Exactly what should replace the final line of your loop depends on the output of ThunderSTORM. You will likely get more help by posting on https://forum.image.sc FWIW, `input_directory` will only be a one-line array consisting of the path string you assign in the first line, and the loop won't process any images in that folder. So that part needs to be fixed. – quantixed Apr 05 '22 at 21:04
  • Thank you! I have actually changed the beginning to a directory based code. It seems to have worked and opens all the files individually. I will look into the link, thank you! – user18715468 Apr 06 '22 at 00:10

0 Answers0