Re: Generating file names in macros
Posted by
Wayne Rasband on
URL: http://imagej.273.s1.nabble.com/no-subject-tp3703691p3703692.html
> Lately, I have begun using macro's in ImageJ to process my
> images. When I run my macro, I use the ICS-opener to open
> three channel .ics files. In a for-loop, I select the
> windows of different channels by creating a string of the
> filename + the iteration count and using the "selectWindow"
> function. All goes well, but once in a while, the macro
> stops at a random image, for example at image 25 ch 1,
> giving the error message: "image 25 ch 1.0 not found". So it
> seems to put a ".0" behind the number in the for-loop and
> tries to find an image-window with that name which doesn't
> exist.
You should be able to avoid this problem by using
selectWindow(filename+d2s(i,0));
instead of
selectWindow(filename+i);
The dts (double to string) function converts a number into a string
using a specified number of decimal places.
-wayne