Python License Documentation GitHub issues GitHub stars
High-precision, hardware-clocked olfactometer control system for behavioral neuroscience
π Documentation β’ π Quick Start β’ π§ Installation β’ π Examples β’ π€ Contributing
MultiBiOS (Multispecies Bilateral Odor delivery System) is a precision olfactometer control system designed for behavioral neuroscience experiments. It provides sub-millisecond timing control, complete experimental reproducibility, and comprehensive data logging.
- π― Sub-millisecond precision with hardware-clocked timing via NI-DAQ
- π Bilateral valve control for complex comparative experiments
- π Complete data provenance with comprehensive logging and replay
- π‘οΈ Built-in safety guardrails prevent timing conflicts at compile-time
- π² Reproducible randomization via configurable random seeds
- π Interactive visualization with real-time and post-hoc analysis
- β±οΈ Real-time progress monitoring shows expected protocol state during execution
- π Teensy 4.1 firmware for microsecond-precise valve preloading
- π YAML protocols for human-readable experimental descriptions
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β YAML Protocol βββββΆβ Python Compiler βββββΆβ NI-DAQ USB β
β Description β β & Runner β β 6353 β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββ
β Teensy 4.1 MCU β
β (Valve Pattern Preloading) β
βββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββ
β TPIC6B595 Shift Registers β
β (10MHz SPI Chain) β
βββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββ
β Olfactometer Valve Arrays β
β (8-valve bilateral control) β
βββββββββββββββββββββββββββββββββββββββ
- Conda or Miniconda
- NI-DAQmx drivers (for hardware execution)
- Spinnaker SDK 4.3.0.189 installed on Windows before installing
PySpin - If you want live Blackfly input in FicTrac on this rig, build a Spinnaker-enabled FicTrac binary and configure the
fictracblock inconfig/hardware.yaml
# Clone the repository git clone https://github.com/neurorishika/MultiBiOS.git cd MultiBiOS # Create the shared NI-DAQ + Blackfly camera environment conda env create -f environment.yml conda activate multibios-blackfly # Verify the combined stack python -c "import multibios, nidaqmx, PySpin; print('multibios-blackfly ready')" # Optional app smoke tests multibios-explorer --help multibios-flow-monitor --help
This environment is intended to run both the MultiBiOS DAQ stack and the Blackfly camera scripts in one place. The rig camera model is Teledyne FLIR Blackfly S BFS-U3-13Y3M.
For live FicTrac on the Blackfly side camera, see docs/fictrac.md. MultiBiOS now prepares the Spinnaker runtime DLL path automatically before launching FicTrac, but you still need a FicTrac binary built with the upstream PGR_USB3 option.
If you are on this workstation and want the same validated build that was used for the Blackfly side camera, run:
cd C:\Rishika\MultiBiOS
.\tools\build_fictrac_spinnaker.ps1 -VcpkgRoot C:\Users\markd\vcpkgThe resulting binary is expected at assets/fictrac-spinnaker/fictrac-spinnaker.exe. The step-by-step build and usage guide lives in docs/fictrac.md.
FicTrac is treated as vendored source in this repo because MultiBiOS carries source-level patches in assets/third_party/FicTrac. The local build directory assets/third_party/FicTrac-build should remain untracked.
-
Preview a protocol (no hardware required):
python -m multibios.run_protocol \ --yaml protocols/example_protocol.yaml \ --hardware config/hardware.yaml \ --dry-run --interactive
-
Run on hardware (requires NI-DAQ setup):
python -m multibios.run_protocol \ --yaml protocols/example_protocol.yaml \ --hardware config/hardware.yaml
-
Run with real-time progress monitoring:
python -m multibios.run_protocol \ --yaml protocols/example_protocol.yaml \ --hardware config/hardware.yaml \ --verbose --progress
This displays the expected protocol state during execution:
DO Legend: [0:RCK] [1:LOAD_REQ] [2:S0] [3:S1] [4:S2] AO Legend: [0:MFC1] [1:MFC2] [ 5%] 250.0ms | DO:βββββ | AO:0:2.50,1:1.20 [ 10%] 500.0ms | DO:βββββ | AO:0:3.00,1:1.50(β=HIGH, β=LOW, shows all channels at once!)
-
Analyze results:
python -m multibios.viz_protocol data/runs/latest
## π Examples
### Simple Bilateral Odor Delivery
```yaml
protocol:
name: "Bilateral Odor Comparison"
timing:
sample_rate: 1000 # 1 kHz sampling
seed: 42 # Reproducible randomization
sequence:
- phase: "Baseline"
duration: 30000 # 30 seconds
times: 1
actions:
- device: "olfactometer.left"
state: "AIR"
timing: 0
- device: "olfactometer.right"
state: "AIR"
timing: 0
- phase: "Odor Presentation"
duration: 60000 # 1 minute per trial
times: 5 # 5 trials
randomize: true # Randomize odor order
actions:
- device: "olfactometer.left"
state: "ODOR1,ODOR2,ODOR3" # Random selection
timing: 10000 # 10s into trial
- device: "triggers.microscope"
state: true
timing: 15000 # Trigger at 15s
sequence: - phase: "Complex Trial" duration: 45000 times: 10 actions: # MFC setpoints - device: "mfc.air_left_setpoint" value: 2.1 # Volts timing: 0 # Synchronized valve switching - device: "olfactometer.left" state: "ODOR1" timing: 5000 - device: "switch_valve.left" state: "ODOR" timing: 5100 # 100ms later # Continuous camera triggers - device: "triggers.camera_continuous" state: true timing: 1000 - device: "triggers.camera_continuous" state: false timing: 40000
| Component | Description | Quantity |
|---|---|---|
| NI USB-6353 | Hardware-clocked DAQ | 1 |
| Teensy 4.1 | Microcontroller for valve control | 1 |
| TPIC6B595 | High-power shift registers | 4 |
| Olfactometer valves | Pneumatic valves (12V) | 8-16 |
| Mass flow controllers | Precision flow control | 2-4 |
NI-DAQ βββββ
ββββ LOAD_REQ (Hardware clock)
ββββ S-bits (Device selection)
ββββ Analog I/O (MFC control)
ββββ Triggers (Microscope/Camera)
Teensy βββββ
ββββ SPI Chain (10MHz)
ββββ Interrupt handling
ββββ Safety interlocks
TPIC6B595 ββΌβββ Valve Array Left
ββββ Valve Array Right
ββββ Switch Valve Left
ββββ Switch Valve Right
π Complete wiring diagrams and setup instructions β
MultiBiOS provides comprehensive data logging:
data/runs/2025-08-21_14-07-33/
βββ protocol_original.yaml # Original protocol
βββ protocol_compiled.yaml # Compiled with timing
βββ hardware_config.yaml # Hardware configuration
βββ digital_output.npy # DO timing arrays
βββ analog_output.npy # AO setpoints
βββ analog_input.csv # MFC feedback (if recorded)
βββ timing_log.csv # Execution timestamps
βββ visualization.html # Interactive plot
The system generates rich interactive plots showing:
- π Commanded vs actual valve states
- ποΈ Analog input/output traces
- β±οΈ Timing precision analysis
- π Zoom and pan capabilities
MultiBiOS is designed for:
- Behavioral choice experiments with precise odor timing
- Optogenetics with synchronized light/odor delivery
- Calcium imaging with triggered acquisition
- Electrophysiology with sub-millisecond precision
- Multi-animal comparative studies
- Reproducible protocols across labs and sessions
- β Compile-time validation prevents hardware conflicts
- β Timing guardrails ensure safe valve switching
- β State verification with sticky S-bit monitoring
- β Hardware interlocks prevent damage
- β Complete logging for audit trails
- π― Deterministic randomization with configurable seeds
- π Complete parameter logging
- π Protocol replay capability
- π Timing validation and verification
- π·οΈ Version tracking of all components
Comprehensive documentation is available at neurorishika.github.io/MultiBiOS
- ποΈ System Architecture
- π Hardware Setup
- πΎ Firmware Guide
- π Protocol Reference
- π Runner Application
- π Visualization
- β FAQ
- π§ Troubleshooting
We welcome contributions! MultiBiOS is built for the neuroscience community.
- π Report bugs and request features
- π‘ Submit improvements to code or documentation
- π§ͺ Share protocols and use cases
- π§ Hardware modifications and extensions
- π Documentation improvements
# Fork the repository on GitHub git clone https://github.com/yourusername/MultiBiOS.git cd MultiBiOS # Install development dependencies poetry install --with dev # Run tests poetry run pytest # Format code poetry run black multibios/ poetry run ruff check multibios/
tests/is reserved for automatedpytestcoverage.tools/manual_checks/is for operator-facing hardware checks, probes, and bench scripts that are meant to be run directly.- When adding new validation code, put reusable automated assertions under
tests/and keep live camera, DAQ, MFC, or FicTrac helpers undertools/manual_checks/.
For a quick automated smoke pass from the repo root, run:
pytest tests/
π Full contributing guide β
This project is licensed under the MIT License - see the LICENSE file for details.
MultiBiOS was developed for the neuroscience research community. Special thanks to:
- The Ruta and Kronauer Labs for requirements and testing
- National Instruments for DAQ hardware support
- The Arduino/Teensy community for firmware foundations
- Open source contributors who make science better
- Issues & Support: GitHub Issues
- Email: neurorishika@gmail.com
- Documentation: neurorishika.github.io/MultiBiOS
π§ Built for Neuroscience β’ π¬ Made with Science β’ π Open Source
β Star this repo β’ π Read the docs β’ π€ Contribute