mxbiflow
A framework for building multi-animal, multi-stage behavioral neuroscience experiments with touchscreen interfaces.
Overview
mxbiflow provides the core infrastructure for cognitive and behavioral experiment scheduling. It handles the experiment lifecycle — from configuration wizards and session management to real-time scene rendering and data logging — so you can focus on designing your experiment logic.
Architecture
┌─────────────────────────────────────────────────────────┐
│ mxbiflow │
│ │
│ Dialog Flow (PySide6) Game Loop (pygame-ce) │
│ ┌────────────────┐ ┌───────────────────┐ │
│ │ MXBIPanel │ │ SceneManager │ │
│ │ ExperimentPanel│ ──────▶ │ ├─ Scene A │ │
│ └────────────────┘ │ ├─ Scene B │ │
│ │ └─ ... │ │
│ │ │ │
│ │ Scheduler │ │
│ │ DetectorBridge │ │
│ └───────────────────┘ │
│ │
│ ConfigStore ◄──── JSON config files │
│ DataLogger ────► session data output │
│ │
│ Driver Layer │
│ ┌───────────────────────────────────────────────────┐ │
│ │ RFID / Rewarder / Detector / Audio / Peripherals │ │
│ └───────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
Usage
Implement your experiment as a set of scenes, register them, and launch:
from pathlib import Path
from mxbiflow import SceneManager, init_gameloop, set_base_path
from mxbiflow.ui import run_wizard
set_base_path(Path.cwd())
scene_manager = SceneManager()
scene_manager.register([IDLE, Detect, Discriminate])
if not run_wizard(scene_manager):
raise SystemExit(0)
game = init_gameloop(scene_manager, max_fps=120)
game.play()
Each scene implements SceneProtocol:
class MyScene:
_running: bool
level_table: dict[str, list[int]] = {"default": [1, 2, 3]}
def start(self) -> None: ...
def quit(self) -> None: ...
@property
def running(self) -> bool: ...
def handle_event(self, event: Event) -> None: ...
def update(self, dt_s: float) -> None: ...
def draw(self, screen: Surface) -> None: ...
Logging
mxbiflow never configures logging on import. For a batteries-included
setup, enable the optional log extra and call setup_logging() once,
then use loguru directly:
uv add mxbiflow[log]
from loguru import logger
from mxbiflow.utils.logger import setup_logging
setup_logging(level="DEBUG", log_file="log/mxbi.log")
logger.info("session started: {}", session_id)
setup_logging() wires mxbiflow's records into loguru and configures its
sinks (stderr, plus an optional rotating, JSON-serialized file log).
Because loguru's logger is a global singleton, the logger you import
above is the configured one — no instance is returned. The CLI
(python -m mxbiflow) enables this setup automatically.
Without loguru, the library stays silent: you can handle mxbiflow's records with your own standard-library handlers instead.
Installation
uv add mxbiflow
Hardware interfaces and drivers are available under mxbiflow.driver:
from mxbiflow.driver import MXBI, MXBIModel
from mxbiflow.driver.detector import DetectorEvent
The former pymxbi package is now part of mxbiflow. Replace imports such as
pymxbi.detector with mxbiflow.driver.detector; no compatibility namespace
is installed.
Requirements
- Python 3.14+
- pygame-ce and PySide6
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mxbiflow-0.3.20.tar.gz.
File metadata
- Download URL: mxbiflow-0.3.20.tar.gz
- Upload date:
- Size: 2.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ef598ed802f0d1069b6e98b7d6d31f408ba7f82cf65c87b6d2309f66edbc05c
|
|
| MD5 |
15459f1d91c35d8164f5c27913e6c6af
|
|
| BLAKE2b-256 |
65918f5a13e1e60022bf79664ebd3785fb0d87461bd975994c6d77efa295ea4c
|
File details
Details for the file mxbiflow-0.3.20-py3-none-any.whl.
File metadata
- Download URL: mxbiflow-0.3.20-py3-none-any.whl
- Upload date:
- Size: 2.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dfa18b18c805c8c2f68a9669127621643739c5b57e2f878eb1da917dd1611fd
|
|
| MD5 |
fd4ca5213c70cebfc77e4b00413f4b2b
|
|
| BLAKE2b-256 |
5368f99226d05dc7718d9a7ba595ca7f25439c0505d447c0a87f548725f0cf1b
|