Skip to main content

Python interface to the Reiser lab ArenaController.

Project description

About

- Python Package Name: arena_interface
- Description: Python interface to the Reiser lab ArenaController.
- Version: 3.0.0
- Python Version: 3.11
- Release Date: 2025-09-09
- Creation Date: 2023-10-17
- License: BSD-3-Clause
- URL: https://github.com/janelia-python/arena_interface_python
- Author: Peter Polidoro
- Email: peter@polidoro.io
- Copyright: 2025 Howard Hughes Medical Institute
- References:
  - https://github.com/janelia-arduino/ArenaController
- Dependencies:
  - click
  - schedule
  - pyserial

Example Usage

Python

from arena_interface import ArenaInterface

ai = ArenaInterface(debug=True)
ai.set_ethernet_mode()
# or
ai.set_serial_mode(port='/dev/ttyACM0', baudrate=115200)
ai.all_on()
ai.all_off()
ai.stream_frame(path='./patterns/pat0004.pat', frame_index=0)
ai.stream_frames(path='./patterns/pat0004.pat', frame_rate=20, runtime_duration=50)
ai.trial_params(pattern_id=3, frame_rate=20, runtime_duration=50)
ai.trial_params(pattern_id=3, frame_rate=-20, runtime_duration=50)

Command Line

help

arena-interface --help
# Usage: arena-interface [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  all-off
  all-on
  display-reset
  set-refresh-rate
  stream-frame
  trial-params
arena-interface stream-frame --help
# Usage: arena-interface [OPTIONS] PATH FRAME_INDEX

Options:
  --help  Show this message and exit.
  1. example commands

    arena-interface all-on
    
    $FRAME_INDEX=0
    arena-interface stream-frame ./patterns/pat0004.pat $FRAME_INDEX
    arena-interface stream-frame ./patterns/pat0004.pat 0
    
    FRAME_RATE=2
    RUNTIME_DURATION=50 # 50 * 100ms = 5000ms = 5s
    arena-interface stream-frames ./patterns/pat0004.pat $FRAME_RATE $RUNTIME_DURATION
    arena-interface stream-frames ./patterns/pat0004.pat 2 50
    
    PATTERN_ID=3
    FRAME_RATE=20
    RUNTIME_DURATION=50 # 50 * 100ms = 5000ms = 5s
    arena-interface trial-params -- $PATTERN_ID $FRAME_RATE $RUNTIME_DURATION
    arena-interface trial-params -- 3 20 50
    
    PATTERN_ID=3
    FRAME_RATE=-20
    RUNTIME_DURATION=50 # 50 * 100ms = 5000ms = 5s
    arena-interface trial-params -- $PATTERN_ID $FRAME_RATE $RUNTIME_DURATION
    arena-interface trial-params -- 3 -20 50
    
    arena-interface all-off
    
  2. advanced commands

    arena-interface set-refresh-rate 175
    
    arena-interface switch-grayscale 0 # 0=binary, 1=grayscale
    

Installation

https://github.com/janelia-python/python_setup

GNU/Linux

Ethernet

C-x C-f /sudo::/etc/network/interfaces

auto eth1

iface eth1 inet static

    address 192.168.10.2

    netmask 255.255.255.0

    gateway 192.168.10.1

    dns-nameserver 8.8.8.8 8.8.4.4
nmap -sn 192.168.10.0/24
nmap -p 62222 192.168.10.62
nmap -sV -p 62222 192.168.10.0/24
sudo -E guix shell nmap
sudo -E guix shell wireshark -- wireshark
make guix-container

Serial

  1. Drivers

    GNU/Linux computers usually have all of the necessary drivers already installed, but users need the appropriate permissions to open the device and communicate with it.

    Udev is the GNU/Linux subsystem that detects when things are plugged into your computer.

    Udev may be used to detect when a device is plugged into the computer and automatically give permission to open that device.

    If you plug a sensor into your computer and attempt to open it and get an error such as: "FATAL: cannot open /dev/ttyACM0: Permission denied", then you need to install udev rules to give permission to open that device.

    Udev rules may be downloaded as a file and placed in the appropriate directory using these instructions:

    99-platformio-udev.rules

  2. Download rules into the correct directory

    curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/master/scripts/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules
    
  3. Restart udev management tool

    sudo service udev restart
    
  4. Ubuntu/Debian users may need to add own “username” to the “dialout” group

    sudo usermod -a -G dialout $USER
    sudo usermod -a -G plugdev $USER
    
  5. After setting up rules and groups

    You will need to log out and log back in again (or reboot) for the user group changes to take effect.

    After this file is installed, physically unplug and reconnect your board.

Python Code

The Python code in this library may be installed in any number of ways, chose one.

  1. pip

    python3 -m venv ~/venvs/arena_interface
    source ~/venvs/arena_interface/bin/activate
    pip install arena_interface
    
  2. guix

    Setup guix-janelia channel:

    https://github.com/guix-janelia/guix-janelia

    guix install python-arena-interface
    

Windows

Python Code

The Python code in this library may be installed in any number of ways, chose one.

  1. pip

    python3 -m venv C:\venvs\arena_interface
    C:\venvs\arena_interface\Scripts\activate
    pip install arena_interface
    

Development

Clone Repository

git clone git@github.com:janelia-python/arena_interface_python.git
cd arena_interface_python

Guix

Install Guix

Install Guix

Edit metadata.org

make metadata-edits

Tangle metadata.org

make metadata

Develop Python package

make guix-dev-container
exit

Test Python package using ipython shell

make guix-dev-container-ipython
import arena_interface
exit

Test Python package installation

make guix-container
exit

Upload Python package to pypi

make upload

Test direct device interaction using serial terminal

make guix-dev-container-port-serial # PORT=/dev/ttyACM0
# make PORT=/dev/ttyACM1 guix-dev-container-port-serial
? # help
[C-a][C-x] # to exit

Docker

Install Docker Engine

https://docs.docker.com/engine/

Develop Python package

make docker-dev-container
exit

Test Python package using ipython shell

make docker-dev-container-ipython
import arena_interface
exit

Test Python package installation

make docker-container
exit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arena_interface-3.0.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

arena_interface-3.0.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file arena_interface-3.0.0.tar.gz.

File metadata

  • Download URL: arena_interface-3.0.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.11

File hashes

Hashes for arena_interface-3.0.0.tar.gz
Algorithm Hash digest
SHA256 c025bcc75cee40621165d22f74e5c5d99229c8bf270e22ca2c6bd288acbab18a
MD5 efb00cef4745444ed61ef6274f0218a5
BLAKE2b-256 2590523f863766478b1ef55e1c50b84f502a40752fb94df14be4fff33cc7bab7

See more details on using hashes here.

File details

Details for the file arena_interface-3.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for arena_interface-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbf9935d25f9049794a3c9b75db7e9a9f6a3349917a1f4028f11d3cf6f55f8b7
MD5 a0aba3224c3aa9fb14c579038002e8d5
BLAKE2b-256 b8bd58b42086eccdabad413602b4ccde178399f1a7ad75e03c82cdf018dbcdc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page