Python engine for Icy, based on Jython
Institution: Institut Pasteur
The Jython for Icy plugin allows you to write scripts for Icy in the Python language. Scripts can be used to automate processing tasks (the Protocols are another kind of automation tools, where the script is defined graphically).
Python is a powerful dynamic programming language, that aims to be elegant, powerful and uncomplicated. Some of its key distinguishing features include:
- very clear, readable syntax
- strong introspection capabilities
- intuitive object orientation
- natural expression of procedural code
- very high level dynamic data types
- extensive standard libraries and third party modules for virtually every task
Inside Icy, Python is a great and easy-to-learn language to write down your image processing scripts.
Jython is an implementation of the Python programming language for Java. Icy itself is precisely written in Java, so Jython is a natural choice as a scripting engine for Icy.
Please note that there is one major difference between Jython and CPython (the standard implementation of Python in the C programming language): some libraries are designed to run specifically in CPython, and they cannot run directly in Jython. The well-known numerical libraries Numpy and Scipy belong to this category, and will not work directly inside Icy. We are working in an elegant way to use them by bridging CPython and Jython. Stay tuned !
The Python scripting engine will appear when you open the Script Editor. The first time you open the Script Editor after having installed Jython for Icy, the application may freeze for some time: Jython is going over all of the source code of Icy and its libraries to make them accessible in Python.
Choose Python in the drop-down list of the editor window.
You can write your Python script inside the editor’s text area and then run it by clicking on the “Play” icon.
In the above example, the script will duplicate the currently-active sequence.
You can also use the console at the bottom of the editor window to interact with Icy. Enter the command lines one-by-one in the text area at the very bottom of the window, and execute each line by hitting Enter.
In the above example, we asked for the width of the focused sequence (128 pixels), and we were about to ask for its height.