Skip to main content

Tools for neuroscience experiments

Project description

toon

image image image image image

Description

Additional tools for neuroscience experiments, including:

  • A framework for polling input devices on a separate process.
  • A framework for animating elements.

Everything should work on Windows/Mac/Linux.

See requirements.txt for dependencies.

Install

Current release:

pip install toon

Development version:

pip install git+https://github.com/aforren1/toon

For full install (including dependencies of included devices):

pip install toon[full]

See setup.py for a list of those dependencies, as well as device-specific subdivisions.

Usage Overview

Input

This module allows us to sample from external devices on a secondary process at high rates, and efficiently move that data to the main process via the multiprocessing module.

Generally useful input devices include:

  • Keyboard (for changes in keyboard state) via Keyboard
  • Mouse (for mouse position) via Mouse

The following are in-house devices, which may not be generally useful but could serve as examples of how to implement additional devices:

  • HAND (custom force measurement device using hidapi) via Hand (for pyusb example, see USBHand)
  • Force Keyboard (predecessor to HAND) via ForceKeyboard (Windows only, due to nidaqmx requirement.)
  • Flock of Birds (the 1992 vintage from Ascension) via Birds (very specific to the KineReach setup in the BLAM Lab)
  • CyberGlove I (I think? Immersion Corp. branding) via Cyberglove

Generally, input devices can be used as follows:

from toon.input import MpDevice
import <device>

dev = MpDevice(<device>, <device-specific kwargs>)

with dev:
    while not done:
        data = dev.read()
        if data.any():
            pass # do something with the data
        ...

See the demos/ folder or snippets in the source of individual devices for usage examples.

Animation

The anim module was derived from Magnum (though I currently don't implement as many features). See here for background.

A quick example:

from time import sleep
from toon.anim import Player
from toon.anim import Track
from toon.anim import Timeline
from toon.anim.easing import elastic_in

class Circle(object):
    x = 0
    y = 0

circle = Circle()
keyframes = [(0, 0), (0.5, 0.8), (1.0, 1.0)]
track = Track(keyframes, easing=elastic_in)
player = Player()
player.add(track, 'x', circle)

timeline = Timeline()
timeline.start()
player.start(timeline.frame_time)

while timeline.frame_time < 2:
    timeline.next_frame()
    player.update(timeline.frame_time)
    print(circle.x)
    # flip window
    sleep(0.016)

See the demos/ folder for a more thorough example including integration with psychopy.

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

toon-0.11.2.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

toon-0.11.2-py2.py3-none-any.whl (23.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file toon-0.11.2.tar.gz.

File metadata

  • Download URL: toon-0.11.2.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for toon-0.11.2.tar.gz
Algorithm Hash digest
SHA256 3ddad8f8da71b0357a6c88b160bbbc40d2380c1af976de30be8746694fe9c807
MD5 bf8d2accbda10697eb10ccf2b304b0ab
BLAKE2b-256 669f869a5185c55e26ac467fa824870e1bbfe3a8780191d22f92ea124043275b

See more details on using hashes here.

File details

Details for the file toon-0.11.2-py2.py3-none-any.whl.

File metadata

  • Download URL: toon-0.11.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for toon-0.11.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 36f793eb1a03700105141ea757d18b1b529f0a16df7d7bf272a26cb1ebd0a3d7
MD5 222ad4461b127af8329521a5395fa57e
BLAKE2b-256 03b8ee655a8e68cfe4fce7f74ac4fa5b9f14bb8877963b64a03d2a61fb4cfc9f

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