Re: wait for a result to appear

Posted by ctrueden on
URL: http://imagej.273.s1.nabble.com/wait-for-a-result-to-appear-tp5017029p5017038.html

Hi Timothy,

It is worth noting that Parallel Iterative Deconvolution has not been
maintained for many years. I wonder if you have tried any of the more
recent deconvolution plugins and algorithms?

There were two presentations at the last ImageJ conference:

* Brian Northan - Flexible Deconvolution using ImageJ Ops
 -- video - https://vimeo.com/140098821
 -- abstract - http://imagej.net/Conference_2015_Program#Brian_Northan_-_
Flexible_deconvolution_using_ImageJ_Ops
 -- slides - https://imagej.github.io/presentations/2015-09-04-
imagej2-deconvolution/

* Benjamin Schmid - Real-time multi-view deconvolution of time-lapse data
on the GPU
 -- video - https://vimeo.com/140098826
 -- abstract - http://imagej.net/Conference_2015_Program#
Benjamin_Schmid_-_Real-time_multi-view_deconvolution_of_
time-lapse_data_on_the_GPU

See also:
http://imagej.net/Deconvolution

And improvements to that wiki page are very welcome.

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - http://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Wed, Aug 17, 2016 at 9:41 AM, Feinstein, Timothy N <[hidden email]> wrote:

> Thank you Aryeh!  I feel silly for missing that basic bit of Java logic.
>
> Well, that part works now.  Now my problem is that any subsequent command
> appears to supercede Parallel Iterative Deconvolution, even 'wait()'.  It
> is entirely possible that PID automation only works in isolation and not
> inside any more extensive macro.  If anyone thinks the problem is
> solvable, I pasted my code at the bottom. Note that some long lines of
> code will have several paragraph breaks in them when pasting out of an
> email.
>
> All the best,
>
>
> Tim
>
> Timothy Feinstein, Ph.D.
> Research Scientist
> University of Pittsburgh Department of Developmental Biology
>
>
>
> On 8/16/16, 10:41 PM, "ImageJ Interest Group on behalf of Aryeh Weiss"
> <[hidden email] on behalf of [hidden email]> wrote:
>
> >On 17/08/2016 4:34 AM, Feinstein, Timothy N wrote:
> >>Hello,
> >>
> >>I am trying to automate the plugin Parallel Iterative Deconvolution.
> >>This plugin does not seem designed for multi-channel images and
> >>especially for doing them in batches, so I am trying to patch together a
> >>work-around.  The workflow is basically to pre-process for background
> >>subtraction, split channels, deconvolve each channel with the
> >>appropriate point spread function, delete the originals, merge the
> >>results back into one composite and save.
> >>
> >>This all works fine, except that ImageJ cannot tell that the plugin is
> >>still running, so it blazes ahead without the results appearing.  I
> >>believe in theory I can use the WHILE statement to say something like:
> >>
> >>while (isOpen("C1-"+Filename[i]+"_WPL_decon") = False) {
> >>      wait(1000);
> >>}
> >
> >I think you need == , not =.
> >Try:
> >
> >while (isOpen("C1-"+Filename[i]+"_WPL_decon") == False) {
> >
> >
> >>Ideally this should hold the macro in stasis until the deconvolution
> >>cycle is finished and a result appears.  However ImageJ seems to think I
> >>am missing a parentheses at the equals sign.  And I am not sure whether
> >>this strategy would work anyway.
> >>
> >>Any advice would be appreciated.  Best,
> >>
> >>
> >>Tim
> >>
> >>Timothy Feinstein, Ph.D.
> >>
> >>--
> >>ImageJ mailing list:
> >><a href="https://na01.safelinks.protection.outlook.com/?url=http%">https://na01.safelinks.protection.outlook.com/?url=http%
> 3a%2f%2fimagej.ni
> >>h.gov%2fij%2flist.html&data=01%7c01%7ctnf8%40pitt.edu%7cce
> 9b31c0a3ad42887
> >>10708d3c649942d%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&
> sdata=aK0y7w7ZqIAw
> >>8CRfzK6chXWzbWzCmjTj6vZqjPDDi6k%3d
> >
> >
> >--
> >Aryeh Weiss
> >Faculty of Engineering
> >Bar Ilan University
> >Ramat Gan 52900 Israel
> >
> >Ph:  972-3-5317638
> >FAX: 972-3-7384051
> >
> >--
> >ImageJ mailing list:
> ><a href="https://na01.safelinks.protection.outlook.com/?url=http%3a%">https://na01.safelinks.protection.outlook.com/?url=http%3a%
> 2f%2fimagej.nih
> >.gov%2fij%2flist.html&data=01%7c01%7ctnf8%40pitt.edu%7cce9b
> 31c0a3ad4288710
> >708d3c649942d%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=
> aK0y7w7ZqIAw8CR
> >fzK6chXWzbWzCmjTj6vZqjPDDi6k%3d
> dir = getDirectory("Input files");
> output = getDirectory("Save the results");
> filename = getFileList(dir);
>
> _______________________________________________________
>
>
> dir = getDirectory("Input files");
> output = getDirectory("Save the results");
> filename = getFileList(dir);
>
>
> pathGreen = File.openDialog("Select the green PSF");
> pathRed = File.openDialog("Select the red PSF");
> pathFarRed = File.openDialog("Select the far red PSF");
>
> setBatchMode(false);
>
> //define the parameters of deconvolution
>
> function deconvolution() {
>     pathToBlurredImage = image;
>     pathToDeblurredImage = deconImage;
>     pathToPsf = psf;
>     boundary = "REFLEXIVE"; //available options: REFLEXIVE, PERIODIC, ZERO
>     resizing = "AUTO"; // available options: AUTO, MINIMAL,
> NEXT_POWER_OF_TWO
>     output = "SAME_AS_SOURCE"; // available options: SAME_AS_SOURCE, BYTE,
> SHORT, FLOAT
>     precision = "SINGLE"; //available options: SINGLE, DOUBLE
>     threshold = "-1"; //if -1, then disabled
>     maxIters = "10";
>     nOfThreads = "8";
>     showIter = "false";
>     gamma = "0";
>     filterXY = "1.0";
>     filterZ = "1.0";
>     normalize = "false";
>     logMean = "false";
>     antiRing = "true";
>     changeThreshPercent = "0.01";
>     db = "false";
>     detectDivergence = "true";
>
> call("edu.emory.mathcs.restoretools.iterative.ParallelIterat
> iveDeconvolutio
> n3D.deconvolveWPL", pathToBlurredImage, pathToPsf, pathToDeblurredImage,
> boundary, resizing, output, precision, threshold, maxIters, nOfThreads,
> showIter, gamma, filterXY, filterZ, normalize, logMean, antiRing,
> changeThreshPercent, db, detectDivergence);
> }
>
> //process each file in the input folder
>
> for (i=0; i<filename.length; i++) {
>     if(endsWith(filename[i], ".tif")) {
>         open(dir+filename[i]);
>         red = "C2-"+filename[i]+"_WPL_decon";
>         blue = "C3-"+filename[i]+"_WPL_decon";
>         green = "C1-"+filename[i]+"_WPL_decon";
>
> //pre-processing for PID: background subtract, add a small saturated spot
> to the first frame in each channel (to get around a quirk in PID's
> design), crop (if desired), split channels
>
>         name=getTitle;
>         run("Subtract Background...", "rolling=50 stack");
>          run("Canvas Size...", "width=256 height=256 position=Center
> zero");
>          Stack.setSlice(1)
>          Stack.setChannel(1)
>          makeRectangle(0, 0, 3, 3);
>          run("Add...", "value=65535 slice");
>          Stack.setChannel(2)
>          makeRectangle(0, 0, 3, 3);
>          run("Add...", "value=65535 slice");
>          Stack.setChannel(3)
>          makeRectangle(0, 0, 3, 3);
>          run("Add...", "value=65535 slice");
>          run("Split Channels");
>
> //deconvolve each channel
>
> selectWindow("C1-"+filename[i]);
>     image = getTitle;
>     deconImage = image+"_WPL_decon";
>     psf = pathGreen;
>     deconvolution();
>      while (isOpen(image+"_WPL_decon") == false) {
>         wait(1000);
>     }
>
>     //selectWindow("C1-"+name);
>     //close;
>
>     selectWindow("C2-"+filename[i]);
>     image = getTitle;
>     deconImage = image+"_WPL_decon";
>     psf = pathRed;
>     deconvolution();
>     while (isOpen(image+"_WPL_decon") == false) {
>         wait(1000);
>     }
>
>     //selectWindow("C2-"+name);
>     //close;
>
>     selectWindow("C3-"+filename[i]);
>     image = getTitle;
>     deconImage = image+"_WPL_decon";
>     psf = pathRed;
>     deconvolution();
>      while (isOpen(image+"_WPL_decon") == false) {
>         wait(1000);
>     }
>
>     //selectWindow("C3-"+name);
>     //close;
>
> //reassemble a TIFF from the deconvolved channels and save it
>
>     run("Merge Channels...", "red=["+red+"] green=["+green+"]
> blue=["+blue+"] gray=*None* create");
>     rename(filename[i]+"_deconvolved");
>     saveName=getTitle;
>     saveAs("Tiff", output+saveName);
>     close();
>
>        }
> }
>
>
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html