-
Notifications
You must be signed in to change notification settings - Fork 19
Home
The tracking-plugin repository contains everything you need to integrate animal tracking in open-field experiments in the Open Ephys system (http://www.open-ephys.org/). We also provide a Bonsai script (http://bonsai-rx.org/) to extract LED position from a Pointgrey camera and input the tracking data in the Open Ephys GUI.
To install the plugin, copy the Tracking folder in the Sources/Plugins
folder of the Open Ephys GUI and follow these steps: Installation - Open Ephys GUI
The Tracking Port plugin allows to stream tracking data into the GUI. The data are streamed from an OSC (Open Sound Message) server and each packet contains 4 floats: x, y positions, width, and height of the field.
Add and delete new sources using the +
and -
buttons. Set the port, address, and choose the color from the dropdown list of colors available.
Note that the Tracking Port only support 'localhost' at the moment.
The Tracking Visualizer displays the tracking data received from the Tracking Port (or any other plugin sending Tracking Data binary events) in real-time. The available Tracking Data sources are shown in the Sources
list box on the left and multiple selection is allowed. The clear
button clears the path trajectories. Note that by clicking the clear
button the data are not lost, as they are saved by the Tracking Port plugin.
In the figure we show a simulated spiral-like trajectory.
The Tracking Stimulator plugin allows to perform tracking-based closed-loop experiments. It is originally design to stimulate place cells and grid cells inside or outside their field with electrical or optogenetics stimulation.
The user can manually draw, drag, resize (double click), copy (ctrl+c
), paste (ctrl+v
), and delete (del
) circles, or can input circles information (x_position, y_position and radius - from 0 to 1) using the editable labels on the right. Each circle can be inactivated using the ON
toggle button.
On the top right, the user can decide which source to track - Input source
dropdown list - and which TTL output channel to trigger - Output channel
dropdown list - when the current position is within the selected circles.
Stimulation is triggered ONLY when the toggle button in the editor (bottom left) is set to ON.
When within the selected circles, the tracking cue becomes red and TTL events are generated on the selected Output channel
. There are two operation modes controlled by the buttons UNIFORM
- GAUSS
:
-
UNIFORM stimulation: a TTL train with a constant frequency
fmax
(user-defined) is generated when the position is within selected regions. In this mode, the colors of the circles are uniformly orange/yellow.
-
GAUSSIAN stimulation: the frequency of the TTL train is gaussian modulated. When the position is in the center of each circle, the frequency is
fmax
, when it is on the border of a circle the frequency issd
*fmax
. In the case displayed in the following figure, the frequency in the center is 2 Hz and the frequency on the borders is 0.5 * 2 = 1 Hz. In this mode, the colors of the circles are graded, darker in the center and lighter on the borders.
The Bonsai scripts that we provide are relatively plug-and-play. Install Bonsai and start tracking.bonsai
script. You will need to install the following libraries with the package manager:
- Vision Library
- Vision Design Library
- PointGrey
- Osc Library
- Osc Design Library
- Scripting Library
When you launch the tracking.bonsai
script this is the workflow. It basically processes the image to extract a green and a red LEDs. If you have different colors you can change the Green and Red nodes. Then the centroid of the largest area of green and red pixels are packed together and sent via OSC signals (Open sound Control).
We provide a second script (osc.bonsai
) which sets up two OSC ports:
- RedPort: port=27020, address='/red', ip_address='localhost'
- GreenPort: port=27021, address='/green', ip_address='localhost'
You can change, add, remove ports from the right panel as shown in the next figure.
Press play to start acquiring camera frames and to send them to the Open Ephys GUI.
We suggest to you record your data using the binary RecordEngine in the Open Ephys. For that we provide a Python library, in the called pyopenephys.py
.
In order to install it run these commands from the terminal:
cd py-open-ephys
python setup.py install
It takes only a few lines of code to parse a recorded Open Ephys binary file:
import pyopenephys
file = pyopenephys.File("path-to-recording-folder")
# experiment 1 (0 in Python)
experiment1 = file.experiments[0]
# recording 1
recording1 = experiment1.recordings[0]
analog_signals = recording1.analog_signals
events_data = recording1.events
tracking_data = recording1.tracking
# plot tracking source 1
import matplotlib.pylab as plt
source_1 = tracking_data[0]
plt.plot(source_1.x, source_1.y)