Skip to main content

pypulsepal

Project description

DOI Website PyPI Wheel Code style: black

PyPulsePal

Python API for the PulsePal open-source pulse train generator

This package provides an API to the PulsePal hardware. This API is a re-implementation of the original PulsePal Python 3 API that draws from the pybpod-api communication protoool.

Example usage

script/function

from pypulsepal import PulsePal

serial_port = "/dev/ttyACM0"  # for unix or "COM"-style port names for Windows

# Create PulsePal object
pp = PulsePal(serial_port=serial_port)

# Set parameters

## Manually
pp.program_one_param(channel=2, param_name="phase1Duration", param_value=.002)

## Via convencience functions
pp.set_resting_voltage(channel=2, voltage=4.2)

# Upload parameters
pp.upload_all()

# Trigger channels
pp.trigger_selected_channels(channel_2=True, channel_4=True)
pp.trigger_all_channels()

# Stop outputs
pp.stop_all_outputs()

# Save settings (also done automatically on disconnect)
pp.save_settings()

as context manager

import time
from pypulsepal import PulsePal

with PulsePal(serial_port="/dev/ttyACM0") as pp:
    # set params
    pp.upload_all()

    # do something
    time.sleep(2)

Write default params to all channels

from pypulsepal.write_tests import write_default_settings

write_default_settings(serial_port="/dev/ttyACM0")

Write (funky) test params to all channels

from pypulsepal.write_tests import write_test_settings_for_manual_check

write_test_settings_for_manual_check(serial_port="/dev/ttyACM0")

Installation

pip

pip install pypulsepal

git

git clone https://github.com/larsrollik/pypulsepal.git
cd pypulsepal/
pip install -e .

pip + git

pip install git+https://github.com/larsrollik/pypulsepal.git

Problems & issues

Please open issues or pull-requests in this repository.

Citation

Please cite the original PulsePal and PyBpod code and publications that this package is based on.

To cite PyPulsePal with a reference to the current version (as publicly documented on Zenodo), please use:

Rollik, Lars B. (2021). PyPulsePal: Python API for the PulsePal open-source pulse train generator. doi: --doi--.

BibTeX

@misc{rollik2022pypulsepal,
    author       = {Lars B. Rollik},
    title        = {{PyPulsePal: Python API for the PulsePal open-source pulse train generator}},
    year         = {2022},
    month        = mar,
    publisher    = {Zenodo},
    url          = {https://doi.org/--doi--},
    doi          = {--doi--},
  }

License & sources

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

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

The architecture of the API is imported and inspired by the pybpodapi.com.arcom module from the pybpod-api.

For changes from the original implementation, see the git history since commit 972bc1e.

Useful code references

TODO

  • Simplify parameter dicts in definitions: into nested dict with first level for name, then standard sub-dict (default value, dtype, dtype legacy(model 1), scaling, )
  • Complete API functions with all PulsePal opcodes, e.g. for Arduino logic levels (see PulsePal USB v2 opcode list)
  • Move PulsePal hardware settings to init and remove defaults for easier upgrade in future
  • API function to accept list of dicts (from json settings file)
    • to make overwrites on channels to get from value-based logic to channel parameter sets
    • add write function to save all settings to json for documentation

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

pypulsepal-0.0.1.tar.gz (48.8 kB view hashes)

Uploaded Source

Built Distribution

pypulsepal-0.0.1-py3-none-any.whl (33.7 kB view hashes)

Uploaded Python 3

Supported by

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