logging and results in macro

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

logging and results in macro

Jared Windover
Hi,

I'm new to ImageJ (and mailing lists). I've run into a bit of a bug I
think. I'm trying to do maxima finding on a bunch of images and have
written a macro to do so on a selected directory. I've also got some print
statements, mostly just sanity checks to make sure that it's running
properly. If I have them included, then sometimes when I try to write the
Results to a file, it actually writes the log window. Sometimes it works
properly though. If I get rid of them, then it seems to work fine.

Here's the macro (the commented print is the troublemaker):

prefix = "Points_";
wext = ".csv";
rext = ".pgm";

dir = getDirectory("Choose Source Directory ");
list = getFileList(dir)
setBatchMode(true)
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
name = list[i];
pos = indexOf(name,'.');
ext = substring(name,pos);
if (ext ==rext) {
open(dir + list[i]);
nameWE = substring(name,0,pos);
newName = prefix + nameWE + wext;
run("Find Maxima...", "noise=70 output=List");
saveAs("Results", dir+newName);
//print("Processed:" +name);
}
}
print("Finished");

Any thoughts?

-Jared

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

Re: logging and results in macro

Rasband, Wayne (NIH/NIMH) [E]
On Dec 15, 2014, at 1:33 PM, Jared Windover <[hidden email]> wrote:

>
> Hi,
>
> I'm new to ImageJ (and mailing lists). I've run into a bit of a bug I
> think. I'm trying to do maxima finding on a bunch of images and have
> written a macro to do so on a selected directory. I've also got some print
> statements, mostly just sanity checks to make sure that it's running
> properly. If I have them included, then sometimes when I try to write the
> Results to a file, it actually writes the log window. Sometimes it works
> properly though. If I get rid of them, then it seems to work fine.

The latest ImageJ daily build (1.49n14) fixes a bug that caused the saveAs("Results”,path) macro function to save the Log window instead of the Results if the Log window was in front.

-wayne


> Here's the macro (the commented print is the troublemaker):
>
> prefix = "Points_";
> wext = ".csv";
> rext = ".pgm";
>
> dir = getDirectory("Choose Source Directory ");
> list = getFileList(dir)
> setBatchMode(true)
> for (i=0; i<list.length; i++) {
> showProgress(i+1, list.length);
> name = list[i];
> pos = indexOf(name,'.');
> ext = substring(name,pos);
> if (ext ==rext) {
> open(dir + list[i]);
> nameWE = substring(name,0,pos);
> newName = prefix + nameWE + wext;
> run("Find Maxima...", "noise=70 output=List");
> saveAs("Results", dir+newName);
> //print("Processed:" +name);
> }
> }
> print("Finished");
>
> Any thoughts?
>
> -Jared

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