0

How do I use exec() in imageJ, http://fiji.sc/ImageJ_tricks#Execute_external_programs? Can I use the exec() function to launch an external python program with something like:

exec("python", d:\py\program1.py");

Is it possible to return an image array to exec from python?

kezzos
  • 3,023
  • 3
  • 20
  • 37

2 Answers2

1

The exec() macro function is hard coded to return STDOUT, as outlined in Curtis Rueden's answer to a similar question on the ImageJ mailing list.

However, you can run Python (or, for that matter, Jython) scripts directly from within Fiji via the script editor or by placing them into the Fiji.app/plugins/ folder.

Jan Eglinger
  • 3,995
  • 1
  • 25
  • 51
  • Thanks, I ask because I am interested in trying to find a way to use numpy and scipy from ImageJ and thought this could be an option. – kezzos May 02 '14 at 12:24
  • Hm, [this question](http://stackoverflow.com/questions/3097466/using-numpy-and-cpython-with-jython) and this [post on the ImageJ mailing list](http://imagej.1557.x6.nabble.com/Any-interest-in-reading-numpy-arrays-into-ImageJ-tp3690308p3690309.html) might be of interest for you then. – Jan Eglinger May 02 '14 at 14:01
  • Thanks, although I was hoping not to have to rewrite my program to get it to launch in imagej. – kezzos May 02 '14 at 14:16
0

For anyone interested in using additional python libraries with imageJ, exec() can get the job done. Use:

exec("python", "d:\\pathtoyour\\pythonprogram.py");

Save this using the imageJ script editor as .ijm file. This can then be installed as a plugin to launch your python program from imageJ.

kezzos
  • 3,023
  • 3
  • 20
  • 37