Deconvoluted Image Not Displaying / Saving

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Deconvoluted Image Not Displaying / Saving

dcsen87
Hello all,

I am trying to write a macro to generate PSFs and then run deconvolution for a set of z-stacks. A new PSF has to be generated for each stack because of the different slice number in each stack. The macro appears to be running fine (generating a new PSF, using the PSF & the image in the deconvolution plugin, running up to 100 iterations of deconvolution), however 1) the temporary deconvolutions (images generated each iteration) are not displayed as is done when running the plug-in outside of the macro and 2) the final deconvoluted image is not displayed and I therefore cannot save it into my output folder.

Any suggestions? Thanks so much in advance if anyone is able to help!

Here is the macro so far in IJM language (new to programming, but have written a few successful batch processing macros in ImageJ)



function pS831Decon(input, output, filename) {
       
open(input + filename);
run("Split Channels");

selectWindow("C2-" + filename);//VG2
close();
selectWindow("C3-" + filename); //PSD95
close();
selectWindow("C1-" + filename); //pS831

slicenumber = nSlices;  

run("Diffraction PSF 3D", "index=1.500 numerical=1.40 wavelength=488 longitudinal=0 image=90 slice=900 width,=324 height,=324 depth,="+slicenumber+" normalization=[Peak = 255] title=pS831PSF-"+filename+"");

run("Iterative Deconvolve 3D", "imga=C1-"+filename+" point=pS831PSF-"+filename+" output=Deconvolved-"+filename+" show log perform detect wiener=0.000 low=1 z_direction=1 maximum=100 terminate=0.010");


selectWindow("Deconvolved-"+filename+"");

saveAs("Tiff", output +"Deconvolved-"+filename+""+ ".tif");
close();


}

input = "/Users/dcs/Documents/Images/Exps/test/";
output = "/Users/dcs/Documents/Images/Exps/pS831decon/";


setBatchMode(true);
list = getFileList(input);
for (i = 0; i < list.length; i++)
       pS831Decon(input, output, list[i]);
setBatchMode(false);
Reply | Threaded
Open this post in threaded view
|

Re: Deconvoluted Image Not Displaying / Saving

dcsen87
Hi Everyone,

I actually figured it out on my own. Adding this line kept all image windows open during the macro run:

setBatchMode(false); // show all images

And then this at the end closed all of them before the next iteration of the function:

while (nImages>0) { //closing all open images
          selectImage(nImages);
          close();
      }

I found these both here:

https://imagej.nih.gov/ij/developer/macro/functions.html#run

Hope this helps someone in the future!