Edit page History How do I edit this website?

Example Beanshell scripts

Note: these example Beanshell scripts were written for the Micro-Manager 1.x API. These will not work in Micro-Manager 2.0 and greater. For a tutorial with examplea scripting 2.x, see: https://nicost.github.io/I2K-MM/ 2.0 compatible example scripts can be found here: https://github.com/micro-manager/micro-manager/tree/main/scripts.

These beanshell scripts can be run from the ‘Script Panel’ (in the ‘Tools’ menu). Either load the script in the Script Button Panel (using the ‘add’ button), or open the script in the editor (using the ‘open’ button.

Most of these scripts can be translated with minimal modification to the Python programming language (see Pycro-manager)

Sdemo1.bsh - Hello World

Sdemo2.bsh - Shows how to use ImageJ functionality within the Beanshell environment

SetZoom.bsh - Utility that sets the zoom level of the current ImageJ image window

Camera_test.bsh - Example camera test.


  • Shows how to snap (but not display) an image


  • Shows how to snap and display an image. The image window must already be open (Snap an image once manually before running the plugin).

SnapAndMeasure.bsh - Shows how to use the ImageJ ‘Measure’ command that updates with every new image snapped.

Live_demo.bsh - Shows how to process an image during acquisition. Needs the DemoStreamingCamera to work.

Burst.bsh - Shows how to start burst mode from a script. Also shows how to save to file during acquisition. Needs burst mode capable camera. May not work.

BurstExample.bsh - Shows how to run a sequence acquisition (used to be “burst mode”) from a script including setting up and starting the acquisition, grabbing the images from the circular buffer, and filing them into the acquisition object.

TestAcq.bsh - Demonstrates how to perform 5D image acquisition using the gui object.

ManualAcq.bsh - Executes 5D acquisition, prompting the user to change the filters/dichroics between channel changes

AcqLC.bsh - Example of a complicated MD acquisition including visiting multiple positions as defined in the position list, acquiring time-lapse data in individual channels.


  • Script used at the ASCB meeting 2008 to synchronize Arduino, camera, AOTF and piezo stage to do fast multi-channel Z-stack acquistion

PositionList.bsh - Shows how to build a positionList programmatically

Init.bsh - Shows how to configure the sytem programmatically, i.e. without using configuration files. The GUI changes will not be visible until you manually run the command ‘Rebuild GUI’ or ‘Refresh GUI’ (Tools menu).

Config_test.bsh - Shows how to define config groups programmatically. Will work with the demo-configuration.

Roi_copy.bsh - Demonstrates copying of ROI from one camera to another.


  • Beanshell for ratiometric Imaging (J. Husson).


  • Beanshell for ratiometric Imaging. Takes only one image, can be useful as a control before starting a whole acquisition with main beanshell above (J. Husson).


  • Control Andor Mosaic via iQ 2.7

The source code repository contains many more example scripts

Nico 21:04, 15 December 2007 (PST)