Fiji not recognizing built in macro functions

1k views Asked by At

I'm trying to make a macro using the javascript editor in Fiji (version 2.0.0-rc-30/1.49u) running on OSX 10.6.8, and I'm having trouble using the built in macro functions. The meat of my code works just fine, but I'd like it to cycle through all the files in a specific folder, so my macro starts off with:

inputdir = "/Users/myusername/picture folder/"    
list = getFileList(inputdir);

And then I have a for loop that runs through each of the files, or at least that's the idea. When I run it I get the following error:

"ReferenceError: "getFileList" is not defined. (<Unknown source>#3) in <Unknown source> at line number 3"

I get similar errors for most of the built-in macro functions (getDirectory, selectWindow, setThreshold).

I'll be the first to admit I'm a novice at javascript, so I'm sure it's something bone-headed, but I've reinstalled imageJ and Fiji, and updated them both to no avail. Any help would be much appreciated.

1

There are 1 answers

0
FrankyG On

First of all macros do have access to some of the Java functions.

He missed a semicolon in his code:

inputdir = "/Users/myusername/picture folder/"  // Forgot semicolon here. 
list = getFileList(inputdir);

So the code actually does work, just watch your syntax :). I suggest coding in Notepad++ or some compiler to make sure there aren't syntax errors.

There is something built into Fiji that makes this a lot easier called the multiple image processor.

The tutorial here will show you exactly how to access it and apply your macro to a directory.

Alternatively you can program it in yourself which they also detail like so:

input = "/home/fiji/input/";
output = "/home/fiji/images/";

list = getFileList(input);
for (i = 0; i < list.length; i++){
    action(input, output, list[i]);
}

Of course you really should make this as a plugin if you want it to have access to all features of Java.

Also ImageJ(FIJI) supports the following languages if you weren't aware:

  • BeanShell.
  • Groovy.
  • ImageJ Macro.
  • Java.
  • JavaScript.
  • Lisp (Clojure)
  • Python (Jython)
  • Ruby (JRuby)