Getting IJ1 Macro to talk to Beanshell script

Greetings all,
I’m a new ImageJ user and my programming skills are meh. As such I’m struggling with what is probably a very simple problem.

I’m trying to automate Weka Segmentation for large batches of images. Right now I have an ImageJ Macro doing the pre and post-processing, and a Beanshell script that does the Weka Segmentation itself. I have been trying to get the Macro to call and run the Beanshell script but I can’t figure out how to do it. I thought maybe I could use the Eval() function and insert the Beanshell script that way but I can’t get it to work. Is there a way I can save the Beanshell script and call that .bsh file from the macro? Could someone show me an example of how this should be done?

Please advise?


Dear @Kclayt88,

sorry, that your post has been unanswered for so long.

I guess the easiest way is to put the BeanShell script in a location ( where it is automatically picked up by the SciJava framework and added to the Plugins menu in ImageJ. Subsequently, you can run("Apply Weka Segmentation") from the macro.


1 Like