Scripting


To produce custom simulations or behaviors not possible using the Simbrain GUI, you can create custom scripts.

Basics

All scripts are currently beanshell scripts (there is nothing to prevent other scripting languages, but none have been implemented yet).   These are basically small java programs that interact with the Simbrain workspace.   Any java library can be used, as can the whole Simbrain API.  This allows for a great deal of flexibility.

Uses of Scripts

Some examples of things you can do using scripts are:

The best way to get a feel for scripting is to have a look at a few scripts.   Try opening a few in the scriptmenu directory, and running them.   Try modifying them in simple ways (e.g. modifying the paramters at the top) and re-running them. 

Also note that there are many basic things you'll need to do in a script that have most likely already been done in some script or another. So you can treat the script directory as a kind of repository of basic actions that you can combine together to get started with the behavior you want.

Scripting is closely related to custom updating in Simbrain. Custom update methods for the workspace or for components introduce custom update actions that are written using this same Beanshell scripting framework.  See workspace update and network update.

Ways to Invoke a Script

To get started, create a new text file with a text editor, save it as a .bsh file, and then run the script from Simbrain.  There are a few ways to do this:

Scriptmenu: .bsh files in the {SimbrainHome}/scripts/scriptmenu directory automatically appear in the  Scriptsmenu of the Simbrain workspace (if you just added the file, you must re-run simbrain).   You can also use the the  Scripts > Edit/Run Script...command to open, edit, then run a script. e.g. one in a location other than the scripts directory.

Network: .bsh files in {SimbrainHome}/scripts/network  automatically appear in the Scriptsmenu of Simbrain network components   Use this directory to create custom actions that can be applied to a current network (e.g., methods of adding neurons, modifying neurons or synapses, etc.)  The two objects available here are " network" and " networkPanel."  These give access to the current Network and its gui representation.

Console: .bsh files in {SimbrainHome}/scripts/console are available from the Simbrain console or terminal components. The console can be useful to quickly test or debug Simbrain. For a sense of some things you can do in the console enter "help(); or "tips();". The console is similar to a UNIX or DOS terminal window.  You can navigate around the file system using commands like "cd();  To run a script from the console, using the source command, e.g.  source("sparseNetwork.bsh");