A demonstration/example of the LabJack

We previously described the super awesome DAQ system, the LabJack. An example may go a long way in further explaining the system.

We go through a lot here, in a very specific way, but hope that this example is broad enough that it is applicable to your research. Ultimately we will demonstrate how to use the LabJack to align a variety of signals. For a specific example: we will align a neural recording to a behavior system. Even more specifically, we show how to align the recordings of the super exciting Neuropixel system to the output of a treadmill, a TTL indicating the start of a trial and presentation of an LED, and the output of a camera (DeepLabCut anyone?) recording the behavior. And we provide example data of this. But broadly speaking, this demonstrates how to align a 5V digital TTL signal (output from the Neuropixel system) to an analog signal (treadmill), another TTL digital signal (trial start), and a 3.3V signal (camera). Two 5V digital signals, one 3.3V signal, and one analog signal.

Outputting a TTL from OpenEphys

Note, that to get a TTL output from OpenEphys for the Neuropixls, do XyZ (I’ll describe this later).

Set up

Equipment Signal LabJack Input LJStreamUD Row +Ch -Ch Scaling Equation
Neuropixel 5V Digital FI04 0 193 199 y=floor(a/2^4)-2*floor(a/2^5)
Trial start/LED 5V Digital FI05 1 193 199 y=floor(b/2^5)-2*floor(b/2^6)
Camera 3.3V Digital FI06 2 193 199 y=floor(c/2^6)-2*floor(c/2^7)
Treadmill 5V Analog AIN01 3 1 199 y=d

This demonstration assumes you have the LabJack set up as shown here and have the software installed. Go to Start => LabJack => LabjackStreamUD to open the software. Input the following


More information of each input can be found on the LabJack site. But to go over what is going on here:

  • The ‘# Channels’ is four (3 digital and one analog)
  • The scan rate is set to 2kHz (choose what makes sense to you and what the LJ can handle). The max sample rate of the U3 is 50 ksamples/second. The max scan rate depends on how many channels you are sampling per scan. Full resolution streaming is limited to 2500 samples/s. More info here
  • Generally keep the Resolution and SettlingFactors at zero
  • Indicate you want to log the file (write to file) by ensuring that check box is black
  • Add a Data File Prefix (example: May3FourCh) to name your log file. An index is also automatically added when more than one file is generated (example: May3FourCh_0 and May3FourCh_1)
  • Increase the Max File Size to something that makes sense. If the maximum file size is reached, a new separate file will be generated and you can just post-hock stitch the files together
  • Change the working directory to someplace that makes sense to you
  • Change the graph history to something that makes sense to you and your experiment (ten times the scan rate?). This is just what will be displayed in this Window
  • Indicate that you want to graph all four signals in this window by ensuring the rows are all marked green in “Graph?”
  • !!!!! Be sure to disable scaling by ensuring that “Disable Scaling” is not checked (white)

Now the fun stuff. We’ll work backwards, from row 3 to 0.

  • Row 3: This is our analog signal we are recording on AIN01. The +Ch tells the software which pin on the LJ to record a voltage from. We are using AIN01, so we set the +Ch to 1. There are four analog pins available on the LJ. If we chose to use AIN00, we would set the +Ch to 0. Next, we set the -Ch to 199 or ground. The LJ compares the voltages between two points. By setting the -Ch to 199, we are telling it to compare our positive channel (AIN01) to ground (199). Next is the scaling equation. The LJ stores the voltage in a variable (as a letter) that corresponds to the row in the LJStreamUD. We are in the fourth row here, so d is the variable. When you do analog readings the scaling is 1:1, so no scale is applied. We simply set y=d
  • Row 2. This is our camera input, coming in on FI06 on the LJ. The LJStreamUD does something really cool to get a digital reading from an analog input functions, thus allowing streaming. By setting the +Ch to 193, we are telling it to read the 16 bits of the Digital I/O (in decimal form for speed) and store it in the variable for this row. Because we are in the second row (index 0) the variable here is c. Then we use math to pull out the reading of our desired pin from the 16 bits.

    y=floor(loggerVar/2^DIONum) - 2*floor(loggerVar/2^(DIONum+1))

    Where loggerVar is the default scaling equation variable that holds the bitmask value and DIONum is the digital IO number of interest.

    Here, loggerVar is c, and DIONum is FI06 or 6. Therefore this equation becomes


    The -Ch is fine to be chosen as ground, 199.

  • Row 1: Here is our Trials Start/LED 5V TTL. Again, we choose the +Ch to be 193 (read the bits of our digital IO) and store it in a variable for this row (b). Then we math for the scaling equation:


  • Row 0: This is the TTL from the Neuropixels. Bla bla, math:


Hit the Start Stream button to begin acquiring data. Data will be saved as a .dat file. Here is an example file. There are many ways to view/plot/manipulate the data, including just renaming the file as .cvs and opening with a spreadsheet viewer (MS Excel). The data file (.dat) will have a header with useful information about the time of starting etc. Then each row will have a timestamp and a corresponding reading for each channel (4 channels in this example).


Aligning the Data

Here I will show how to subtract the beginning data and aligning the NP data. I will show super awesome pictures and will include data.

ONE Core acknowledgment

Please acknowledge the ONE Core facility in your publications. An appropriate wording would be:

“The Optogenetics and Neural Engineering (ONE) Core at the University of Colorado School of Medicine provided engineering support for this research. The ONE Core is part of the NeuroTechnology Center, funded in part by the School of Medicine and by the National Institute of Neurological Disorders and Stroke of the National Institutes of Health under award number P30NS048154.”