Python interface to the Dudman lab Mouse Joystick Rig.
Project description
About
- Python Package Name: mouse_joystick_interface
- Description: Python interface to the Dudman lab Mouse Joystick Rig.
- Version: 5.0.1
- Python Version: 3.10
- Release Date: 2023-12-05
- Creation Date: 2023-10-17
- License: BSD-3-Clause
- URL: https://github.com/janelia-pypi/mouse_joystick_interface_python
- Author: Peter Polidoro
- Email: peter@polidoro.io
- Copyright: 2023 Howard Hughes Medical Institute
- References:
- https://github.com/janelia-kicad/mouse_joystick_controller
- Dependencies:
- modular_client
- flatten_json
Example Usage
Python
from mouse_joystick_interface import MouseJoystickInterface
dev = MouseJoystickInterface() # Might automatically find devices if available
# if devices not found automatically, specify ports directly
dev = MouseJoystickInterface(use_ports=['/dev/ttyACM0','/dev/ttyACM0']) # Linux specific ports
dev = MouseJoystickInterface(use_ports=['/dev/tty.usbmodem262471','/dev/tty.usbmodem262472']) # Mac OS X specific ports
dev = MouseJoystickInterface(use_ports=['COM3','COM4']) # Windows specific ports
# abort_assay prematurely stops a running assay and leaves the rig ready to start a new assay
dev.abort_assay()
# start_assay is the main method that starts the assay, collects assay data, and saves data files
dev.start_assay(set_path='~/set_example.csv')
# optional mouse_joystick_controller methods
dev.mouse_joystick_controller.set_properties_to_defaults(['ALL'])
dev.mouse_joystick_controller.get_property_values(['ALL'])
dev.mouse_joystick_controller.repeat_aborted_trial('setValue',False)
dev.mouse_joystick_controller.get_assay_status()
dev.mouse_joystick_controller.move_joystick_to_base_position()
dev.mouse_joystick_controller.move_joystick_to_reach_position()
duration = 10
count = 1
dev.mouse_joystick_controller.activate_lickport(duration,count)
dev.mouse_joystick_controller.get_trial_timing_data()
dev.mouse_joystick_controller.abort_trial()
Command Line
Example Set CSV Input File
repeat\_trial\_count,pull\_torque,lickport\_reward\_duration,zero\_torque\_reward\_delay,reach\_position.0,reach\_position.1
2,50,100,0,20,200
3,75,120,0,30,300
2,0,100,3,5,200
Example Trials CSV Ouput File
finished\_trial\_count,successful\_trial\_count,trial\_aborted,assay\_aborted,pull\_threshold,set\_in\_assay,repeat\_set\_count,block\_in\_set,block\_count,trial\_in\_block,block.repeat\_trial\_count,block.pull\_torque,block.lickport\_reward\_duration,block.zero\_torque\_reward\_delay,block.reach\_position.0,block.reach\_position.1,trial\_start,mouse\_ready,joystick\_ready,pull,push,timeout,trial\_abort
Installation
https://github.com/janelia-pypi/python_setup
GNU/Linux
-
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:
-
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
-
Restart udev management tool
sudo service udev restart
-
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
-
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.
-
pip
python3 -m venv ~/venvs/mouse_joystick_interface source ~/venvs/mouse_joystick_interface/bin/activate pip install mouse_joystick_interface
-
guix
Setup guix-janelia channel:
https://github.com/guix-janelia/guix-janelia
guix install python-mouse-joystick-interface
Windows
Python Code
The Python code in this library may be installed in any number of ways, chose one.
-
pip
python3 -m venv C:\venvs\mouse_joystick_interface C:\venvs\mouse_joystick_interface\Scripts\activate pip install mouse_joystick_interface
Development
Clone Repository
git clone git@github.com:janelia-pypi/mouse_joystick_interface_python.git
cd mouse_joystick_interface_python
Guix
Install Guix
Edit metadata.org
make -f .metadata/Makefile metadata-edits
Tangle metadata.org
make -f .metadata/Makefile metadata
Develop Python package
make -f .metadata/Makefile guix-dev-container
exit
Test Python package using ipython shell
make -f .metadata/Makefile guix-dev-container-ipython
import mouse_joystick_interface
exit
Test Python package installation
make -f .metadata/Makefile guix-container
exit
Upload Python package to pypi
make -f .metadata/Makefile upload
Test direct device interaction using serial terminal
make -f .metadata/Makefile guix-dev-container-port-serial # PORT=/dev/ttyACM0
# make -f .metadata/Makefile 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 -f .metadata/Makefile docker-dev-container
exit
Test Python package using ipython shell
make -f .metadata/Makefile docker-dev-container-ipython
import mouse_joystick_interface
exit
Test Python package installation
make -f .metadata/Makefile docker-container
exit
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file mouse_joystick_interface-5.0.1.tar.gz
.
File metadata
- Download URL: mouse_joystick_interface-5.0.1.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.9.6 requests/2.28.1 setuptools/67.6.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b75fb8e0a544b893c05566fbdfd637c3b4140e5839bfa4f550e3d67d587c0955 |
|
MD5 | d5c2ec0ae2048bc217821476312e620a |
|
BLAKE2b-256 | fa4c2d99d3baecf234dc43577a4536cc82146b66c6a56fbee2d8be22e6ea3c7e |
File details
Details for the file mouse_joystick_interface-5.0.1-py3-none-any.whl
.
File metadata
- Download URL: mouse_joystick_interface-5.0.1-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.9.6 requests/2.28.1 setuptools/67.6.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9369fc88667fbd5b008733304a72d4986ae73bb4614e8898a7d20caa9db49ccb |
|
MD5 | 6e4d2797b5bf5c2ad92334c8b732ae3f |
|
BLAKE2b-256 | 4d1abd9d7cef500fddb54197fcb15697c735beb71a67e9b4611557d18077162b |