Package 'scopr'

Title: Read Ethoscope Data
Description: Handling of behavioural data from the Ethoscope platform (Geissmann, Garcia Rodriguez, Beckwith, French, Jamasb and Gilestro (2017) <DOI:10.1371/journal.pbio.2003026>). Ethoscopes (<http://gilestrolab.github.io/ethoscope/>) are an open source/open hardware framework made of interconnected raspberry pis (<https://www.raspberrypi.org>) designed to quantify the behaviour of multiple small animals in a distributed and real-time fashion. The default tracking algorithm records primary variables such as xy coordinates, dimensions and speed. This package is part of the rethomics framework <http://rethomics.github.io/>.
Authors: Quentin Geissmann [aut, cre]
Maintainer: Quentin Geissmann <[email protected]>
License: GPL-3
Version: 0.3.3
Built: 2025-02-28 06:03:47 UTC
Source: https://github.com/rethomics/scopr

Help Index


Retrieve information about an experiment

Description

This function is used to obtain experimental information – such as time and date of the experiment, acquisition device, and version of the software – embedded in a result file (.db) generated by the ethoscope platform.

Usage

experiment_info(FILE)

Arguments

FILE

the name of the input file

Value

a list containing fields for metadata entries

See Also


List all available result files

Description

This function discovers all ethoscope result files and put them in a data.table::data.table. This is useful to figure out when and which experiments were performed.

Usage

list_result_files(result_dir, index_file = NULL)

Arguments

result_dir

the root directory where all data are saved, or the path to a remote directory.

index_file

the name of an index_file, in result_dir (needed for loading remote data).

Value

a data.table::data.table. Each row is a single experimental file, and columns describe details such as its path, start date and time, and the name and id of the ethoscope used.

See Also


Load data from ethoscope result files

Description

This function is used to import behavioural data generated by the ethoscope platform. That is it loads multiple .db files into a single R behavr::behavr table.

Usage

load_ethoscope(metadata, min_time = 0, max_time = Inf,
  reference_hour = NULL, verbose = TRUE, columns = NULL, cache = NULL,
  ncores = 1, FUN = NULL, ...)

Arguments

metadata

data.table::data.table used to load data (see detail)

min_time, max_time

load only data between min_time and max_time (in seconds). This time is relative to the start of the experiment.

reference_hour

hour, in the day, to use as ZT0 reference. When unspecified, time will be relative to the start of the experiment.

verbose

whether to print progress (a logical)

columns

optional vector of columns to be selected from the db file. Time (t) is always implicitly selected. When NULL and if FUN is set, columns can be retrieved automatically (from the attributes of FUN).

cache

the name of a local directory to cache results for faster subsequent data loading.

ncores

number of cores to use for optional parallel processing (experimental).

FUN

function (optional) to transform the data from each individual immediately after is has been loaded.

...

extra arguments to be passed to FUN

Details

the linked metadata should be generated using link_ethoscope_metadata.

Value

A behavr table. In addition to the metadata, it contains the data, with the columns:

  • id – autogenerated unique identifier, one per animal

  • t – time (s)

  • Several variables recorded by ethoscopes (position, angle, width/height and others), or computed by FUN. Distance units (e.g. xy position, height/width) are expressed as a fraction of the width of the ROI they originate from.

References

See Also

Examples

dir <- paste0(scopr_example_dir(), "/ethoscope_results/")
data(region_id_metadata)
metadata <- link_ethoscope_metadata(region_id_metadata, dir)
print(metadata)

# Default data loading
dt <- load_ethoscope(metadata)
dt

# We use reference hour to set zt0 to 09:00 GMT
dt <- load_ethoscope(metadata, reference_hour=9)
dt

# Only load x and y positions
dt <- load_ethoscope(metadata, columns=c("x", "y"), reference_hour=9)
dt
# apply function whilst loading the data
dt <- load_ethoscope(metadata, reference_hour=9, FUN=head)
dt

Simple toy metadata defining three experiments, with one condition (test) per experiment. Implicitly, 20 individuals are in each experiment It serves as a simple example.

Description

Simple toy metadata defining three experiments, with one condition (test) per experiment. Implicitly, 20 individuals are in each experiment It serves as a simple example.

Usage

no_region_id_metadata

Format

An object of class data.frame with 3 rows and 4 columns.

Author(s)

Quentin Geissmann


Simple toy metadata experimental conditions for 15 individuals in three experiments. the condition (test) is linked to the experiments, and another condition (treatment) is per individual. It serves as a simple example. #'

Description

Simple toy metadata experimental conditions for 15 individuals in three experiments. the condition (test) is linked to the experiments, and another condition (treatment) is per individual. It serves as a simple example. #'

Usage

region_id_metadata

Format

An object of class data.frame with 15 rows and 6 columns.

Author(s)

Quentin Geissmann


Get path to scopr example

Description

scopr comes with a sample DAM2 files in its inst/extdata directory. scopr_example allow make them easy to access.

Usage

scopr_example(path = NULL)

scopr_example_dir()

Arguments

path

Name of file. If NULL, the example files will be listed.

Examples

# list all files
scopr_example()