MTrack2 plugin bug fix

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

MTrack2 plugin bug fix

chris elliott
If a sequence of images contains one with no particles, MTrack2 returns
early and does not write a results file, path plot or other data. The
attached patch fixes it

chris


--- MTrack2_orig.java 2009-11-19 14:18:02.875000000 +0000
+++ MTrack2_.java 2009-11-19 12:28:47.390625000 +0000
@@ -1,3 +1,5 @@
+
+
 import ij.plugin.filter.PlugInFilter;
 import java.awt.Color;
 import java.util.*;
@@ -12,7 +14,7 @@
 import ij.measure.*;
 
 
-/**
+/** Modified Chris Elliott ([hidden email]) Nov 2009
  Uses ImageJ's particle analyzer to track the movement of
  multiple objects through a stack.
  Based on the Object Tracker plugin filter by Wayne Rasband
@@ -155,9 +157,8 @@
  pa.analyze(imp, stack.getProcessor(iFrame));
  float[] sxRes = rt.getColumn(ResultsTable.X_CENTROID);
  float[] syRes = rt.getColumn(ResultsTable.Y_CENTROID);
- if (sxRes==null)
- return;
-
+ if (sxRes!=null)
+ {            
  for (int iPart=0; iPart<sxRes.length; iPart++) {
  particle aParticle = new particle();
  aParticle.x=sxRes[iPart];
@@ -165,8 +166,10 @@
  aParticle.z=iFrame-1;
  theParticles[iFrame-1].add(aParticle);
  }
+
  IJ.showProgress((double)iFrame/nFrames);
  }
+ }
 
  // now assemble tracks out of the particle lists
  // Also record to which track a particle belongs in ArrayLists
Reply | Threaded
Open this post in threaded view
|

Re: MTrack2 plugin bug fix

dscho
Hi Chris,

On Wed, 25 Nov 2009, chris elliott wrote:

> If a sequence of images contains one with no particles, MTrack2 returns
> early and does not write a results file, path plot or other data. The
> attached patch fixes it

Would it not be better to just replace the "return;" in

                       if (sxRes==null)
                                return;

with a "continue;"?

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: MTrack2 plugin bug fix

chris elliott
Thanks for this, but the URL you gave is not giving a full path for the
server address.

I come from a C background, so don't really know all the java
possibilites, but just want to ensure we avoid executing the

for (int iPart=0; iPart<sxRes.length; iPart++) {

loop if sxRes is null, so that the code should resume with the next iFrame

chris

Johannes Schindelin wrote:

> Hi Chris,
>
> On Wed, 25 Nov 2009, Johannes Schindelin wrote:
>
>> On Wed, 25 Nov 2009, chris elliott wrote:
>>
>>> If a sequence of images contains one with no particles, MTrack2
>>> returns early and does not write a results file, path plot or other
>>> data. The attached patch fixes it
>> Would it not be better to just replace the "return;" in
>>
>>                        if (sxRes==null)
>>                                 return;
>>
>> with a "continue;"?
>
> Just in case you agree, here is what I would commit to fiji.git:
>
> http://pacific/cgi-bin/gitweb.cgi?p=fiji.git;a=commitdiff;h=refs/heads/mtrack2-fix
>
> Ciao,
> Dscho
>
Reply | Threaded
Open this post in threaded view
|

Re: MTrack2 plugin bug fix

dscho
Hi,

On Wed, 25 Nov 2009, chris elliott wrote:

> Thanks for this, but the URL you gave is not giving a full path for the
> server address.

Oops.

http://pacific.mpi-cbg.de/cgi-bin/gitweb.cgi?p=fiji.git;a=commitdiff;h=refs/heads/mtrack2-fix

> I come from a C background, so don't really know all the java possibilites,

"continue" is available in C as well.  It means "skip to the next
iteration of the loop".  With for loops, the increment statement is
executed.

> but just want to ensure we avoid executing the
>
> for (int iPart=0; iPart<sxRes.length; iPart++) {
>
> loop if sxRes is null, so that the code should resume with the next iFrame

This is what the "continue" statement does; instead of dropping out of the
function, it drops out of the current iteration of the enclosing loop.

I only suggested to use it so you do not need to break indentation by
adding curly brackets without increasing the indent level of the enclosed
code block.

Ciao,
Dscho

> Johannes Schindelin wrote:
> > Hi Chris,
> >
> > On Wed, 25 Nov 2009, Johannes Schindelin wrote:
> >
> > > On Wed, 25 Nov 2009, chris elliott wrote:
> > >
> > > > If a sequence of images contains one with no particles, MTrack2 returns
> > > > early and does not write a results file, path plot or other data. The
> > > > attached patch fixes it
> > > Would it not be better to just replace the "return;" in
> > >
> > >                        if (sxRes==null)
> > >                                 return;
> > >
> > > with a "continue;"?
> >
> > Just in case you agree, here is what I would commit to fiji.git:
> >
> > http://pacific/cgi-bin/gitweb.cgi?p=fiji.git;a=commitdiff;h=refs/heads/mtrack2-fix
> >
> > Ciao,
> > Dscho
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: MTrack2 plugin bug fix

chris elliott
Johannes Schindelin wrote:

> Hi,
>
> On Wed, 25 Nov 2009, chris elliott wrote:
>
>> Thanks for this, but the URL you gave is not giving a full path for the
>> server address.
>
> Oops.
>
> http://pacific.mpi-cbg.de/cgi-bin/gitweb.cgi?p=fiji.git;a=commitdiff;h=refs/heads/mtrack2-fix
>

that looks fine

chris
Reply | Threaded
Open this post in threaded view
|

Re: MTrack2 plugin bug fix

Nico Stuurman-4
In reply to this post by chris elliott
> If a sequence of images contains one with no particles, MTrack2  
> returns early and does not write a results file, path plot or other  
> data. The attached patch fixes it

This bug fix is now included in the MTrack2 code at: http://valelab.ucsf.edu/~nico/ijplugins/MTrack2.html

Best,

Nico
Reply | Threaded
Open this post in threaded view
|

Re: MTrack2 plugin bug fix

chris elliott
Thank you
chris

Nico Stuurman wrote:

>> If a sequence of images contains one with no particles, MTrack2
>> returns early and does not write a results file, path plot or other
>> data. The attached patch fixes it
>
> This bug fix is now included in the MTrack2 code at:
> http://valelab.ucsf.edu/~nico/ijplugins/MTrack2.html
>
> Best,
>
> Nico
Reply | Threaded
Open this post in threaded view
|

HistogramWindow to plugin...

Tony Collins-4
In reply to this post by Nico Stuurman-4
Hi,

I'd like a bit more control over the histogram plot in ImageJ (size, text displayed, etc.) for some FLIM images I want to publish. I though the quickest way to do this would be to adapt the core HistogramWindow() code and convert it to a plugin that I could customise.
http://rsbweb.nih.gov/ij/developer/source/ij/gui/HistogramWindow.java.html

I replaced:
        package ij.gui;
with
        import ij.gui.*;

and swapped the string:
        HistogramWindow

With
        My_HistogramWindow
And saved it as My_HistogramWindow.java

It compiles OK but I get an error *dialog* saying "Unable to load plugin (ins)".

Any suggestions as to whether there is a fix to this would be much appreciated.

Cheers,

Tony
 
Tony J. Collins, Ph.D.
McMaster Biophotonics Facility
HSC 4H21A, McMaster University, Hamilton, ON, L8N 3Z5
[hidden email]     www.macbiophotonics.ca
Reply | Threaded
Open this post in threaded view
|

Re: HistogramWindow to plugin...

Wayne Rasband
 > I'd like a bit more control over the histogram plot in ImageJ
 > (size, text displayed, etc.) for some FLIM images I want to
 > publish. I though the quickest way to do this would be to
 > adapt the core HistogramWindow() code and convert it to a
 > plugin that I could customise.
 > http://rsbweb.nih.gov/ij/developer/source/ij/gui/
 > HistogramWindow.java.html
 >
 > I replaced: package ij.gui; with import ij.gui.*;
 >
 > and swapped the string: HistogramWindow
 >
 > With My_HistogramWindow And saved it as
 > My_HistogramWindow.java
 >
 > It compiles OK but I get an error *dialog* saying "Unable
 > to load plugin (ins)".
 >
 > Any suggestions as to whether there is a fix to this would
 > be much appreciated.

You're getting the "Unable to load plugin (ins)" error because the
HistogramWindow class does not implement the PlugIn interface. What you
need to do is create a plugin that includes HistogramWindow as an inner
class. It would look something like this:

    public class Histogram_Window implements PlugIn {

       public void run(String arg) {
          new HistogramWindow(IJ.getImage());
       }

       class HistogramWindow extends ImageWindow {
       ....
       }

    }

There is a working example at

   
http://rsb.info.nih.gov/ij/plugins/download/misc/Histogram_Window.java

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: HistogramWindow to plugin...

Tony Collins-4
Perfect!
Thanks Wayne.
Tony

 
Tony J. Collins, Ph.D.
McMaster Biophotonics Facility
HSC 4H21A, McMaster University, Hamilton, ON, L8N 3Z5
[hidden email]     www.macbiophotonics.ca


> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Wayne
> Rasband
> Sent: November 25, 2009 1:14 PM
> To: [hidden email]
> Subject: Re: HistogramWindow to plugin...
>
>  > I'd like a bit more control over the histogram plot in ImageJ
>  > (size, text displayed, etc.) for some FLIM images I want to
>  > publish. I though the quickest way to do this would be to
>  > adapt the core HistogramWindow() code and convert it to a
>  > plugin that I could customise.
>  > http://rsbweb.nih.gov/ij/developer/source/ij/gui/
>  > HistogramWindow.java.html
>  >
>  > I replaced: package ij.gui; with import ij.gui.*;
>  >
>  > and swapped the string: HistogramWindow
>  >
>  > With My_HistogramWindow And saved it as
>  > My_HistogramWindow.java
>  >
>  > It compiles OK but I get an error *dialog* saying "Unable
>  > to load plugin (ins)".
>  >
>  > Any suggestions as to whether there is a fix to this would
>  > be much appreciated.
>
> You're getting the "Unable to load plugin (ins)" error because the
> HistogramWindow class does not implement the PlugIn interface. What you
> need to do is create a plugin that includes HistogramWindow as an inner
> class. It would look something like this:
>
>     public class Histogram_Window implements PlugIn {
>
>        public void run(String arg) {
>           new HistogramWindow(IJ.getImage());
>        }
>
>        class HistogramWindow extends ImageWindow {
>        ....
>        }
>
>     }
>
> There is a working example at
>
>
> http://rsb.info.nih.gov/ij/plugins/download/misc/Histogram_Window.java
>
> -wayne