setSlice and composite pb

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

setSlice and composite pb

JPCLAMME
Hi,

In a  macro I had a line that would access a given slice in hyperstack
presented as composite stack (4 channels and 8 z) using setSlice. I wanted
to do the same in a plug-in and it failed. As long as the channel
dimension is present, ij.SetSlice do nothing. (no errors , it just doesn't
move from slice 1) If I reduce the dimension to z only then it work.

Please advise

Thanks

JP
Reply | Threaded
Open this post in threaded view
|

Re: setSlice and composite pb

jmutterer
You should use the ImagePlus setPosition method for Hyperstacks.
Here is what the macro setSlice function does:

void setSlice() {
   int n = (int)getArg();
   ImagePlus imp = getImage();
   int nSlices = imp.getStackSize();
   if (n==1 && nSlices==1)
     return;
   else if (n<1 || n>nSlices)
     interp.error("Argument must be >=1 and <="+nSlices);
   else {
     if (imp.isHyperStack())
       imp.setPosition(n);
     else
       imp.setSlice(n);
     }
   resetImage();
}

Jerome.

On Thu, Apr 2, 2009 at 10:40 PM, Jean Pierre CLAMME <
[hidden email]> wrote:

>
> Hi,
>
> In a  macro I had a line that would access a given slice in hyperstack
> presented as composite stack (4 channels and 8 z) using setSlice. I wanted
> to do the same in a plug-in and it failed. As long as the channel
> dimension is present, ij.SetSlice do nothing. (no errors , it just doesn't
> move from slice 1) If I reduce the dimension to z only then it work.
>
> Please advise
>
> Thanks
>
> JP
Reply | Threaded
Open this post in threaded view
|

Re: setSlice and composite pb

JPCLAMME
Thank you,

Also is it normal that if I run a macro from a plugin ( with runMacroFile)
it is much much slower than if I run he macro directely with a short key ?

Thanks,

JP


ImageJ Interest Group <[hidden email]> wrote on 04/02/2009 02:03:15
PM:

> You should use the ImagePlus setPosition method for Hyperstacks.
> Here is what the macro setSlice function does:

> void setSlice() {
> int n = (int)getArg();
> ImagePlus imp = getImage();
> int nSlices = imp.getStackSize();
> if (n==1 && nSlices==1)
> return;
> else if (n<1 || n>nSlices)
> interp.error("Argument must be >=1 and <="+nSlices);
> else {
> if (imp.isHyperStack())
> imp.setPosition(n);
> else
> imp.setSlice(n);
> }
> resetImage();
> }

> Jerome.

> On Thu, Apr 2, 2009 at 10:40 PM, Jean Pierre CLAMME <
> [hidden email]> wrote:
> >
> > Hi,
> >
> > In a  macro I had a line that would access a given slice in hyperstack
> > presented as composite stack (4 channels and 8 z) using setSlice. I
wanted
> > to do the same in a plug-in and it failed. As long as the channel
> > dimension is present, ij.SetSlice do nothing. (no errors , it just
doesn't
> > move from slice 1) If I reduce the dimension to z only then it work.
> >
> > Please advise
> >
> > Thanks
> >
> > JP
Reply | Threaded
Open this post in threaded view
|

Re: setSlice and composite pb

Wayne Rasband
In reply to this post by JPCLAMME
> In a  macro I had a line that would access a given slice in hyperstack
> presented as composite stack (4 channels and 8 z) using setSlice. I  
> wanted
> to do the same in a plug-in and it failed. As long as the channel
> dimension is present, ij.SetSlice do nothing. (no errors , it just  
> doesn't
> move from slice 1) If I reduce the dimension to z only then it work.

Use

     imp.setPosition(imp.getChannel(), slice, imp.getFrame());

in a plugin or script to select a given slice in a hyperstack. In a  
macro, use

     Stack.setSlice(slice);

-wayne