Skip to main content

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

mxbiflow-0.3.18.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mxbiflow-0.3.18-py3-none-any.whl (2.3 MB view details)

Uploaded Python 3

File details

Details for the file mxbiflow-0.3.18.tar.gz.

File metadata

  • Download URL: mxbiflow-0.3.18.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

Hashes for mxbiflow-0.3.18.tar.gz
Algorithm Hash digest
SHA256 828b3374684dbb8c5c1eeca91d17cb028e8b9003d47603b60c0065926ca0c9a1
MD5 18dea379cc0fa8af3c868028bfc8945e
BLAKE2b-256 10f57a4b19c3822642bb1c9b17c7883951046327c3b5a729b6d0732a0d7e14b1

See more details on using hashes here.

File details

Details for the file mxbiflow-0.3.18-py3-none-any.whl.

File metadata

  • Download URL: mxbiflow-0.3.18-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

Hashes for mxbiflow-0.3.18-py3-none-any.whl
Algorithm Hash digest
SHA256 7008d47f4e5dbad7a97d222aa2c80f8163b359968140ed807613b995768b7cd9
MD5 3e7a179b3534e4323095a4d3f59cc928
BLAKE2b-256 e06d770d4cbc92e7b8a3ec9edf63b835b2c81f2d9e5f2b011f2bb068b34fb4e9

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.23

2 files

0.3.22

2 files

0.3.21

2 files

0.3.20

2 files

0.3.19

2 files

This release

0.3.18 This release

2 files

0.3.17

2 files

0.3.16

2 files

0.3.15

2 files

0.3.14

2 files

0.3.13

2 files

0.3.12

2 files

0.3.11

2 files

0.3.10

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page