wait for a result to appear

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

wait for a result to appear

TimFeinstein
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);
}

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: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: wait for a result to appear

Aryeh Weiss
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: http://imagej.nih.gov/ij/list.html


--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: wait for a result to appear

TimFeinstein
In reply to this post by TimFeinstein
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:
>>https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fimagej.ni
>>h.gov%2fij%2flist.html&data=01%7c01%7ctnf8%40pitt.edu%7cce9b31c0a3ad42887
>>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:
>https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fimagej.nih
>.gov%2fij%2flist.html&data=01%7c01%7ctnf8%40pitt.edu%7cce9b31c0a3ad4288710
>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.ParallelIterativeDeconvolutio
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
Reply | Threaded
Open this post in threaded view
|

Re: wait for a result to appear

ctrueden
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
Reply | Threaded
Open this post in threaded view
|

Re: wait for a result to appear

TimFeinstein
Thanks Curtis.  The first talk refers to Iterative 3D Deconvolution, which
was released and last updated in 2005.  Multiview deconvolution is for
light sheet data.  Heck I would be using it now if I could get multiview
reconstruction to work on my home-made instrument.  Apparently you need a
very carefully registered sample holder.

I understand that Ops and GPU deconvolution will be great, eventually.
Could anyone share their favorite deconvolution plugin that they use right
now?  

I have used commercial packages like Huygens with great success.  However
at the moment I would like to use ImageJ to deconvolve basic widefield
data for routine tasks.  PID is the best of the options I have tested but
it appears not super compatible with scripting.

All the best,


Tim

Timothy Feinstein, Ph.D.
Research Scientist
University of Pittsburgh Department of Developmental Biology





On 8/17/16, 11:01 AM, "ImageJ Interest Group on behalf of Curtis Rueden"
<[hidden email] on behalf of [hidden email]> wrote:

>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://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fvimeo.com
>%2f140098821&data=01%7c01%7ctnf8%40pitt.edu%7c735fd07cf8494373641d08d3c6b0
>f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=J4MQM6Df0cOfXJP5UEjdpyiw
>UsSsJbqX6QqXAqqJsDg%3d
> -- abstract -
>https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fimagej.net
>%2fConference_2015_Program%23Brian_Northan_-_&data=01%7c01%7ctnf8%40pitt.e
>du%7c735fd07cf8494373641d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7
>c1&sdata=sZJpBwn6yHYxk3TzzGkWcFCSBIu%2b1jOIWkM7E5eUmQA%3d
>Flexible_deconvolution_using_ImageJ_Ops
> -- slides -
>https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fimagej.gi
>thub.io%2fpresentations%2f2015-09-04-&data=01%7c01%7ctnf8%40pitt.edu%7c735
>fd07cf8494373641d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata
>=lDtyBOntnQcBWB%2bEdh5dH6GueMCEjc2AixX5oSygyzI%3d
>imagej2-deconvolution/
>
>* Benjamin Schmid - Real-time multi-view deconvolution of time-lapse data
>on the GPU
> -- video -
>https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fvimeo.com
>%2f140098826&data=01%7c01%7ctnf8%40pitt.edu%7c735fd07cf8494373641d08d3c6b0
>f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=W5yKLyy8h3JfHp4nPZberW7a
>7gWFAwWfmQdGaWxscuI%3d
> -- abstract -
>https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fimagej.net
>%2fConference_2015_Program%23&data=01%7c01%7ctnf8%40pitt.edu%7c735fd07cf84
>94373641d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=vHT%2f7
>4UKsKVqYwFR21Y2bIkEJB6A5xRzY4reQyaVUCo%3d
>Benjamin_Schmid_-_Real-time_multi-view_deconvolution_of_
>time-lapse_data_on_the_GPU
>
>See also:
>https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fimagej.net
>%2fDeconvolution&data=01%7c01%7ctnf8%40pitt.edu%7c735fd07cf8494373641d08d3
>c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=1qD5mPYlW4Dcu%2fXO2S
>qzXPOW6k7sW3ghnLcE%2bqSz6gw%3d
>
>And improvements to that wiki page are very welcome.
>
>Regards,
>Curtis
>
>--
>Curtis Rueden
>LOCI software architect -
>https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2floci.wisc.
>edu%2fsoftware&data=01%7c01%7ctnf8%40pitt.edu%7c735fd07cf8494373641d08d3c6
>b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=Dg44RANnXrWmSyj%2bH5hZ
>ahzOvervqLECK6%2fzlNQVPGE%3d
>ImageJ2 lead, Fiji maintainer -
>https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fimagej.net
>%2fUser%3aRueden&data=01%7c01%7ctnf8%40pitt.edu%7c735fd07cf8494373641d08d3
>c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=w6O2NK61LNyiQffGf9Q9
>P8wn%2f8DTGSEx4EvGjPWZrMg%3d
>Did you know ImageJ has a forum?
>https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fforum.imag
>ej.net%2f&data=01%7c01%7ctnf8%40pitt.edu%7c735fd07cf8494373641d08d3c6b0f63
>b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=ETP6QBbg%2fsFtHR7fc2ZCxJbr5
>uKj1LX0pL25izztuSI%3d
>
>
>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:
>>https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fimagej.ni
>>h.gov%2fij%2flist.html&data=01%7c01%7ctnf8%40pitt.edu%7c735fd07cf84943736
>>41d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=1oUyPax9xlcV
>>h%2fGJABMkuuskiozXfw3AqW0ZJ1BnzkI%3d
>>
>
>--
>ImageJ mailing list:
>https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fimagej.nih
>.gov%2fij%2flist.html&data=01%7c01%7ctnf8%40pitt.edu%7c735fd07cf8494373641
>d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=1oUyPax9xlcVh%2
>fGJABMkuuskiozXfw3AqW0ZJ1BnzkI%3d

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: wait for a result to appear

bnorthan
Hi Timothy

I helped write the deconvolution ops, so I wish they were further along,
however right now they do not have a GUI placed around them, or are they
easily usable with multi-channel images.

Have you tried deconvolution lab??  It is OK for single channel images.
Unfortunately deconvolution lab has issues with multi channel images.  It
is not easy to deconvolve multichannel images without splitting channels
before hand.

Also it is not easy to script with Deconvolution Lab.

In the near future I hope to be able to do more testing on the ops
deconvolution, and write a wrapper for multichannel images.  I will keep
you updated.

Brian


On Wed, Aug 17, 2016 at 3:29 PM, Feinstein, Timothy N <[hidden email]> wrote:

> Thanks Curtis.  The first talk refers to Iterative 3D Deconvolution, which
> was released and last updated in 2005.  Multiview deconvolution is for
> light sheet data.  Heck I would be using it now if I could get multiview
> reconstruction to work on my home-made instrument.  Apparently you need a
> very carefully registered sample holder.
>
> I understand that Ops and GPU deconvolution will be great, eventually.
> Could anyone share their favorite deconvolution plugin that they use right
> now?
>
> I have used commercial packages like Huygens with great success.  However
> at the moment I would like to use ImageJ to deconvolve basic widefield
> data for routine tasks.  PID is the best of the options I have tested but
> it appears not super compatible with scripting.
>
> All the best,
>
>
> Tim
>
> Timothy Feinstein, Ph.D.
> Research Scientist
> University of Pittsburgh Department of Developmental Biology
>
>
>
>
>
> On 8/17/16, 11:01 AM, "ImageJ Interest Group on behalf of Curtis Rueden"
> <[hidden email] on behalf of [hidden email]> wrote:
>
> >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://na01.safelinks.protection.outlook.com/?url=
> https%3a%2f%2fvimeo.com
> >%2f140098821&data=01%7c01%7ctnf8%40pitt.edu%
> 7c735fd07cf8494373641d08d3c6b0
> >f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=
> J4MQM6Df0cOfXJP5UEjdpyiw
> >UsSsJbqX6QqXAqqJsDg%3d
> > -- abstract -
> >https://na01.safelinks.protection.outlook.com/?url=
> http%3a%2f%2fimagej.net
> >%2fConference_2015_Program%23Brian_Northan_-_&data=01%
> 7c01%7ctnf8%40pitt.e
> >du%7c735fd07cf8494373641d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112
> fd0d%7
> >c1&sdata=sZJpBwn6yHYxk3TzzGkWcFCSBIu%2b1jOIWkM7E5eUmQA%3d
> >Flexible_deconvolution_using_ImageJ_Ops
> > -- slides -
> >https://na01.safelinks.protection.outlook.com/?url=
> https%3a%2f%2fimagej.gi
> >thub.io%2fpresentations%2f2015-09-04-&data=01%7c01%7ctnf8%40pitt.edu
> %7c735
> >fd07cf8494373641d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112
> fd0d%7c1&sdata
> >=lDtyBOntnQcBWB%2bEdh5dH6GueMCEjc2AixX5oSygyzI%3d
> >imagej2-deconvolution/
> >
> >* Benjamin Schmid - Real-time multi-view deconvolution of time-lapse data
> >on the GPU
> > -- video -
> >https://na01.safelinks.protection.outlook.com/?url=
> https%3a%2f%2fvimeo.com
> >%2f140098826&data=01%7c01%7ctnf8%40pitt.edu%
> 7c735fd07cf8494373641d08d3c6b0
> >f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=
> W5yKLyy8h3JfHp4nPZberW7a
> >7gWFAwWfmQdGaWxscuI%3d
> > -- abstract -
> >https://na01.safelinks.protection.outlook.com/?url=
> http%3a%2f%2fimagej.net
> >%2fConference_2015_Program%23&data=01%7c01%7ctnf8%40pitt.edu
> %7c735fd07cf84
> >94373641d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112
> fd0d%7c1&sdata=vHT%2f7
> >4UKsKVqYwFR21Y2bIkEJB6A5xRzY4reQyaVUCo%3d
> >Benjamin_Schmid_-_Real-time_multi-view_deconvolution_of_
> >time-lapse_data_on_the_GPU
> >
> >See also:
> >https://na01.safelinks.protection.outlook.com/?url=
> http%3a%2f%2fimagej.net
> >%2fDeconvolution&data=01%7c01%7ctnf8%40pitt.edu%
> 7c735fd07cf8494373641d08d3
> >c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=1qD5mPYlW4Dcu%
> 2fXO2S
> >qzXPOW6k7sW3ghnLcE%2bqSz6gw%3d
> >
> >And improvements to that wiki page are very welcome.
> >
> >Regards,
> >Curtis
> >
> >--
> >Curtis Rueden
> >LOCI software architect -
> >https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2floci.wisc
> .
> >edu%2fsoftware&data=01%7c01%7ctnf8%40pitt.edu%
> 7c735fd07cf8494373641d08d3c6
> >b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=
> Dg44RANnXrWmSyj%2bH5hZ
> >ahzOvervqLECK6%2fzlNQVPGE%3d
> >ImageJ2 lead, Fiji maintainer -
> >https://na01.safelinks.protection.outlook.com/?url=
> http%3a%2f%2fimagej.net
> >%2fUser%3aRueden&data=01%7c01%7ctnf8%40pitt.edu%
> 7c735fd07cf8494373641d08d3
> >c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=
> w6O2NK61LNyiQffGf9Q9
> >P8wn%2f8DTGSEx4EvGjPWZrMg%3d
> >Did you know ImageJ has a forum?
> >https://na01.safelinks.protection.outlook.com/?url=
> http%3a%2f%2fforum.imag
> >ej.net%2f&data=01%7c01%7ctnf8%40pitt.edu%7c735fd07cf8494373641d08d3c6b0
> f63
> >b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=ETP6QBbg%
> 2fsFtHR7fc2ZCxJbr5
> >uKj1LX0pL25izztuSI%3d
> >
> >
> >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:
> >>https://na01.safelinks.protection.outlook.com/?url=
> http%3a%2f%2fimagej.ni
> >>h.gov%2fij%2flist.html&data=01%7c01%7ctnf8%40pitt.edu%
> 7c735fd07cf84943736
> >>41d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112
> fd0d%7c1&sdata=1oUyPax9xlcV
> >>h%2fGJABMkuuskiozXfw3AqW0ZJ1BnzkI%3d
> >>
> >
> >--
> >ImageJ mailing list:
> >https://na01.safelinks.protection.outlook.com/?url=
> http%3a%2f%2fimagej.nih
> >.gov%2fij%2flist.html&data=01%7c01%7ctnf8%40pitt.edu%
> 7c735fd07cf8494373641
> >d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112
> fd0d%7c1&sdata=1oUyPax9xlcVh%2
> >fGJABMkuuskiozXfw3AqW0ZJ1BnzkI%3d
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: wait for a result to appear

ctrueden
Hi Brian,

Thanks for chiming in.

> Also it is not easy to script with Deconvolution Lab.

Another major problem with Deconvolution Lab is that it is not open source.

> In the near future I hope to be able to do more testing on the ops
> deconvolution, and write a wrapper for multichannel images.  I will
> keep you updated.

LOCI may have resources in the near future to help. Let's discuss in more
detail this fall! It will be really awesome to get this work polished up!

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 2:47 PM, Brian Northan <[hidden email]> wrote:

> Hi Timothy
>
> I helped write the deconvolution ops, so I wish they were further along,
> however right now they do not have a GUI placed around them, or are they
> easily usable with multi-channel images.
>
> Have you tried deconvolution lab??  It is OK for single channel images.
> Unfortunately deconvolution lab has issues with multi channel images.  It
> is not easy to deconvolve multichannel images without splitting channels
> before hand.
>
> Also it is not easy to script with Deconvolution Lab.
>
> In the near future I hope to be able to do more testing on the ops
> deconvolution, and write a wrapper for multichannel images.  I will keep
> you updated.
>
> Brian
>
>
> On Wed, Aug 17, 2016 at 3:29 PM, Feinstein, Timothy N <[hidden email]>
> wrote:
>
> > Thanks Curtis.  The first talk refers to Iterative 3D Deconvolution,
> which
> > was released and last updated in 2005.  Multiview deconvolution is for
> > light sheet data.  Heck I would be using it now if I could get multiview
> > reconstruction to work on my home-made instrument.  Apparently you need a
> > very carefully registered sample holder.
> >
> > I understand that Ops and GPU deconvolution will be great, eventually.
> > Could anyone share their favorite deconvolution plugin that they use
> right
> > now?
> >
> > I have used commercial packages like Huygens with great success.  However
> > at the moment I would like to use ImageJ to deconvolve basic widefield
> > data for routine tasks.  PID is the best of the options I have tested but
> > it appears not super compatible with scripting.
> >
> > All the best,
> >
> >
> > Tim
> >
> > Timothy Feinstein, Ph.D.
> > Research Scientist
> > University of Pittsburgh Department of Developmental Biology
> >
> >
> >
> >
> >
> > On 8/17/16, 11:01 AM, "ImageJ Interest Group on behalf of Curtis Rueden"
> > <[hidden email] on behalf of [hidden email]> wrote:
> >
> > >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://na01.safelinks.protection.outlook.com/?url=
> > https%3a%2f%2fvimeo.com
> > >%2f140098821&data=01%7c01%7ctnf8%40pitt.edu%
> > 7c735fd07cf8494373641d08d3c6b0
> > >f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=
> > J4MQM6Df0cOfXJP5UEjdpyiw
> > >UsSsJbqX6QqXAqqJsDg%3d
> > > -- abstract -
> > >https://na01.safelinks.protection.outlook.com/?url=
> > http%3a%2f%2fimagej.net
> > >%2fConference_2015_Program%23Brian_Northan_-_&data=01%
> > 7c01%7ctnf8%40pitt.e
> > >du%7c735fd07cf8494373641d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112
> > fd0d%7
> > >c1&sdata=sZJpBwn6yHYxk3TzzGkWcFCSBIu%2b1jOIWkM7E5eUmQA%3d
> > >Flexible_deconvolution_using_ImageJ_Ops
> > > -- slides -
> > >https://na01.safelinks.protection.outlook.com/?url=
> > https%3a%2f%2fimagej.gi
> > >thub.io%2fpresentations%2f2015-09-04-&data=01%7c01%7ctnf8%40pitt.edu
> > %7c735
> > >fd07cf8494373641d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112
> > fd0d%7c1&sdata
> > >=lDtyBOntnQcBWB%2bEdh5dH6GueMCEjc2AixX5oSygyzI%3d
> > >imagej2-deconvolution/
> > >
> > >* Benjamin Schmid - Real-time multi-view deconvolution of time-lapse
> data
> > >on the GPU
> > > -- video -
> > >https://na01.safelinks.protection.outlook.com/?url=
> > https%3a%2f%2fvimeo.com
> > >%2f140098826&data=01%7c01%7ctnf8%40pitt.edu%
> > 7c735fd07cf8494373641d08d3c6b0
> > >f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=
> > W5yKLyy8h3JfHp4nPZberW7a
> > >7gWFAwWfmQdGaWxscuI%3d
> > > -- abstract -
> > >https://na01.safelinks.protection.outlook.com/?url=
> > http%3a%2f%2fimagej.net
> > >%2fConference_2015_Program%23&data=01%7c01%7ctnf8%40pitt.edu
> > %7c735fd07cf84
> > >94373641d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112
> > fd0d%7c1&sdata=vHT%2f7
> > >4UKsKVqYwFR21Y2bIkEJB6A5xRzY4reQyaVUCo%3d
> > >Benjamin_Schmid_-_Real-time_multi-view_deconvolution_of_
> > >time-lapse_data_on_the_GPU
> > >
> > >See also:
> > >https://na01.safelinks.protection.outlook.com/?url=
> > http%3a%2f%2fimagej.net
> > >%2fDeconvolution&data=01%7c01%7ctnf8%40pitt.edu%
> > 7c735fd07cf8494373641d08d3
> > >c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=1qD5mPYlW4Dcu%
> > 2fXO2S
> > >qzXPOW6k7sW3ghnLcE%2bqSz6gw%3d
> > >
> > >And improvements to that wiki page are very welcome.
> > >
> > >Regards,
> > >Curtis
> > >
> > >--
> > >Curtis Rueden
> > >LOCI software architect -
> > >https://na01.safelinks.protection.outlook.com/?url=
> http%3a%2f%2floci.wisc
> > .
> > >edu%2fsoftware&data=01%7c01%7ctnf8%40pitt.edu%
> > 7c735fd07cf8494373641d08d3c6
> > >b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=
> > Dg44RANnXrWmSyj%2bH5hZ
> > >ahzOvervqLECK6%2fzlNQVPGE%3d
> > >ImageJ2 lead, Fiji maintainer -
> > >https://na01.safelinks.protection.outlook.com/?url=
> > http%3a%2f%2fimagej.net
> > >%2fUser%3aRueden&data=01%7c01%7ctnf8%40pitt.edu%
> > 7c735fd07cf8494373641d08d3
> > >c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=
> > w6O2NK61LNyiQffGf9Q9
> > >P8wn%2f8DTGSEx4EvGjPWZrMg%3d
> > >Did you know ImageJ has a forum?
> > >https://na01.safelinks.protection.outlook.com/?url=
> > http%3a%2f%2fforum.imag
> > >ej.net%2f&data=01%7c01%7ctnf8%40pitt.edu%7c735fd07cf8494373641d08d3c6b0
> > f63
> > >b%7c9ef9f489e0a04eeb87cc3a526112fd0d%7c1&sdata=ETP6QBbg%
> > 2fsFtHR7fc2ZCxJbr5
> > >uKj1LX0pL25izztuSI%3d
> > >
> > >
> > >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:
> > >>https://na01.safelinks.protection.outlook.com/?url=
> > http%3a%2f%2fimagej.ni
> > >>h.gov%2fij%2flist.html&data=01%7c01%7ctnf8%40pitt.edu%
> > 7c735fd07cf84943736
> > >>41d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112
> > fd0d%7c1&sdata=1oUyPax9xlcV
> > >>h%2fGJABMkuuskiozXfw3AqW0ZJ1BnzkI%3d
> > >>
> > >
> > >--
> > >ImageJ mailing list:
> > >https://na01.safelinks.protection.outlook.com/?url=
> > http%3a%2f%2fimagej.nih
> > >.gov%2fij%2flist.html&data=01%7c01%7ctnf8%40pitt.edu%
> > 7c735fd07cf8494373641
> > >d08d3c6b0f63b%7c9ef9f489e0a04eeb87cc3a526112
> > fd0d%7c1&sdata=1oUyPax9xlcVh%2
> > >fGJABMkuuskiozXfw3AqW0ZJ1BnzkI%3d
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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