ZProjector for dummies

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

ZProjector for dummies

Jeff Hardin
Hi all,
I'm trying to learn how to use the ZProjector class to generate an ImagePlus and then replace the ImagePlus of a window with the result. However, I can't get the same result using calls to the ZProjector  directly that I get when I use the IJ.run("Z Project...") command. I am using a stack which is the MRI Stack (27 slices) converted to a HyperStack (z = 9 , t = 3).

Here are the two calls:

myProjector = new ZProjector();
myProjector.setMethod(ij.plugin.ZProjector.MAX_METHOD);
myProjector.setStartSlice(1);
myProjector.setStopSlice(4);
myProjector.setImage(imp);
myProjector.doHyperStackProjection(false);
ImageWindow tempWindow = new ImageWindow(myProjector.getProjection());
tempWindow.show();

This seems to project all 9 focal planes instead of 4. Other projection methods seem to give the same result (all 9 sections). This is also true when I use a plain old stack and myProjector.doProjection()

In contrast, the following works correctly on a stack or hyperstack:
IJ.run(imp, "Z Project...", "start=1 stop=4 projection=[Max Intensity]");

This projects only the requested 4 focal planes.

Is this a bug, or am I doing something fundamentally wrong? If the latter, help would be appreciated! ImageJ v = 1.49b, JVM 1.60_65 (32-bit), Mac OS X 10.9.

Cheers,
Jeff
----------------------------------------
Jeff Hardin
Professor and Chair, Department of Zoology
Director, Biology Core Curriculum
University of Wisconsin
1117 W. Johnson St.
Madison, WI 53706
voice: (608) 262-9634
fax: (608) 262-7319
email: [hidden email]
web page: http://worms.zoology.wisc.edu

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

Re: ZProjector for dummies

Tiago Ferreira-2
Dear Jeff,


On Jun 4, 2014, at 17:25, Jeff Hardin <[hidden email]> wrote:
> I can't get the same result using calls to the ZProjector  directly that I get when I use the IJ.run("Z Project...") command.

Try calling the setImage() method _before_ setting the limits of the projection, i.e.:

  myProjector = new ZProjector();
  myProjector.setImage(imp);
  myProjector.setMethod(ZProjector.MAX_METHOD);
  myProjector.setStartSlice(1);
  myProjector.setStopSlice(4);

or, alternatively:

  myProjector = new ZProjector(imp);
  myProjector.setMethod(ZProjector.MAX_METHOD);
  myProjector.setStartSlice(1);
  myProjector.setStopSlice(4);


In short:
Before calling setImage(), the ZProjector does not know on which image to operate.
Because of that, setStartSlice() and setStopSlice() will do nothing, and the projection
will be performed on the entire stack (the default). You can check this by looking at
the ZProjector source code, and confirm that setStartSlice() and setStopSlice() will do
nothing if the image to be projected has not yet been defined:

https://github.com/imagej/imagej1/blob/master/ij/plugin/ZProjector.java#L72
https://github.com/imagej/imagej1/blob/master/ij/plugin/ZProjector.java#L78


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

Re: ZProjector for dummies

Jeff Hardin
Dear Wayne and Tiago (Tiago's post below, identical to Wayne's),
Ouch. you're both right. Thanks for correcting a bonehead mistake.
Cheers,
Jeff

On Jun 4, 2014, at 10:05 PM, Tiago Ferreira <[hidden email]> wrote:

> Dear Jeff,
>
>
> On Jun 4, 2014, at 17:25, Jeff Hardin <[hidden email]> wrote:
>> I can't get the same result using calls to the ZProjector  directly that I get when I use the IJ.run("Z Project...") command.
>
> Try calling the setImage() method _before_ setting the limits of the projection, i.e.:
>
>  myProjector = new ZProjector();
>  myProjector.setImage(imp);
>  myProjector.setMethod(ZProjector.MAX_METHOD);
>  myProjector.setStartSlice(1);
>  myProjector.setStopSlice(4);
>
> or, alternatively:
>
>  myProjector = new ZProjector(imp);
>  myProjector.setMethod(ZProjector.MAX_METHOD);
>  myProjector.setStartSlice(1);
>  myProjector.setStopSlice(4);
>
>
> In short:
> Before calling setImage(), the ZProjector does not know on which image to operate.
> Because of that, setStartSlice() and setStopSlice() will do nothing, and the projection
> will be performed on the entire stack (the default). You can check this by looking at
> the ZProjector source code, and confirm that setStartSlice() and setStopSlice() will do
> nothing if the image to be projected has not yet been defined:
>
> https://github.com/imagej/imagej1/blob/master/ij/plugin/ZProjector.java#L72
> https://github.com/imagej/imagej1/blob/master/ij/plugin/ZProjector.java#L78
>
>
> -tiago

----------------------------------------
Jeff Hardin
Professor and Chair, Department of Zoology
Director, Biology Core Curriculum
University of Wisconsin
1117 W. Johnson St.
Madison, WI 53706
voice: (608) 262-9634
fax: (608) 262-7319
email: [hidden email]
web page: http://worms.zoology.wisc.edu

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