Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Hi all,
In a macro I have a "Z Project" command inside a FOR loop: for(){ run("Z Project...", ... } However the FOR loop exits prematurely after running its code only once even though the exit condition has not been met. If I comment out the one "run(..." line the loop runs the expected number of times. Is it normal behavior for loop code to run only once if it contains a "run(..." statement? (this happens with WHILE too) Thanks, Esteban |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Hi Esteban,
does your for loop have nSlices in the terminating condition? Then it may terminate because nSlices=1 for the image created by "Z Project...", which becomes the foreground image. For example, this runs only once: for (i=1; i<=nSlices; i++) { run("Z Project...", "start=1 stop=&i projection=[Average Intensity]"); // the output is foreground image, it has nSlices=1 rename("average_of_slices_1-"+i); } This does the full loop: originalID = getImageID(); for (i=1; i<=nSlices; i++) { run("Z Project...", "start=1 stop=&i projection=[Average Intensity]"); rename("average_of_slices_1-"+i); selectImage(originalID); } Michael ________________________________________________________________ On 10 Jan 2011, at 22:02, G. Esteban Fernandez wrote: > Hi all, > > In a macro I have a "Z Project" command inside a FOR loop: > > for(){ > run("Z Project...", ... > } > > However the FOR loop exits prematurely after running its code only > once even > though the exit condition has not been met. If I comment out the one > "run(..." line the loop runs the expected number of times. Is it > normal > behavior for loop code to run only once if it contains a "run(..." > statement? (this happens with WHILE too) > > Thanks, > Esteban ... [show rest of quote]
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Yes, it did have nSlices, thanks! Next time I'll put the full code in my
post... -Esteban On Tue, Jan 11, 2011 at 1:25 AM, Michael Schmid <[hidden email]>wrote: > Hi Esteban, > > does your for loop have nSlices in the terminating condition? Then it may > terminate because nSlices=1 for the image created by "Z Project...", which > becomes the foreground image. > > For example, this runs only once: > > for (i=1; i<=nSlices; i++) { > run("Z Project...", "start=1 stop=&i projection=[Average Intensity]"); > // the output is foreground image, it has nSlices=1 > rename("average_of_slices_1-"+i); > } > > This does the full loop: > > originalID = getImageID(); > for (i=1; i<=nSlices; i++) { > run("Z Project...", "start=1 stop=&i projection=[Average Intensity]"); > rename("average_of_slices_1-"+i); > selectImage(originalID); > } > > > Michael > ________________________________________________________________ > > > On 10 Jan 2011, at 22:02, G. Esteban Fernandez wrote: > > Hi all, >> >> In a macro I have a "Z Project" command inside a FOR loop: >> >> for(){ >> run("Z Project...", ... >> } >> >> However the FOR loop exits prematurely after running its code only once >> even >> though the exit condition has not been met. If I comment out the one >> "run(..." line the loop runs the expected number of times. Is it normal >> behavior for loop code to run only once if it contains a "run(..." >> statement? (this happens with WHILE too) >> >> Thanks, >> Esteban >> > ... [show rest of quote]
|
Free forum by Nabble | Disable Popup Ads | Edit this page |