if (nSlices==1)

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

if (nSlices==1)

Wilson R S (AT)
I am using an if statement in the form of:



If (nSlices==1){

                Save}

Else{

                Other}

 

Meaning, if this is a single image (not a stack) save, else (it is
stack) do other. When it is presented with a stack it is fine, however
it seems incapable of realising that a single image is not a stack i.e.
nSlices==1.

Is this a fault or have I missed something in the coding?

I am using ImageJ 1.43p12.

 

Rhod
Reply | Threaded
Open this post in threaded view
|

Re: if (nSlices==1)

Julian Cooper
Hi Rhod,

The macro:

if (nSlices==1) {
        print("Single Slice");
}
else {
        print("Stack");
}

works appropriately for me so your code should be branching correctly.

I suspect there is a problem with the code in your "Save" block. Does
nothing at all appear to happen if it is a single image, or do you get an
error message, or even do you get the code for a stack executing when it is
a single image?

Best wishes,

Julian


> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On
> Behalf Of Wilson R S (AT)
> Sent: 11 February 2010 08:56
> To: [hidden email]
> Subject: if (nSlices==1)
>
>
> I am using an if statement in the form of:
>
>
>
> If (nSlices==1){
>
>                 Save}
>
> Else{
>
>                 Other}
>
>  
>
> Meaning, if this is a single image (not a stack) save, else (it is
> stack) do other. When it is presented with a stack it is fine, however
> it seems incapable of realising that a single image is not a
> stack i.e.
> nSlices==1.
>
> Is this a fault or have I missed something in the coding?
>
> I am using ImageJ 1.43p12.
>
>  
>
> Rhod
>
Reply | Threaded
Open this post in threaded view
|

Re: if (nSlices==1)

Wilson R S (AT)
Stack code executes when it is a single image.
I get an error code saying "Stack Required".

Rhod

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Julian Cooper
Sent: 11 February 2010 10:34
To: [hidden email]
Subject: Re: if (nSlices==1)

Hi Rhod,

The macro:

if (nSlices==1) {
        print("Single Slice");
}
else {
        print("Stack");
}

works appropriately for me so your code should be branching correctly.

I suspect there is a problem with the code in your "Save" block. Does
nothing at all appear to happen if it is a single image, or do you get
an
error message, or even do you get the code for a stack executing when it
is
a single image?

Best wishes,

Julian


> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On
> Behalf Of Wilson R S (AT)
> Sent: 11 February 2010 08:56
> To: [hidden email]
> Subject: if (nSlices==1)
>
>
> I am using an if statement in the form of:
>
>
>
> If (nSlices==1){
>
>                 Save}
>
> Else{
>
>                 Other}
>
>  
>
> Meaning, if this is a single image (not a stack) save, else (it is
> stack) do other. When it is presented with a stack it is fine, however
> it seems incapable of realising that a single image is not a
> stack i.e.
> nSlices==1.
>
> Is this a fault or have I missed something in the coding?
>
> I am using ImageJ 1.43p12.
>
>  
>
> Rhod
>