Skip to content

MurineShiftWork/pypulsepal

Repository files navigation

PyPulsePal

PyPI Ruff

Python API for the PulsePal open-source pulse train generator.

→ Full documentation

Example usage

Load and apply a saved config file:

from pypulsepal import PulsePal
from pypulsepal.config_io import load_config

cfg = load_config("my_params.json")   # or .yaml
with PulsePal.from_config(cfg, serial_port="/dev/ttyACM0") as pp:
    pp.trigger_selected_channels(channel_1=True)

Standard instantiation:

import time
from pypulsepal import PulsePal

pp = PulsePal(serial_port="/dev/ttyACM0")
pp.channel_configs[0].phase1Voltage = 5.0
pp.channel_configs[0].pulseTrainDuration = 1.0
pp.sync_all_params()
pp.trigger_selected_channels(channel_1=True)
time.sleep(1)
pp.stop_all_outputs()
pp.close()

As a context manager (saves settings and closes on exit automatically):

import time
from pypulsepal import PulsePal

with PulsePal(serial_port="/dev/ttyACM0") as pp:
    pp.channel_configs[0].phase1Voltage = 5.0
    pp.channel_configs[0].pulseTrainDuration = 1.0
    pp.sync_all_params()
    pp.trigger_selected_channels(channel_1=True)
    time.sleep(1)
    pp.stop_all_outputs()

Installation

pip install pypulsepal

With YAML config file support:

pip install "pypulsepal[yaml]"

From source:

git clone https://github.com/murineshiftwork/pypulsepal.git
cd pypulsepal
pip install -e ".[yaml]"

Citation

To cite PyPulsePal, reference the GitHub repository:

Rollik, Lars B. PyPulsePal: Python API for the PulsePal open-source pulse train generator. https://github.com/murineshiftwork/pypulsepal

Please also cite the original PulsePal hardware and PyBpod publications that this package builds on.

License & sources

This software is released under the GNU GPL v3.0.

This work is derived from the Sanworks PulsePal Python API (commit: 5bb189f).

src/pypulsepal/_arcom.py is vendored from pybpod-api 1.8.2 (MIT, Copyright © 2016 Champalimaud Foundation) with minor adaptations.

Useful references

Packages

 
 
 

Contributors

Languages

Generated from larsrollik/templatepy