Giter Club home page Giter Club logo

gem's Introduction

GEM (Groove Enhancement Machine)

gem

About

This is a repository for code associated with the NAKFI Groove Enhancement Machine (GEM) project led by Petr Janata at UC Davis.

The GEM consists of a set of Arduinos that communicate with each other and with a computer running experiment control software written in Python.

The "Metronome" Arduino functions as the adaptive metronome and communicates with the computer. A force-sensitive resistor (FSR) is connected to each of the other Arduinos, the "Tapper" Arduinos, utilizing a scheme first described by Schulz & van Vugt (2016). The Tapper Arduinos communicate tap events via interrupts to the Metronome Arduino which adjusts the time of the next metronome tone based on the individual tap times and parameters that have been communicated from the experiment control computer (ECC).

Further instructions and project information can be found in the Wiki.

Overview

Directories

GEM

Contains the C++ files that make up the GEM library.

GUI

Contains the python files that comprise the graphical user interface, run on the experiment control computer.

Master_Adaptive

Contains the sketch that is downloaded to the Master Arduino.

Slave_Adaptive

Contains the sketch that is downloaded to the Slave Arduino.

Dependencies

Although the project was originally developed to run on Python 2, it has been ported to Python 3. The first release version has been tested using:

  • macOS 12.2.1 (Monterey)
  • Python 3.10.0
  • Arduino IDE 1.8.19

This project depends on the following third-party libraries which you should install in your system's Arduino/libraries folder following the instructions at http://www.arduino.cc/en/Guide/Libraries:

  • WaveHC (<=1.0.2)
  • EnableInterrupt (originally developed using EnableInterrupt library version 0.9.5, but this appears not to be working properly in the newer version)

Instructions

Detailed installation instructions are available in the wiki.

By default, the Arduino software expects to see project directories in the Arduino directory, e.g. /Users/janatalab/Documents/Arduino. The path can be set under the Arduino->Preferences...

Arduino libraries are located within a directory called "libraries", as are any libraries that are installed in support of a project, such as the third-party libraries listed above.

We recommend either cloning the repository within the Arduino directory or creating a symbolic link (symlink) to the git repository location.

Within the Arduino libaries directory, make a symbolic link to this repository's GEM directory which contains the GEM library.

After launching a Python virtual environment, e.g. virtualenv, that you have created for this project, install the required Python files using the requirements.txt file in the GUI directory.

See the Wiki for further setup instructions.

Citations

Schultz, B. G., & van Vugt, F. T. (2016). Tap Arduino: An Arduino microcontroller for low-latency auditory feedback in sensorimotor synchronization experiments. Behavior Research Methods, 48(4), 1591–1607. https://doi.org/10.3758/s13428-015-0671-3

The GEM was originally described and published in the following paper:

Fink, L.K., Alexander, P.C., & Janata, P. (2022). The Groove Enhancement Machine (GEM): A multi-person adaptive metronome to manipulate sensorimotor synchronization and subjective enjoyment. Front. Hum. Neurosci. 16:916551. doi: 10.3389/fnhum.2022.916551

Please cite the paper if using anything from this repository.

Note that more information about the proof-of-concept experiments reported in the paper is available in a separate git repository: https://github.com/janatalab/GEM-Experiments-POC

gem's People

Contributors

janatalab avatar lkfink avatar scottiealexander avatar pjanata avatar

Stargazers

Max Vo avatar Søren Lyhne avatar  avatar

Watchers

Wisam Reid avatar  avatar  avatar  avatar  avatar

gem's Issues

Synchronize constants between Arduino and GUI code

This is just a formal reminder to @lkfink and I that we need to implement a simple constant parsing routine in python so that the GUI uses the correct constants (some assumptions might be necessary, but see below).

Just a thought, but we could potentially save ourselves even more trouble by defining a magic number that we increment each time GEMConstants.h is changed, that way the GUI can query the master Ardunio for the version that its code was compiled with and check that against the file that it parses (throwing an error on mismatch). Of course we'd still have to remember to update the magic number...

Define message structure for data messages from Master Arduino to ECC

We need to be able to send and log timestamped events from the Master Arduino to the Experiment Control Computer (ECC) via the serial (USB) connection. Communication needs to happen at a high baud rate, e.g. 115200. The messages need to be structured in order to identify the data that is being transmitted: they need timestamps and identifiers.

Timestamps are obtained using the millis() command
Event codes should be defined in GEMconstants.h

GUI Data Viewer - Data Visualization

This is a very far off enhancement but just wanted to start a discussion about the eventual data visualization in the data viewer.

Initially I imagined an electrophysiology-like viewer with lines for each of the slave channels displaying a tick any time anyone tapped and then vertical full screen lines for windows (gray) and metronome (black), with slaves all having their own color.

However, yesterday Petr mentioned wanting to know the stdev in real time and it occurred to me that we could use something like visual python to have a pulsing circle or 3D ball that would get narrower or wider depending on error. I came across this (really in depth) arduino and Vptyon tutorial while searching for something else yesterday and wanted to archive it here before I lose it.

Arduino + Visual python: http://www.toptechboy.com/using-python-with-arduino-lessons/

Vpython: http://vpython.org/

Petr & Scottie, What do you think would be the best type of visualization? We can use this thread for brainstorming and keeping track of resources.

Master Ardunio state system v0.0.0

I'm opening an issue on this for discussion purposes, it's not really an issue per se, as I wanted to highlight the direction I'm going in order to 1) provide a note to @lkfink so she can get a sense of what needs to happen in the GUI system to set parameters on the master Arduino (and have it actually start a run etc.) and 2) so that the design can be looked at by all. Note that this is experimental (thus i moved it to a new branch: dev-stateful). Changes are summarized below:

  1. Constants system

    • Each family of constants has their own (small) range, see GEMConstants.h for details
    • Added constants for state logic found in Master_Adaptive.ino
  2. Master Arduino state system

    • the loop() function now simply checks the global GEM_CURRENT_STATE and calls the corresponding state function (either run() or idle() etc.)
    • each state function is responsible for transitioning based on messages from the ECC
    • the run() function is essentially just a copy of the old loop() function
    • the idle() function allows for setting parameters (so far just met.alpha and met.bmp/ met.ioi), as well as more verbose communication (that is currently a TODO)

In short: the master Arduino boots in the IDLE state, runs the setup() function etc., then waits for messages from the ECC and parses them (setting parameters as requested etc.). Once the ECC requests a transition to the RUN state (by sending the constant GEM_STATE_RUN) loop() will begin calling the run() function instead; however, the metronome will not start until GEM_START is received (i.e. after the transition to the RUN state). Stopping the metronome immediately returns us to the IDLE state, requiring the ECC to send GEM_STATE_RUN followed by GEM_START to restart the metronome etc. This prevents state transitions while the metronome is playing. As it stands the system is a little clunky, but as stated above it's experimental.

General / design related comments are welcome. All implementation details should be considered as preliminary / alpha versions. Ultimately, a robust stateful design is what was/is planed for the lkfink-patch-1 branch, so that will, time permitting, function as a version 2.0 of this system in the future.

Update wiring diagram

We need to update/fix the existing wiring diagram and annotate it with resistor values, etc. The current diagram appears to have errors in it, insofar as resistors between ground and FSR that should be the same are not, in fact, the same. They should be 10 kOhm. Not quite sure what the value is or should be for the pullup resistors on the interrupts because I can't find any circuit documentation in the Google Drive folders. (Because circuit.io appears to have been bought by Autodesk, the designs we created and linked to in our Google Doc are lost forever - a reminder that external links are rarely stable.)

Also, the resistors populating the actual GEM rig are not the same as what is on the diagram. The actual values being used are:

  • for connections to ground: 47k (yellow, violet, orange)
  • for interrupt pullups: 3.1k (orange, brown, red)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.