neurogears / ranson-rig

An interactive visual stimulation rig controllable by OSC using Bonsai and BonVision
MIT License
0 stars 2 forks source link

ranson-rig

An interactive visual stimulation rig controllable by OSC using Bonsai and BonVision

Installation

  1. Clone or download this repository
  2. Run the setup.cmd script in the bonsai folder
  3. Run Bonsai.exe

How to use

  1. Open ranson-rig.bonsai in the src/workflows folder
  2. Open osc-test.py in the src/python folder
  3. Start the Bonsai workflow
  4. Run the python script to go through a demo sequence of trials

Protocol

The communication interface between Python/MATLAB and the stimulation rig is built on top of the OSC real-time protocol over UDP.

A sequence of messages is used to setup the stimuli for each trial, followed by a start message for each trial type. The existing messages and their parameters are detailed below.

Data Storage

Data storage messages control where logged data is recorded, and specify session and trial identifiers to enable replay of trials in open loop mode.

Dataset

This message specifies the root of the dataset, i.e. the volume and file path prefix where all the data will be stored. Replay of trials is only allowed within the same dataset.

Experiment

This message specifies the start of a new session, and provides metadata about animal ID and session start time.

Preloading

Preloading messages control the explicit state of the stimulus cache for heavy stimuli. This allows the experimenter to control when exactly resources are loaded and cleared from memory.

Resource

This message declares a new resource in the active set to preload. The resource is not preloaded until the entire set is preloaded.

Preload

Signals that the active resource set should be preloaded into memory.

Clear

Signals that all currently preloaded sets should be cleared and unloaded from memory.

Stimulus Control

Stimulus control includes messages used to setup various stimulus in the passive and go/nogo tasks. They can include both visual and non-visual stimulation, including sine gratings, videos, and later audio and other stimulation types.

Replay

This message triggers replay of the specified session and trial number. The dataset is searched for the correct trial, and all metadata used to construct the trial information is used to reconstruct trial conditions. All input data such as wheel movements or licks are replayed following their originally recorded timing.

Gratings

Defines a fully parameterized grating stimulus.

Video

This stimulus type implements visual stimulation with an arbitrary image sequence, loaded from a file or folder with images with the following naming convention frame-***.bmp (or other compatible image format). Multiple videos can play simultaneously and each instance can be parameterized individually with different orientation, position, speed and onset/duration.

Pulse Valve

This stimulus type implements a single pulse on the water valve output. Pulse duration must be specified manually in the Behavior board GUI.

Start

This message immediately plays the current stimulus set as a passive stimulation trial.

Success

This message sets the current stimulus set to be played on positive outcomes of operant trials.

Failure

This message sets the current stimulus set to be played on negative outcomes of operant trials.

Go/NoGo Task

The Go/NoGo module controls the basic task structure of all Go/NoGo tasks. The general sequence is:

  1. Pre-stimulus period
  2. Stimulus sequence (t0)
  3. Response window (t0 + tResponse)
  4. Outcome (Hit, Miss, FalseAlarm, CorrectReject) depending on trial type

Go

This message starts a go trial with general control parameters.

NoGo

This message starts a no-go trial with general control parameters.

Maze Control

Maze control includes messages used to specify the positioning of tiles in the VR corridor, and the individual interactions for each tile. Messages should be arranged hierarchically: all interactions for a tile should be declared before the tile declaration; and all the tiles should be declared before the corridor is started. See Python and MATLAB examples for more details.

Interaction

The interaction message specifies one interaction which should be active for the next tile.

Available interactions and their argument types:

Tile

Specifies the position, extent and appearance of a single portion of the corridor walls. Tiles can be specified in all four walls, or set to face the front of the subject. They can also be made invisible and used for interaction only.

Corridor

This message starts a virtual corridor trial but also defines certain general properties of the corridor, such as its length, width and height (wall separation), and the starting location and viewpoint.