Data Acqusition Software for Neurobiology using Matlab


As part of an effort to make inexpensive and flexible biology lab instrumentation, we have written a Matlab program which:

We used Matlab because it is a flexible programming language which includes the abilities to:

This page is divided into two parts; program use and program internal structure. Obviously, you don't need to understand the program internals to use it, as long as nothing goes wrong.

Using the Program

If you want to use the program you must have a licensed copy of Matlab release 14. Later in the fall we expect to have a version which will run standalone without Matlab. You then need to download the program we wrote (see links below). Be sure that your Matlab 'path' includes the folder where you stored the program. If you are not sure use the SetPath... option in the File menu to investigate. The NIDAQ version assumes that you have a National Instruments data aqusition card, and have installed the version 7.30 NIDAQ drivers. This program is cycle and memory hungry. It may not work well on slow machines. I have tested on

The GUI consists of two parts, a simulated oscilloscope and a simulated stimulator, hereafter refered to as the scope and stimulator.

The scope controls:

The stimulator controls.

Program Internal Organization

The program is structured as a Matlab function. Persistant data is stored in the UserData area of the figure. The initial execution of the function from the command line initializes a bunch of variables and the GUI, then exits. At that point, the GUI is drawn in the figure window and all the GUI controls are waiting patiently for a user action. Control returns to the main function under three conditions:

Each of the events or callbacks passes a string to the main function which is dispatched by a gigantic case statement to perform an action, perhaps modify the persistant data, then exit. Since the main function is not running most of the time, the Matlab command line stays active.

The DAQ toolbox provides an (almost) hardware-independent, abstract, data acqusition interface to Matlab. Several devices are supported. Currently separate versions of this program are written to support the Winsound device and National Instruments NIDAQ hardware. It turns out that there are some device dependencies. A flag must be set in the program to select the hardware to be used before you run it. The DAQ toolbox defines analog input and analog output objects which have quite complex, and potentially asynchronous, behavior. The usual get/set commands specify DAQ object parameters and read back their state. Debugging the porgram consisted mostly of figuring out how to set up DAQ objects and their parameters.

Note that it is possible to produce weird concurrent errors if the user happens to trigger a GUI element at just the wrong time. I am still working on this. There are a few sub-functions near the end of the program. One constructs the stimulator waveform. Another displays an scope trace.