EthoPy Local Configuration Guide¶
What is local_conf.json?¶
The local_conf.json
file stores device-specific settings that are unique to each computer or experimental setup. These are settings that:
- Are tied to your specific hardware (file paths, GPIO pins, database credentials)
- Need to be configured once per machine, not per experiment
Key distinction: Experimental parameters and data go in the database. Machine-specific settings go in local_conf.json
.
File Location¶
EthoPy automatically looks for your configuration file here:
- Mac/Linux:
~/.ethopy/local_conf.json
- Windows:
%USERPROFILE%\.ethopy\local_conf.json
You can also specify a custom location using the environment variable:
- Environment variable: Set
ETHOPY_CONFIG_PATH
to point to your custom config file location
Essential Configuration¶
Minimal Setup¶
Here's the minimum configuration needed to get EthoPy running:
1 2 3 4 5 6 7 8 9 10 |
|
What each part does:
dj_local_conf
: Database connection settings (required)source_path
: Where experimental data files are saved on this machinetarget_path
: Where backup copies should be saved
Configuration Sections¶
1. Database Settings (Required)¶
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Settings explanation:
-
database.host
: Database server IP address or hostname- Default:
"127.0.0.1"
(localhost - your computer) - Examples:
"192.168.1.100"
,"lab-database.university.edu"
- Default:
-
database.user
: MySQL username for database connection- Default:
"root"
- Default:
-
database.password
: MySQL password for the specified user- Default:
""
(empty string)
- Default:
-
database.port
: MySQL server port number- Default:
3306
(standard MySQL port) - Note: Only change if your MySQL uses a different port
- Default:
-
database.reconnect
: Automatically reconnect if connection is lost- Default:
true
- Default:
-
database.use_tls
: Use encrypted TLS connection to database, more details here- Default:
false
- Default:
-
datajoint.loglevel
: DataJoint library logging verbosity- Default:
"WARNING"
- Options:
"DEBUG"
,"INFO"
,"WARNING"
,"ERROR"
,"CRITICAL"
- Default:
2. File Paths (Required)¶
1 2 3 4 |
|
Settings explanation:
-
source_path
: Local directory where experimental data files are saved- Default:
"~/EthoPy_Files"
(EthoPy_Files folder in your home directory) - Purpose: All recorded data (videos, sensor data, etc.) is stored here during experiments
- Examples:
"/Users/yourname/experiment_data"
,"/home/pi/data"
- Default:
-
target_path
: Directory where backup copies of data should be moved after experiments- Default:
"/"
(root directory - usually needs to be changed) - Purpose: Automatic backup/archival location for completed experiments
- Examples:
"/mnt/lab_storage"
- Default:
Important: Always use full paths starting from your drive root.
3. Logging Settings (Optional)¶
1 2 3 4 5 6 7 8 9 |
|
Settings explanation:
-
level
: Minimum log level to record- Default:
"INFO"
- Options:
"DEBUG"
(most verbose),"INFO"
,"WARNING"
,"ERROR"
,"CRITICAL"
(least verbose) - Purpose: Controls how much detail is logged
- Default:
-
directory
: Directory where log files are stored- Default:
"~/.ethopy/"
(hidden .ethopy folder in your home directory) - Examples:
"/var/log/ethopy"
,"/Users/yourname/logs"
- Default:
-
filename
: Name of the main log file- Default:
"ethopy.log"
- Note: Backup files will be named
ethopy.log.1
,ethopy.log.2
, etc.
- Default:
-
max_size
: Maximum size of log file before rotation (in bytes)- Default:
31457280
(30 MB) - Purpose: Prevents log files from growing too large
- Default:
-
backup_count
: Number of old log files to keep- Default:
5
- Purpose: Maintains history while preventing unlimited disk usage
- Default:
4. Hardware Setup (Optional - Raspberry Pi only)¶
If you're using physical hardware (valves, sensors, LEDs), specify GPIO pin connections:
1 2 3 4 5 6 7 |
|
Settings explanation:
Channels
: Maps hardware types to GPIO pin assignments- Default: Not set (no hardware channels configured)
- Purpose: Tells EthoPy which GPIO pins control which hardware devices
Hardware types:
-
Liquid
: Water delivery pumps/valves for reward delivery- Format:
{"port_number": gpio_pin_number}
- Example:
{"1": 22, "2": 23}
means port 1 uses GPIO pin 22, port 2 uses GPIO pin 23
- Format:
-
Lick
: Lick detection sensors for behavioral monitoring- Format:
{"sensor_number": gpio_pin_number}
- Example:
{"1": 17, "2": 27}
means lick sensor 1 on GPIO pin 17, sensor 2 on GPIO pin 27
- Format:
-
Odor
: Odor delivery valves for olfactory experiments- Format:
{"valve_number": gpio_pin_number}
- Example:
{"1": 24, "2": 25}
means valve 1 on GPIO pin 24, valve 2 on GPIO pin 25
- Format:
Important notes:
- Each GPIO pin number can only be used once across all hardware types
5. Custom Schema Names (Optional)¶
If your database uses custom schema names:
1 2 3 4 5 6 7 8 9 |
|
Settings explanation:
SCHEMATA
: Maps EthoPy data types to your custom database schema names- Purpose: Allows EthoPy to work with existing databases that use different naming conventions
Schema types and defaults:
-
experiment
: Main experimental session data- Default:
"lab_experiments"
- Contains: Session info, trial data, animal information
- Default:
-
behavior
: Behavioral measurement data- Default:
"lab_behavior"
- Contains: Lick detection, movement tracking, response data
- Default:
-
stimulus
: Stimulus presentation information- Default:
"lab_stimuli"
- Contains: Visual/auditory stimuli parameters, timing
- Default:
-
interface
: Hardware interface configurations- Default:
"lab_interface"
- Contains: Hardware setup parameters, calibration data
- Default:
-
recording
: Data recording metadata- Default:
"lab_recordings"
- Contains: File paths, recording parameters, data format info
- Default:
Note: Most users can skip this section - EthoPy will use the default schema names.
6. Plugin Path (Optional)¶
1 2 3 |
|
Settings explanation:
plugin_path
: Directory where EthoPy plugins are stored- Default:
"~/.ethopy/ethopy_plugins"
(plugins folder in your .ethopy directory) - Purpose: Location for custom EthoPy extensions and plugins
- Examples:
"/Users/yourname/my_plugins"
,"/opt/ethopy_plugins"
- Default:
Note: Only needed if you're using custom plugins or want to store them in a different location.
Common Setup Scenarios¶
Local Database Setup (Most Common)¶
1 2 3 4 5 6 7 8 9 10 |
|
Remote Database Setup¶
1 2 3 4 5 6 7 8 9 10 |
|
Hardware Experiment Setup¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Troubleshooting¶
Problem: "Cannot connect to database"¶
Solutions:
-
Check your password - Verify the password matches your MySQL password
-
Advanced troubleshooting: For remote databases or lab setups, contact your system administrator or IT support to verify database server status, network connectivity, and firewall settings. Check if MySQL is running
- If
database.host
is127.0.0.1
orlocalhost
: Runmysql -u root -p
on the same machine as EthoPy - If
database.host
is a remote IP (like192.168.1.100
): Run the command on that remote database server - The command should ask for your password and connect successfully
- If you get "command not found", MySQL client is not installed
- If you get "connection refused", MySQL server is not running
- If
-
Check the database address - For
127.0.0.1
, MySQL must be on your computer -
Check the port number - MySQL usually uses 3306
Problem: "Cannot find data path"¶
Solutions:
-
Check the folder exists - Verify the folder exists in your file system
-
Use full paths - Use
/Users/yourname/data/
notdata/
-
Check permissions - Ensure you can read and write to the folder
-
Create the folder - Create the folder if it doesn't exist
Problem: "Hardware not responding"¶
Solutions:
-
Check physical connections - Verify all wires are properly connected
-
Check pin numbers - Ensure pin numbers match your hardware setup
-
Check for conflicts - Make sure no pin number is used twice
-
Test with simple LED - Verify basic GPIO functionality
Problem: "Configuration file not found"¶
Solutions:
-
Check file location - Ensure
local_conf.json
is in~/.ethopy/
-
Check JSON format - Verify proper JSON syntax (no missing commas/brackets)
-
Start simple - Copy one of the examples from this guide
Security Best Practices¶
- Never share your config file - It contains database passwords
- Use strong passwords - Protect your database access
- Keep backups - Save a copy of your working configuration
- Use full paths - Avoid relative paths that might break
Local vs Database Settings¶
Store in local_conf.json:
- Database connection details
- File paths specific to this machine
- Hardware GPIO pin assignments
- Logging preferences
- Machine-specific settings
Store in database:
- Experimental parameters
- Trial configurations
- Animal information
- Session data
- Results and measurements
This separation keeps your experiments portable while maintaining machine-specific configurations.