Skip to content

phoBehavioralBoxLabjackController

Antwan-Green edited this page Jan 3, 2024 · 5 revisions

Pho Behavioral Box LabJack Controller

This software is used by lab members on Lab Computers to record the activity of mice via the LabJack.

This C++ code tracks activity of all dispensers. The code performs this by assigning a 0 or 1 to each variable excluding the running wheel. Once the mice triggers a dispenser by nose-poke, the software then saves that by changing the zero to a one. Then, a line is created in a CSV that lists the change along with the time the change occurred.

Here is an example of what the code looks like in action:

Upon loading the program, this text will display:

 Behavioral Box LabJack Controller:

 Version #

 Pho Hale 2021

 CURRENT CONFIGURATION:==============================================
 Computer Hostname: Watson-BB-XX 

 Experiment Name: Exp_XX
 Cohort Name: cohort_xx
 Animal Name: Amimal_xx

 Filesystem:
  Output Directory: C:/Common/data/experiment_xx/cohort_xx/animal_xx/
  Historical data loading is enables and the output directory is 
 C:/Common/data/experiment_xx/cohort_xx/animal_xx
 Webserver is enabled. It can be accessed via a web browser at URL http://xx.x.x.x:xxxx
 ==================================================== END CURRENT CONFIGURATION

The above section just out lines where the files that will be retrieved by the program will be stored, as well as any backup locations- these can all be changed by editing the phoBehavioralBoxLabjackController-Config.ini file.

Scanning for attached Labjacks...

Found 1 device connections

Successfully read json data from C:/Common/config/phoBehavioralBoxLabjackController- 
LogicalChannelSetupConfig.json!

Attempting to parse as a LoadedLogicalChannelsSetupConfiguration object...

Successfully loaded C:/Common/config/phoBehavioralBoxLabjackController-LogicalChannelSetupConfig.json as 
JSON and updated this->loadedChannelSetupConfig!

Sucessfully loading config from C:/Common/config/phoBehavioralBoxLabjackController- 
LogicalChannelSetupConfig.json!

All of this information can be found on Github via the "ConfigFiles" Subfolder in the "phoBehavioralBoxLabjackController" directory!

Setting up Labjack Stream Registers:

Disabling stream for handle: 2
Ensuring triggered stream is disabled:    Setting STREAM_TRIGGER_INDEX to 0

Enabling internally-clocked stream:    Setting STREAM_CLOCK_SOURCE to 0

Setting STREAM_RESOLUTION_INDEX to 0

Setting STREAM_SETTLING_US to 0.000000

Setting AIN_ALL_RANGE to 0.000000

Setting AIN_ALL_NEGATIVE_CH to LJM_GND

The above code sets the some of the data stream's channels to constant variables:

-Such as the STREAM_TRIGGER_INDEX (to be disabled),

-STREAM_RESOLUTION_INDEX (disabled to ensure that we only used the sync between the Labjack and computer to change the lux of our light system),

-STREAM_RESOLUTION_INDEX (ensures that the resolution, or how many times the software interprets data from the LabJack is set to zero before being configured later)

-STREAM_SETTLING_US (the time it takes for a stream of data to reset before recording again)

-AIN_ALL_RANGE (the range for analog inputs to be set to zero for the running wheel)

-AIN_ALL_NEGATIVE_CH (setting all negative channels to have the same signal as the ground channel)

 Scan Stream started!
        New file paths:
        Digital Inputs: 
 C:/Common/data/experiment_xx/cohort_xx/animal_xx/out_file_sxxxxxxxxx_Unix_time_in_ms.csv
     Analog Inputs: 
 C:/Common/data/experiment_06/cohort_01/animal_05/out_file_analog_sxxxxxxxxx_Unix_time_in_ms.csv
     Labjack [470020353] :
        LABJACK TIME: Wed Jan  3 05:00:04 2024
        COMPUTER TIME: Wed Jan  3 05:00:04 2024
        Computer time is already synced with Labjack time!

The code for this section is located in the phoLabjackClockSync.c file on Github.

  Commands:
        Press [p] at any time to print the most recently read values for all labjacks.
        Press [f] at any time to show the current output file directory.
        Press [s] at any time to show the current log files for all labjacks.
        Press [r] at any time to refresh and scan for more labjacks.
        Press [l] at any time to toggle visible LED Light mode for all labjacks.
        Press [a] at any time to toggle Attract mode for all labjacks.
        Press [u] at any time to display utility options.
        Press [q] at any time to quit.
        Press any other key at any time to show this list of commands.
Clone this wiki locally