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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 2 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