Ephus: Multipurpose Data Acquisition Software for Neuroscience Experiments

Physiological measurements in neuroscience experiments often involve complex stimulus paradigms and multiple data channels. Ephus (http://www.ephus.org) is an open-source software package designed for general-purpose data acquisition and instrument control. Ephus operates as a collection of modular programs, including an ephys program for standard whole-cell recording with single or multiple electrodes in typical electrophysiological experiments, and a mapper program for synaptic circuit mapping experiments involving laser scanning photostimulation based on glutamate uncaging or channelrhodopsin-2 excitation. Custom user functions allow user-extensibility at multiple levels, including on-line analysis and closed-loop experiments, where experimental parameters can be changed based on recently acquired data, such as during in vivo behavioral experiments. Ephus is compatible with a variety of data acquisition and imaging hardware. This paper describes the main features and modules of Ephus and their use in representative experimental applications.

applications; complex combinations of multiple I/O devices and signals; uncaging and optogenetic based synaptic mapping applications; and, event-driven in vivo behavioral experiments.
Parts of this work have been published in preliminary format (O'Connor et al., 2008(O'Connor et al., , 2009).

Web site
The Ephus web address is http://www.ephus.org. The site includes links for downloading Ephus and related tools, and extensive information about installation, configuration, and usage. Feedback can be provided as well (scanimagers@gmail.com).

softWare developMent
Ephus was developed and tested on multiple computers (Dell, Lenovo, Superlogics) running Microsoft Windows XP.

Matlab and ancillary software
Ephus runs within Matlab (version 2007b and higher; Mathworks, Natick, MA, USA) as a series of scripts, classes, and custom toolboxes. No commercial Matlab toolboxes are required. Data acquisition is through NiMex, a custom toolbox which is included in Ephus.
GLib, an open-source, cross-platform utility library, is automatically installed.

Computer
The Ephus computer must accommodate the data acquisition boards (via PCI/PCIe slots or USB connectors, as appropriate) and, where needed, a video camera (usually an IEEE 1394 interface connection).

introduction
Software tools are crucial for neuroscience experiments involving complex combinations of event-driven stimulus and recording paradigms. Although commercial software solutions exist, these are often limited by a variety of factors including cost, source code inaccessibility, hardware compatibility, and more. Consequently a strong tradition in neurophysiology research is to write custom software routines. While superb for the specific tasks at hand, these custom solutions rarely offer the flexibility and extensibility needed for them to be transferrable across platforms, hardware configurations, and experimental paradigms without significant modifications.
We present here a suite of software tools engineered around general-purpose data I/O. This package, Ephus, is module-based and includes functionality for a wide variety of applications ranging from traditional in vitro electrophysiology to highly customized circuit mapping and in vivo behavioral protocols. Ephus has evolved alongside ScanImage, a package dedicated for 2-photon laser scanning microscopy . Ephus offers a collection of both application-specific tools, such as those for electrophysiology, scanning and mapping, video imaging, as well as common (shared) tools for data binding, configuration switching, and experimental timing. Ephus has been used for standard cellular electrophysiology, synaptic circuit mapping using laser scanning photostimulation (LSPS), and electrophysiology in vivo behavioral paradigms, and it offers a wide range of potential applications: whole-cell recording with non-standard customized routines including multi-electrode Although focused on electrophysiological experiments, Ephus is fundamentally a collection of modules (termed programs) for general data acquisition. For instance, it contains modules such as the stimulator, a program that controls DA or DIO output; the acquirer, a program that controls AD input; and ephys, a specialized program for cellular electrophysiology supporting intracellular recordings.
The number of output and input channels is limited only by the available hardware. The mapping between hardware and output and input channels is configured in an initialization file. Data sent to stimulating devices can be specified by the pulseEditor. The user may control individual programs directly; in addition, each program can be triggered by other programs, or itself trigger other programs when started. Alternatively any program can be configured to be triggered by the loopGui, which allows the number and timing of triggers, each corresponding to an individual acquisition, to be controlled. The pulseJacker program allows iterating through a pre-configured set of stimulus (pulse) data for each output channel (configured in the stimulator and/or ephys programs) for each trigger received or generated by Ephus.
The above roughly recapitulates the functionality of standard electrophysiology data acquisition programs. Beyond this, Ephus has several unique features.

Multiple levels of customization
Ephus allows easy configuration and display of individual experimental parameters via controls on the graphical user interface (window) for the various programs. However, Ephus also allows rapid (<1 s) "en bloc" switching between experiments as a whole, through the use of settings files and programmable shortcuts, termed "hotswitches". Each program stores its configuration (i.e., data acquisition parameters, window location) to a settings file on disk. A hotswitch captures the settings for a collection of appropriately configured programs and assigns a named shortcut. Once a desired experimental configuration has been saved as a hotswitch, one can rapidly return to this set-up by pressing the associated hotswitch button. For example, a user might have a hotswitch set-up for a series of current injections to examine threshold and firing response in a given neuron, but then use a second hotswitch to transition to a fixed voltage-clamp protocol for mapping synaptic inputs in LSPS. The hotswitch program ( Figure 1A) provides oneclick access to these shortcuts, and also provides the means for creating, modifying and deleting hotswitches.
Individual experimental set-ups can be joined into a logical group, which is saved as a "configuration set". Each user typically maintains a small number (e.g., 1-5) of active configuration sets, each with multiple (e.g., 10) hotswitches. The "File" menu provides commands to save or restore the settings of a particular program, or of all running programs ( Figure 1A).

User functions for on-line analysis and customization
Various modules expose events indicating particular points in program execution; these events can trigger the execution of custom user functions. Typically such functions implement custom data analysis following data acquisition. However, user functions can also change data acquisition parameters and therefore support on-line customization beyond what is available via the graphical user interface.

qcam.
A program for video control, qcam acquires data from CCD cameras. qcam is used for fluorescence microscopy, bright-field microscopy for whole-cell recordings, intrinsic signal imaging, etc. Using hotswitches it is easy to switch quickly between different exposures, look-up tables, frame rates, window sizes and other parameters. Currently qcam is designed for use with QImaging CCD cameras; in the future, this will likely be expanded to support additional devices and vendors.

mapper.
A program linking LSPS and electrophysiological measurements, the mapper is a highly optimized tool for circuit mapping or photochemical microscopy. The mapper is used to define the scan parameters and to align the scan with a video image of the sample. The mapper also orchestrates the stimulator, acquirer, and ephys, all of which must operate in a coordinated manner during a mapping experiment. The mapper relies on a few specialized calibration programs.

Data binding through the xsg
The xsg ("experiment saving GUI") controls the saving of data files. All data acquired are bound together in a logical manner and all acquisition parameters are saved in a header. Files are saved August 2010 | Volume 4 | Article 100 | 3

Suter et al.
Ephus software

Installing Ephus
The current version of Ephus along with instructions for downloading and installation is available at the Ephus web site. It is distributed as open-source software under the "HHMI/Janelia Farm Open-Source License".

Modifying the initialization file, and launching Ephus
When Ephus is launched, the user is prompted to supply an initialization file. This file establishes the correspondence between hardware channels and data, triggering, and other rig-specific settings -i.e., settings that do not change while running Ephus. A documented model initialization file is provided with the Ephus distribution, which the user can readily modify to suit their rig and experimental requirements.
To start Ephus, the command "ephus" is entered at the Matlab command line. During the first launch, certain programs require minor additional configuration (e.g., specifying which directory contains pulse files).
The flow of events in a generic Ephus experiment is depicted as a flowchart ( Figure 1D). as double-precision binary Matlab MAT-files, with the extension *.xsg. A single file on disk contains data and header information from all programs. Files are organized in folders and named in a systematic way that can be customized using the xsg controls. The xsg program is shown, during a slice electrophysiology experiment, in Figure 1B. The experiment number is incremented by the experimenter for each cell recorded, while the acquisition number increments automatically when new data is acquired, for example by the ephys program. A manually incremented "epoch" counter is available, allowing users to define different epochs of data acquisition (typically used in off-line analysis routines).
autonotes. During the course of an experiment, the autonotes program ( Figure 1C) provides a convenient way to type notes on experimental procedures, the condition of the specimen, or parameters of the apparatus not automatically recorded by Ephus programs. In addition to notes entered manually, a number of Ephus programs automatically add autonotes entries -for example, whenever a data file is acquired, a video image captured, or a hotswitch activated. Every entry is automatically time-stamped. The resulting log is saved as a plain text file alongside the data files saved by the xsg program.

Figure 1 | Ephus programs for management of general experimental information. (A)
The hotswitch window provides many customizable buttons to rapidly switch between experimental configurations (e.g., family of current steps, synaptic circuit mapping) and program settings (e.g., video exposure time). Also visible are menu items to save or restore settings for individual programs, as well as all programs. The Copy settings menu item aids in sharing settings among lab members. This menu is available in every Ephus program. (B) The xsg program, responsible for binding data and header information from all programs and saving to disk, provides user controls for specifying the file-naming parameters and for indicating the start of a new experiment, or experimental epoch. (C) The autonotes program functions as an electronic laboratory notebook, automatically time-stamping text entries useful for recording experimental procedures. Some programs automatically add entries to this log (e.g., when a video image is captured, a hotswitch is pressed, or custom user functions are executed). Notes can also be entered manually in the text window. (D) Flowchart describing generic sequence of events during experiments.
The Ephus layout for a typical electrophysiology recording session is shown in Figure 3.

Video-assisted electrophysiology
Many electrophysiology experiments involve a microscope and video imaging. Ephus includes the qcam program for both live display of a video image acquired using a digital video camera (see above), as well as saving single and multiple frames (i.e., movies) for off-line analysis. The qcam controls allow adjustments of exposure, temporal averaging, spatial binning, look-up tables, and region-of-interest zooming ( Figure 4A). For saved video frames, the file-naming scheme can be specified manually, or delegated to the xsg program. The qcam program is commonly used in preview mode when establishing giga-ohm seals for patch-clamp whole-cell recordings (Figures 4A,B).

Hardware calibration
The photodiode program is used to calibrate the light sensitivity of a photodiode that samples the beam power. The imagingSys program is used to calibrate the voltage signals controlling mirror galvanometers. Calibration of a Pockels cell is performed at startup, and recalibration can be done at any time from the mapper.
In VItro electrophysiology experiMents oscilloscope Ephus includes a built-in multi-channel software oscilloscope, the scopeGui (Figure 2). This is convenient for amplifier control and on-line data display. Typically it is used to establish and monitor electrophysiological recordings. The scopeGui applies periodic test pulses and displays basic whole-cell recording parameters. Data are displayed, but not saved.

Data acquisition with ephys
In the ephys program (Figure 3A), after selecting amplifier channels and assigning pulse patterns, a single trial is acquired by pushing the "Start" button. To repeat the same acquisition multiple times at a particular interval, ephys is placed in "External" trigger mode, the loopGui is set to the desired number of iterations and its "Start" button is then pushed to initiate and control the acquisition ( Figure 3B).
It is often desirable to execute a series of pulses differing in one or more parameters. For example, a common paradigm in electrophysiology experiments is to present a family of step stimuli of differing amplitudes. This functionality is provided by the pulseJacker (Figures 3C,D), which allows cycle-by-cycle individual hardware channel specification (which channels will be active, and which pulses they will use). This is a particularly powerful feature in Ephus.

event-based In VIVo experiMents
Multiple inputs can be recorded through AD and DIO channels with the acquirer program. The channels and the duration of recordings can be selected from the GUI ( Figure 7A). For example, during behavioral experiments, event triggered recording of several readouts of the animal behavior can be simultaneously acquired ( Figure 7B).

Pulses
Pulses are made using the pulseEditor program. In addition, a standard set of electrophysiology-related pulses is available at the Ephus web site. The pulseEditor provides functionality for crafting step pulses, with options for specifying all standard parameters (number of steps, delay, duration, amplitude, etc.) and for simple combinations of pulses. Figure 6 shows the pulseEditor controls ( Figure 6A) used to define a train of five pulses and to view the resulting waveform ( Figure 6B) -this example makes use of the "additive" option to combine a train of five small negative pulses with a single, larger positive pulse. However, it is also possible to generate more elaborate custom pulses -indeed, any arbitrary waveform -by using the signalObject class included with Ephus. Figure 6C provides an example of such a custom pulse: this "chirp" signal is a sinusoid whose frequency increases linearly with time; it is used to study frequencyspecific sub-threshold responses in whole-cell recordings.

mapper.
The mapper program provides a collection of tools associated with synaptic circuit mapping. It consists of a single graphical user interface ( Figure 5A) and a number of separate windows that facilitate alignment of the mapping grid to the sample (Figure 5B), visualization of the electrophysiologically recorded response to stimulation at a single site (Figure 5C), and to an entire pattern of stimulation sites ( Figure 5D). One option allows "point-andshoot" stimulation using the computer's pointing device to select a single site, or at several user-selected sites in succession (see the "Flashing" section in Figure 5A). Another option allows map acquisition using rectangular stimulus grids and sequence patterns (see the "Mapping" section in Figure 5A). An associated video display window allows users to overlay stimulus grids on images of the sample, and to adjust the size and orientation of the mapping grid with respect to tissue landmarks ( Figure 5B).
Once the stimulus grid has been translated and rotated into alignment with the sample, map acquisition is initiated and the mapper proceeds to stimulate the sample at every point specified in the map pattern, at the specified inter-stimulus interval. Figure 5E shows off-line visualization of a 4 × 6 excerpt of the raw current responses acquired during a 16 × 16 map using the stimulation grid shown in Figure 5B. Typically such current responses will be analyzed off-line to separate responses due to direct activation of the post-synaptic cell from those responses induced on the presynaptic population.

Saving settings and configurations
A particular collection and arrangement of Ephus modules can be saved as a named configuration. Multiple configurations can be saved. In addition, hotswitches provide a way to change program settings rapidly and conveniently.

Ephus menu bar
Every Ephus program has a menu bar providing at least two standard command items: One menu ("File") provides access to configuration loading and saving. A second menu ("Programs") provides access to all programs (Figure 1).

Start/External buttons
A subset of programs has these buttons. Pushing "Start" immediately triggers the acquisition. Pushing "External" puts the program in external-trigger mode. Programs in external mode can be triggered by pushing the "Start" button of another program; for example, in this way the loopGui can be used to launch ephys, stimulator, and acquirer together, ensuring a common start time.
Alternatively, a trigger pulse generated by software or hardware outside of Ephus can also be used in external mode.

Loop control
In addition to setting the number of iterations and starting loops, the loopGui also provides an option for seamless (DAC mode) or intermittent (CPU mode) looping. In DAC mode a continuous record of the iteration sequence is saved to a single data file, while in CPU mode separate files contain a record for each iteration. The DAC mode provides real-time reliability between loop iterations, at the expense of logging/sending data at all times. Meanwhile, the CPU mode allows for closed-loop control and sparser data-logging, at the expense of potential inter-iteration jitter (typically on the order of milliseconds to tens of milliseconds) and longer inter-iteration intervals.

Stimulus/acquisition duration
The overall duration of stimulus pulses is not set in the pulseEditor; instead, the "Trace Length" parameter in the programs that use these pulses (e.g., ephys, stimulator) individually sets the duration of the stimulus pulses. Similarly, this parameter sets the duration of data acquisition in the acquirer.
The "Update Rate" and "Display Width" parameters in the dataacquiring programs (ephys and acquirer) allow users to modify the way data are displayed (there is no effect on the way data are stored). This is particularly useful when acquiring traces that are many seconds or more in duration.

Custom configurations
The use of configurations and hotswitches was described above. These allow users to switch rapidly between complex experimental configurations while viewing only those particular program windows necessary to the task at hand.

Custom stimulus pulses
While the pulseEditor provides controls for defining trains of square pulses, arbitrary stimulus waveforms (see Figure 6C) can be defined using the lower-level signalObject Matlab object included with

Figure 4 | qcam: user interface for video control and display. (A)
Control panel for video acquisition parameters (exposure, temporal averaging, spatial binning), online display parameters (frame rate, look-up table, zoom), and storage parameters. (B) Live video display, obtained by running the qcam program in preview mode, of pyramidal neurons in a brain slice during a patch-clamp experiment (60× water-immersion objective, 58 μm below surface of 300-μm thick sagittal slice in mouse motor cortex).

Map patterns
Map pattern files specify the sequence of stimulation sites in a grid and are available on the Ephus web site. In addition, the mapper accepts custom map patterns.

Suter et al.
Ephus software

User functions
Ephus provides many hooks in the event flow and elsewhere that allow "user functions" to act on events and data. A number of user functions are built-in. Templates are provided to facilitate development of custom user functions.

Combining Ephus and multiphoton microscopy via ScanImage
There is growing interest in combining two-photon laser scanning microscopy and electrophysiological recording, an approach that has been used extensively for experiments such as high-resolution imaging of Ca 2+ dynamics in dendritic spines. Ephus and ScanImage can be used simultaneously for this purpose (O'Connor et al., 2008).

Ephus.
To use a custom stimulus the user first defines the waveform (e.g., as a linear combination of trigonometric functions, as an arbitrary analytic equation in time, a named probability distribution, or from arbitrary array data), saves the resulting signalObject as a pulse file, and selects it for delivery on an amplifier or other hardware DIO or DA channel as specified in stimulator or ephys.

Custom optical stimulation experiments
Optical stimulation protocols are not limited to the capabilities offered by the mapper. For example, custom routines can be used on-line to rapidly generate and deliver precise spatial and temporal stimuli to investigate spatio-temporal integration in synaptic circuits.

Figure 5 | Ephus configuration for synaptic circuit mapping experiment. (A)
The mapper program provides all controls necessary for scanning and flashing a laser beam across the sample in a specified grid pattern while simultaneously recording from one or more amplifier channels during each optical stimulus. Additional controls allow for calibrating a Pockels cell, calibrating transmitted laser power, selecting an appropriate grid pattern and adjusting its orientation, saving an image of the sample, marking the position of the recorded cell(s) in the field-of-view, and specifying the stimulation interval. Instead of a stimulation grid, the user can manually specify one or more positions at which to flash the sample. (B) An auxiliary window displaying the sample (in this case a sagittal slice of mouse motor cortex in 4× bright-field). The stimulation grid pattern is overlaid on the bright-field image and has been aligned (using the controls shown in A) to the pia and centered on the soma of the patched cell (blue circle). The red circle indicates the location of the last stimulus delivered. This display updates throughout the mapping procedure. (C) Voltage-clamp recording acquired during the last stimulus, showing a complex synaptic response, followed by a voltage step for monitoring recording parameters. (D) A standard user function performs a rapid analysis of the whole-cell recording (see C) and provides immediate feedback on the ongoing map in the form of a pseudo-color plot. This display updates throughout the mapping procedure. Note that this online display does not distinguish between direct (evident here in the strongest responses within 100-200 μm of the soma) from synaptic responses. functional programming. Since the mid-1990s, object-oriented programming has been standard in the design of most commercial software. Object-oriented design is not yet as common in the Matlab environment as in many other environments. Matlab has a number of object-orientation schemes that have grown over the years. Ephus is written using the earliest supported style of Matlab classes (which was all that was available at the start of the Ephus project), and implements its own pass-by-reference semantic scheme. Pass-by-reference is an important concept, which allows one instance of a particular object to be accessible from multiple, loosely coupled locations in the code, which in turn allows all such locations to see the same state for a given object. This becomes important when implementing eventbased programming, where it is unclear, prior to runtime, which code will be accessing specific objects at any given time.
Matlab is a single-threaded environment. This means that the simple act of entering into a loop would prevent Matlab from performing other tasks, including processing any other input. To get around this limitation, critical sections of the Ephus architecture rely on the propagation of events. Objects interested in a specific event (typically an input event or a state change) must register with the appropriate agent, and when the event occurs, all registered listeners are notified. An event may be generated For most applications, this is as simple as linking the trigger signals between the two software packages, which is often all that is needed to interface Ephus with external instrumentation. More advanced experiments may employ custom user functions to simplify operating both software suites quickly. Telegraphed data, in either direction, may be used to provide timestamps across programs for use in analysis. Depending on hardware availability, physical space, and other concerns, Ephus and ScanImage may be run on the same computer (using one or separate instances of Matlab) or on separate machines. for the developer: notes on EPHUS softWare architecture Ephus is heavily object-oriented (Booch et al., 1994) and eventbased (Yourdon and Constantine, 1979). The layered architecture and interconnections for a selected set of core software and hardware components are presented as a schematic diagram (Figure 8). Ephus is object-oriented in the sense that the programs themselves, and the subcomponents (i.e., data acquisition, event distribution, device interfaces, etc.), are all implemented as classes/objects. The classes encapsulate related data and functionality and designate a specific, associated lifecycle for each object instance. This results in cleaner and more modular code than would be achieved with traditional to proceed, it does not tie up the Matlab interpreter, as it would if it used a polling loop (i.e., "while <state_not_set>"). The act of waiting for an event does not require constant computation, and subsequently leaves the Matlab interpreter free to carry out other actions. The propagation of events and the flow of control in response to user action are presented in a software sequence diagram (Figure 9). In this example, a user initiates an LSPS map by mouse-click in the mapper, and a number of programs, classes, user functions, toolboxes and device drivers interact to complete the map pixel-by-pixel.
The programmable user functions available throughout Ephus are one of the most obvious examples of the event-based system design. In the case of user functions, the event and registration mechanism is exposed all the way up to the user level. However, this design principle is inherent to the software architecture, all the way to the hardware interfaces (including down into the underlying C code).
A number of industry-standard design patterns (Gamma et al., 1995) and best practices are employed throughout the implementation of Ephus. The code is rigorously documented on a per-function basis, with descriptions of all arguments, usage, and caveats. The system was designed from the very beginning with the capability for it to be modified, particularly by end-users, in mind. Various levels of programming proficiency are acceptable for customizing Ephus, because it has its own levels of complexity designed into it. At the highest level (simplest from a programmer's perspective), a user may write a new user function or modify an existing one. Moving to a lower level, users may write code to generate their own pulses and pulseJacker cycles. Lower still, users may write their own objects (i.e., write a new amplifier class for ephys to interface with new hardware). At an even lower level, users may create entirely new programs to add fundamentally new functionality to the system. Finally, users may modify the overall architecture and the C code (in NiMex). In practice, a large number of experiments may be automated simply by writing user functions and making pulseJacker cycles, it is rarely necessary to touch any of the lower-level code. Example functions are supplied with Ephus that demonstrate how by a hardware subsystem (i.e., via NiMex), user input, or other source. With an event-based design, when a section of code needs a change in the program state (i.e., waiting for an external trigger, waiting for a loop iteration event, waiting for user input) in order

Application references
Glu-LSPS: patterned stimulation with glutamate uncaging Shepherd et al. (2003 In vivo laser scanning microstimulation mapping Komiyama et al. (2010) to write user functions and how to create pulseJacker cycles in an automated fashion. These functions are heavily documented and are intended as tutorials and templates for users.

conclusion
Ephus is an open-source, flexible software package for generalpurpose data acquisition. Flexibility and extensibility make Ephus potentially useful for a wide variety of neuroscience experiments ranging from standard in vitro electrophysiology to synaptic circuit mapping to complex event-based in vivo paradigms.
Interested readers are referred to previous studies for further examples of different experimental paradigms enabled by Ephus software (Table 1). To date, a majority of the published studies have involved circuit mapping. We anticipate continued utility of Ephus both for "standard" LSPS mapping experiments, and for more customized mapping-type experiments involving user-specified spatio-temporal stimulation patterns.
In this report we have focused on the use of Ephus for data acquisition and have not described the various approaches that are possible for off-line analysis of Ephus-acquired data. The the overall concept and managed the project. Benjamin A. Suter, Leopoldo T. Petreanu, Bryan M. Hooks, and Taro Kiritani tested software and helped with debugging. Benjamin A. Suter and Gordon M. G. Shepherd drafted the manuscript with input from all authors.

acknoWledgMents
We thank our colleagues for field testing and feedback at many stages of development, including D. Huber, V. Jayaraman, T. Mao, D. O'Connor, P. Sheets, S. Sternson, T. Tzounopoulos, and X. Xu. Funded by the National Institutes of Health (EB001464) and Howard Hughes Medical Institute.
Ephus package does not include advanced analysis routines, as it is assumed that most users will require customized routines for analysis of their custom-acquired data sets. However, a simple GUI-based tool (traceBrowser) is provided, and serves as a starting point for users to develop their own analysis tools. Additionally, some basic tools with graphical user interfaces are provided on the Ephus web site for reviewing traces and analyzing mapping data.

author contributions
Timothy O'Connor led the software development and programming aspects of the project, and Vijay Iyer co-developed and programmed. Gordon M. G. Shepherd and Karel Svoboda designed