Setup Configuration in EthoPy¶
What is setup_conf_idx?¶
The setup_conf_idx
(Setup Configuration Index) is a unique number that defines a complete hardware setup for your experiments. Think of it as a "recipe" that tells EthoPy:
- What type of hardware interface to use (simulation, Raspberry Pi, PC ports, etc.)
- How many ports you have and what they do (lick detection, reward delivery, etc.)
- Screen settings for visual stimuli
- Camera settings for recording
- Audio settings for sound stimuli
Key concept: Each setup_conf_idx
represents one complete hardware configuration. You can have multiple configurations (idx 0, 1, 2, etc.) for different experimental setups.
Why Use Different Setup Configurations?¶
Different experiments may need different hardware:
- setup_conf_idx = 0: Simulation mode (no real hardware, keyboard input)
- setup_conf_idx = 1: Basic Raspberry Pi setup with 2 lick ports and 1 reward valve
- setup_conf_idx = 2: Advanced setup with multiple cameras, speakers, and VR ball
- setup_conf_idx = 3: Simple PC setup for visual-only experiments
What Does setup_conf_idx Define?¶
1. Main Configuration¶
1 2 3 4 5 |
|
Interface types:
DummyPorts
: Simulation mode (keyboard input, no real hardware)RPPorts
: Raspberry Pi with GPIO pinsPCPorts
: PC with serial/USB connectionsRPVR
: Raspberry Pi with virtual reality ball
2. Port Configuration¶
Defines your behavioral ports (lick detectors, reward valves, etc.):
1 2 3 4 5 6 7 8 9 |
|
Port types:
Lick
: Detects when animal licks (infrared sensor, capacitive sensor, etc.)Proximity
: Detects when animal is in position (motion sensor, etc.)
Port flags (what each port can do):
ready=1
: Port can detect when animal is in "ready" position for a trialresponse=1
: Port can register behavioral responses (licks, touches, etc.)reward=1
: Port can deliver rewards (water, food, etc.)invert=1
: Flip the signal (useful if your sensor gives opposite readings)
3. Screen Configuration¶
1 2 3 4 5 6 7 8 9 10 11 12 |
|
4. Camera Configuration¶
1 2 3 4 5 6 7 8 |
|
5. Other Components¶
- Ball: For virtual reality experiments
- Speaker: For audio stimuli
How to Create a New Setup Configuration¶
Alternative Method: Instead of using Python code, you can use DBBeaver (a free database management tool) to create and modify setup configurations through a user-friendly graphical interface. This can be easier for users who prefer visual database editing over writing code.
Step 1: Choose Your setup_conf_idx Number¶
Pick an unused number (check existing configurations first):
1 2 3 4 5 6 7 |
|
Step 2: Add Main Configuration¶
1 2 3 4 5 6 |
|
Step 3: Add Port Configuration¶
Important: You MUST add at least one port configuration.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
Step 4: Add Screen Configuration (If Needed)¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Step 5: Add Camera Configuration (If Needed)¶
1 2 3 4 5 6 7 8 9 10 |
|
Using Your New Configuration¶
Once created, use your new setup in tasks:
1 2 3 4 |
|
Pre-built Configuration¶
Default Simulation (setup_conf_idx = 0)¶
Perfect for testing tasks without hardware: - Interface: DummyPorts (keyboard simulation) - Ports: 2 lick ports + 1 proximity (controlled by arrow keys and spacebar) - Screen: Basic simulation screen
Troubleshooting¶
Common Issues¶
- "Configuration not found" error
- Check if your
setup_conf_idx
exists in the database -
Verify you inserted the main configuration correctly
-
Hardware not responding
- Verify your
interface
type matches your actual hardware - For RPPorts: Check GPIO pin connections in
local_conf.json
- For simulation: Use DummyPorts interface
Getting Help¶
- Check existing configurations: Look at working setups (especially setup_conf_idx = 0)
- Start simple: Begin with simulation mode, then add real hardware
- Ask for help: Contact your lab's technical support for hardware-specific issues
Summary¶
The setup_conf_idx
system lets you:
- Define different hardware setups for different experiments
- Switch between configurations easily (simulation vs real hardware)
- Share configurations across different experimental computers
- Maintain consistency in hardware setup across experiments
Each setup_conf_idx is completely independent - changing one doesn't affect others. This makes it safe to experiment with new configurations while keeping working setups intact.
Important Note: Configuration History and Data Integrity¶
Configuration parameters are automatically saved for each experimental session. When you start a session, EthoPy copies all configuration parameters from the setup tables into the lab_interface
schema tables connected to that specific session. This means:
- Data integrity: Even if you modify a setup configuration later, your historical data remains linked to the exact parameters that were used during each session
- Reproducibility: You can always see exactly what hardware settings were used for any past experiment
- Safe updates: You can safely update setup configurations without affecting the analysis of previous experiments
- Audit trail: All configuration changes are preserved, preventing data drift issues
This automatic parameter logging ensures that your experimental data always maintains a complete record of the hardware setup used, making your research more reproducible and reliable.