Skip to contents

Trackball experiments, in which animals are tethered/restrained atop a (most commonly) styrofoam ball are common experiments within animal behaviour and neuroscience.

There are different ways to obtain data from trackball experiments, and although we only currently support limited ways, we are looking forward to supporting all your trackball experiments!

The main interface from your data to a standardised trackball data frame is the read_trackball() function. The most common experimental setup uses two optical computer mics (or other optical flow sensors), which detects movements of the ball at different axes and is the primary experimental setup we support (although see our roadmap!). For this experiment, read_trackball() requires two file paths, one for each sensor.

You can find pairs with variations of list.files() and for-loops. We’ll go through how to use read_trackball() for a single experimental trial, as well as a few ways of managing multiple experimental trials at the same time.

The read_trackball() function

We recommend keeping your analysis scripts and data in the same project (which doesn’t mean folder), and to use the great here package package to manage your files (see their documentation to learn more about it).

First, we’ll let R know which is our project root folder.

library(here, quietly = TRUE)
#> here() starts at /home/runner/work/respirometr/respirometr
here::i_am("vignettes/articles/read-licor.Rmd")
#> here() starts at /home/runner/work/respirometr/respirometr

Our data lives in a funky place (because of the constraints of being in an R package), but giving file paths is easy.

filepath_1 <- here("tests", "data", "LI850.txt")

# These might be something like: here("data", "trackball", "sensor_1", "trackballdata_100.csv") for you!

Great, now we have our file paths. But the function needs to know a few more things.

  • Experimental configuration
    • Takes either "free" or "fixed".
  • Time column
    • Which column contains time stamps in either seconds or datetime format (takes either column number or name in quotes, e.g. 4 or "time")
  • Sampling rate
    • This can be your actual sampling rate, but we use this information to bin observations, so you can easily choose a lower sampling rate.
  • Mouse Dots-per-cm (DPCM)
    • This value is optional, but if provided is used to convert your spatial estimates from unit-less to centimeters. Can be found for most computer mice.

Let’s try to read our provided files:

df <- read_licor(
  filepath_1,
  model = "850"
)

Working with multiple experiments

When working with multiple experimental trials, there are multiple ways of reading all the data whilst keeping track of all the important information. Here we’ll cover a few ways that are supported by animovement.

Read from metadata file

When to use: File names contain little or no information.

In this scenario we use a spreadsheet to keep track of which files go together. We have an .xlsx file that contains the correct pairs of file names. Let’s begin by reading and inspecting the file.

We can then import our data, one experiment after the other. Again, we use the here package to make file management easier.

Read from file names

When to use: File names contain enough information that can be used to distinguish between experiments.

WORK IN PROGRESS!