EthoPy Configuration Guide¶
Quick Start¶
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Configuration File Location¶
The configuration file is stored in:
- Linux/macOS: ~/.ethopy/local_conf.json
- Windows: %USERPROFILE%\.ethopy\local_conf.json
Basic Configuration Structure¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Using the Configuration Manager¶
Basic Operations¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Working with Paths¶
1 2 3 4 5 6 7 |
|
Advanced Usage¶
Environment Variables Override¶
Set environment variables to override configuration:
1 2 |
|
Custom Configuration File¶
1 |
|
Configuration Validation¶
The ConfigurationManager automatically validates and sets defaults for: - Database connection settings - Schema names - Logging configuration - Required paths
Configuration Sections¶
Database Settings (dj_local_conf
)¶
Essential settings for DataJoint database connection:
1 2 3 4 5 6 7 8 9 10 11 |
|
Schema Mapping (SCHEMATA
)¶
Maps internal schema names to database schemas:
1 2 3 4 5 6 7 8 |
|
Logging Configuration¶
1 2 3 4 5 6 7 8 9 |
|
Hardware Channel Configuration (channels
)¶
The channels
configuration defines GPIO pin mappings for various hardware components. This is crucial for experiments that involve physical hardware interaction, particularly on Raspberry Pi systems.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Channel Types and Their Uses¶
-
Odor Channels
- Purpose: Control odor delivery valves
- Format:
{"port_number": gpio_pin}
- Example:
"1": 24
maps odor port 1 to GPIO pin 24
-
Liquid Channels
- Purpose: Control water/liquid reward delivery
- Format:
{"port_number": gpio_pin}
- Example:
"1": 22
maps liquid port 1 to GPIO pin 22
-
Lick Channels
- Purpose: Detect animal licking behavior
- Format:
{"port_number": gpio_pin}
- Example:
"1": 17
maps lick detector 1 to GPIO pin 17
-
Proximity Channels
- Purpose: Detect animal presence/position
- Format:
{"port_number": gpio_pin}
- Example:
"3": 9
maps proximity sensor 3 to GPIO pin 9
-
Sound Channel
- Purpose: Control audio output
- Format:
{"port_number": gpio_pin}
- Example:
"1": 13
maps sound output to GPIO pin 13
-
Sync Channels
- Purpose: Synchronization with external devices
- Components:
"in"
: Input synchronization signal"rec"
: Recording trigger"out"
: Output synchronization signal
-
Special Channels
"Opto"
: Single pin for optogenetics control"Status"
: LED indicator for system status
Hardware Setup Considerations¶
-
Pin Conflicts
- Ensure no GPIO pin is assigned to multiple channels
- Check pin capabilities (input/output/PWM support)
- Avoid system-reserved pins
-
Safety Checks
1 2 3 4 5 6 7 8
# Example validation pins_used = set() for device, pins in config.get('channels').items(): if isinstance(pins, dict): for pin in pins.values(): if pin in pins_used: raise ValueError(f"Pin {pin} used multiple times") pins_used.add(pin)
-
Power Requirements
- Consider current limitations of GPIO pins
- Use appropriate hardware drivers for high-power devices
- Include safety resistors where needed
Common Hardware Configurations¶
-
Basic Setup (2 ports)
1 2 3 4
{ "Liquid": {"1": 22, "2": 23}, "Lick": {"1": 17, "2": 27} }
-
Advanced Setup (with all features)
1 2 3 4 5 6 7 8 9 10
{ "Liquid": {"1": 22, "2": 23}, "Lick": {"1": 17, "2": 27}, "Proximity": {"1": 5, "2": 6}, "Odor": {"1": 24, "2": 25}, "Sound": {"1": 13}, "Sync": {"in": 21, "rec": 26, "out": 16}, "Opto": 19, "Status": 20 }
Paths Configuration¶
1 2 3 4 5 |
|
Best Practices¶
-
Security
- Never commit configuration files with sensitive data
- Use environment variables for passwords
- Keep backups of your configuration
-
Path Management
- Use absolute paths when possible
- Ensure write permissions for logs/data
- Regularly check available disk space
-
Error Handling
- Always check if paths exist before operations
- Handle missing configuration values gracefully
- Log configuration changes
Common Issues and Solutions¶
Database Connection Issues¶
Problem: Cannot connect to database
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Path Permission Issues¶
Problem: Cannot write to paths
1 2 3 4 5 6 7 8 |
|
Future Improvements¶
The configuration system is continually being improved. Planned features include:
- Schema validation using Pydantic
- Configuration migration tools
- GUI configuration editor
Contributing¶
To contribute to the configuration system:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Submit a pull request
Testing Your Configuration¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|