Running Programs

Revised: 11/30/07

To run a program, ensure that one of its windows is active (click a window, or choose the program by name via Program->Loaded), then choose Program->Run (Command-R). If the Variables window is active, you can run a program by choosing it from the Show pop-up menu, then clicking Run.

Before starting the program, Expo does the following:

1. It allocates memory for up to four event queues (state events, raw spike waveform, spike times, and analog signals). Expo always allocates a queue for state events; it allocates other queues only when the program needs them. If a program's running time is known, Expo automatically establishes the sizes of event queues. If the running time is unknown, Expo sets queue sizes based on a maximum running time that you specify via Expo->Preferences.

2. It checks that all devices required by the program are present. If states contain routines that use special hardware (e.g., a digital I/O board) Expo checks that it is present and configured. If a required device is missing or misconfigured Expo will warn you.

3. It checks that any resources (e.g., images or movies) used by the program are available.

If the above are completed successfully, Expo will close any open editing window that belongs to the program, set the seed for the random number generator used in sequencing states, and start the run.

Expo checks that key operations are executed properly while the program is running, and will abort it per your preference. To specify what errors will halt a program choose Expo->Preferences, and click the Running Programs tab.

  • If routines cannot complete their actions within a single timebase tick, Expo will abort the program if you check Timebase Overrun.
  • If the program is recording spikes and the sound recording thread fails to keep up with the signal, Expo will abort the program if you check Spike Recording Overload.
  • If the program is recording analog signals and the sound recording thread fails to keep up with the signal, Expo will abort the program if you check Analog Recording Overload.
  • If the program would give rise to stimulus chromaticities that are out of the monitor's gamut, Expo will abort the program if you check Display Overmodulation.

While the program is running, its Status window displays information about its condition (elapsed time, state that is running and how many times it has been active). In the Program->Loaded submenu, the running program is identified by a red bullet. Whenever a program is running you can bring one of its windows to the foreground by hitting Command-/ (slash) or by choosing Window->Active Program.

If the Variables window is active, the running program is identified by a red bullet beside its name in the Show popup menu. If that program's variables are on display, any values changed by the program are continuously revised. You can also set the values of any variables that the program reads. (If Expo is not showing the variables for the active program, you click Active to display them.)

Only one program can be running at any one time. When the program is running Expo disables all commands that could change its environment, and all commands that could modify the program (you can, however, modify any other open program). If the program is collecting spikes, Expo also disables all commands that could modify spike templates. Expo does not disable commands that examine data, and you can analyze continuously the data being collected by the running program.

One started, a program will normally run until the last slot in its schedule is unable to transfer control anywhere. When the program stops Expo will, by default, warn you by sounding a beep, and will prompt you to save any data it has recorded. You can disable these warnings if you wish. To do that, choose Expo->Preferences…, and in the 'Running Programs' tab, check/uncheck Beep and Prompt to Save Data as appropriate.

Trapping Keyboard and Mouse Events

If a running program uses the Read Mouse, Read Wheel or Read Key routines, keyboard and mouse events are available to it only when they are specially trapped. By default these events are directed in the normal way to the active window on the screen. To enable trapping of mouse events and keystrokes (after a program has started running) choose Program->Trap Events (Command-K). You can configure Expo (via Expo->Preferences) to enable event trapping automatically whenever a program that needs events starts running, and to disengage the cursor from the mouse while trapping mouse movements.

Events can be trapped only if the running program makes calls to the relevant state routines (Read Key, Read Mouse or Read Wheel) or a slot in the program schedule accepts a keystroke. The cursor is never disengaged unless the running program calls Read Mouse.

When events are being trapped all mouse and wheel movements, and keystrokes, are passed to the active program. Expo indicates this by displaying a semi-transparent red circular window that is attached to the cursor. Events are trapped until another window becomes active or you hit ESC, or right-click and choose Stop Trapping from the contextual menu. Event trapping stops automatically when the running program is suspended or stops.

The position values registered by Read Mouse are clamped to the boundaries of the display over which the mouse moves. Read Mouse does not deliver values if you drag the red window, so you can exploit this if you want to reposition the cursor on the screen. While you are trapping events you can reset the mouse position to 0,0 (the center of the screen) by hitting F1 (with any modifier key, if appropriate).

When using Read Wheel you can reset the registered value to 0 by hitting F2 (with any modifier key, if appropriate).

You can also reset the mouse and wheel by right-clicking and choosing from the contextual menu.

Running Single States

In debugging programs it is often helpful to see what a particular state does, without having to wait for it to appear in its scheduled place. You can run any single state through the Program->Run State submenu. The submenu shows all simple states, and the unfolded substates of any matrix. When you run a single state, Expo allows it to remain active indefinitely, but collects no data. The run stops immediately when you choose Program->Suspend or hit Command-period (see below).

Programs can run in the foreground or the background. If multiple applications are open you can start a program running with Expo in the foreground, then switch to another application program. The time-critical events that occur while a state is active continue unhindered when Expo is in the background. If Expo is in the background when a running program finishes, OS X will bounce Expo's icon in the Dock.

Expo's time-critical operations should run smoothly regardless of what other applications are doing. Nevertheless, you can make Expo dispose of all processes that have a user interface (including the Finder) before it runs a program. To arrange this, choose Expo->Preferences, and check Dismiss Other Processes. Thereafter, whenever you issue the Run command, Expo will dismiss all other active processes.

When a program finishes running, Expo does not restart any application programs that it dismissed, but it will, if you wish, automatically restart the Finder. When you check Dismiss Other Processes in Preferences, you can check (or uncheck) Restart Finder.

Even if you have not checked the automatic Finder restart, you can recall the Finder (as long as no program is running) by choosing File->Launch Finder.

Examining Progress

While a program is running its status window shows (in green) the time for which it has been active and the currently active slot/state. You can view the whole log of program activity by choosing Data->Log, and you can analyze data gathered by the running program by choosing Data->Examine.

Suspending/Resuming/Stopping a Run

You can suspend a running program and later let it resume execution from the point at which it stopped. You can also abort a run at any time.

To suspend a running program choose Program->Suspend or hit Command-period. You need not have any of the program’s windows active to issue this command. Expo will suspend the program (and bring its status window to the front) when the state controlled by the active slot comes to an end. (If the slot permits the state to run indefinitely, you cannot suspend it, and will instead have to stop it completely by hitting Command-period a second time). While a program is suspended you cannot modify it, save data it has collected, or change its environment, but you can run any other open program. Expo allows you to run, then suspend, any number of open programs. In any menus that display lists of loaded programs (the Program->Loaded submenu, or the Show popup menu in the Variables window) a suspended program is identified by an orange bullet.

As long as no program is running, you can restart any suspended program by activating one of its windows then choosing Program->Resume (Command-R — Resume replaces Run for a suspended program). Execution continues from the point at which the program was suspended.

To stop any program that is suspended, choose Program->Stop, or hit Command-period. (Stop replaces Suspend for a suspended program). You can abort execution of any running program by hitting Command-period twice. Once you stop a run, you cannot resume execution; you must start a new run. Aborting a run does not lose any data collected.

The effect of Command-period is thus context-dependent: if any program is running when you execute the command, Expo will suspend the running program and activate its status window, regardless of which program is currently in the foreground. If no program is running and the front window belongs to a suspended program that program's run is aborted. If the Variables window is the front window and is displaying variables for a suspended program, the execution of that program is aborted; otherwise nothing happens.

Should Command-period ever fail to stop a running program, you can abort the run by sending Expo a kill message from the Terminal:

kill -s SIGINT <pid>

where <PID> is the process ID assigned to Expo. If you send SIGINT when no program is running Expo will quit without warning.

Saving Data

When a program stops running, either naturally, or through your having stopped it, you can save any data collected. (You cannot save data from a program that is merely suspended.)

To save data, first ensure that the active window belongs to the program that collected the data, then choose File->Save Data…. This item is dimmed if the program has no unsaved data.

If the program has recorded the raw spike waveform, the save panel will offer you the option of saving the full raw waveform, or a sample of it (the first 30 sec) or none of it. Which button is initially checked is determined by a Preferences setting (Expo->Preferences). Data files that contain raw spike waveforms can be very large, so it is probably not worth saving more than a sample unless the spike trace is grubby enough to need reanalysis. If you have saved the raw spike waveform in a file, and later want to remove it, you can do this with the AppleScript droplet EXPO-StripRawSpikes.

You can set up Expo to prompt you to save data whenever it completes a run. To enable this, choose Expo->Preferences…, and check Prompt to Save Data. When a program ends, Expo will display a dialog box that invites you to save or discard data. If you click Save, Expo will display a standard panel through which you can save the data. After the data are saved the raw spike waveform is discarded, but other data, including spike times, remain attached to the program, and available for analysis, until the program is run again. If you click Cancel, the unsaved data remain available in memory until you run the program again. If you try to run a program that is holding unsaved data, Expo will again prompt you to save or discard the data, and will not start the run until you have done one or the other.

What’s in a Data File

When Expo saves data it puts in the file:

Because the data file contains a complete executable copy of the program and all the information about its environment you can replay the experiment as was originally executed.

You can recover from the data file (as a new Untitled program) the program used to collect the data.

Naming Data Files

By default, Expo generates data file names automatically, from a template that you supply. The template has three parts, a root (e.g., XXX) and a numerical suffix (e.g., 1) that are put together as XXX#1. To this Expo appends, in square brackets, the name of the program that collected the data, thus: XXX#1[find_orientation]. As you save data (from any program) Expo automatically increases the value of the suffix, so, continuing the example, for a second data file that contained data from the program find_sf Expo would offer the name XXX#2[find_sf].

To set a new template for data file names, choose File->Data File Name…. Expo will display a panel through which you can set the root and suffix to be used in generating filenames subsequently.

When saving a data file, you can always override a suggested name by entering a filename explicitly in the save panel; you can disable the automatic generation of file names by choosing Expo->Preferences… and unchecking Generate Names for Data Files.

If Expo is generating data file names automatically, and you override a suggested file name when saving a file, Expo will ask if you want to form a new template from the name used. If you do not want this to become a template, Expo displays the template panel with the fields filled in (as best it can) from the file name you used. The candidate template is for the next data file that would be generated.

When you save data in a file whose name Expo has generated automatically, Expo adds that file's name to the File->Recent Data submenu. You can open any file on the list just by choosing its name. Expo clears the menu, and starts a new list of data files, whenever you override the suggested file name while saving data.

Adding Notes

You can save with data notes about the experiment (e.g., about the quality of the spikes, etc.). During an experimental run, or before saving data, you can enter the notes by choosing Data->Notes. You cannot add notes to data already saved in a file. When you choose Notes, Expo will open a window through which you can enter and edit text in the usual way. You can view these notes with the same command when you recall data from a file (see below).

Clearing Saved Data

After you have run a program (even if you have saved the data it collected) the data other than the raw spike waveform remain in memory until you close the program or run it again. If you have many open programs, each with saved data and consuming a lot of memory, Expo can become slow. If you need to free some memory you can explicitly discard data that have already been saved by choosing Data->Clear Saved Data.

Replaying Program Runs

If you have saved a raw spike waveform with data, you can replay the program in the file that contains the data, using the raw waveform as the source from which spike times will be derived. Expo regenerates spikes in synchrony with the stimuli that originally gave rise to them.

To replay a program while generating spike times, first choose Data->Replay Spikes to display spike waveforms, then set any spike templates your program will need. To start the experiment replaying choose Data->Replay Run (the command is dimmed if any program is running or suspended).

Replay Run is useful for demonstrating how spikes are elicited by the stimuli presented by a program, but since the exact times at which states are started in a running program can vary slightly from one run to the next (for example, the run might be replayed on a machine whose active monitor had a refresh rate different from the one originally used), Replay Run cannot be relied on for exact replication and should not be used to regenerate data for analysis. If you want to reanalyze spike times, choose Data->Reanalyze Spikes.