Skip to main content

A package to easily open trx.mat files in use at the Decision & Bayesian Computation lab at the Pasteur Institute in Paris

Project description

pytrxmat

Overview

pytrxmat is a Python package designed to facilitate the access and manipulation of data stored in trx.mat files commonly used in behavior screens. These files contain raw tracking data and postprocessing results for multiple larvae in experimental studies. Installation

pip install pytrxmat

Usage

TRX Class

The main component of pytrxmat is the TRX class, which provides a convenient interface to interact with trx.mat files.

Initialization

from pytrxmat.trx import TRX

# Instantiate the TRX class with the path to your 'trx.mat' file
trx = TRX('path/to/trx.mat')

Accessing Fields

The TRX class allows you to retrieve various fields from the trx.mat file, including scalar, string, time series, and composite array fields.

Scalar Fields

# Get a scalar field (e.g., 'numero_larva_num')
scalar_data = trx.get('numero_larva_num')

Time Series Fields

# Get a time series field (e.g., 'x_tail')
time_series_data = trx.get('x_tail')

Composite Array Fields

# Get a composite array field (e.g., 'duration_large')
composite_array_data = trx.get_composite_array('duration_large')

String Fields

# Get string fields (e.g., 'neuron' and 'protocol')
string_data = trx.get_string(['neuron', 'protocol'])

The Repository class

The class repository.Repository is meant to be a thin wrapper above the directory tree used to orgnaize the data.

It is initialized by providing the path to the directory containing the tracker folders, and a list of trackers to open. Once the repository is built, we can access different subsets of the data using indexing, or use iterators to loop through all the data.

from repository import Repository
from pathlib import Path

repo = Repository(Path('/home/hephaistos/screen'), ['t5', 't15'])
trx = repo['t5']['FCF_attP2_1500062@NoEffector_0_9999']['p_8_45s1x30s0s#p_8_105s10x2s10s#n#n@100']['20120224_084329'].trx

protocol = repo['t5']['FCF_attP2_1500062@NoEffector_0_9999']['p_8_45s1x30s0s#p_8_105s10x2s10s#n#n@100']
for trx in protocol.trx():
    process(trx)

for trx in repo.trx():
    process(trx)

for protocol in repo.protocols():
    process(protocol)

line = repo['t5']['FCF_attP2_1500062@NoEffector_0_9999']
for protocol in line.protocols():
    process(protocol)

Two caveats :

  1. The hierarchy goes Tracker > Line > Protocol > DateTime. This is set by the organization of the folders.

  2. If you jump levels in the hierarchy by using an iterator, you won't be able to easily figure out where the data is coming from, unless you parse the path attribute. Instead, you could use nested for loops

File Format

The trx.mat file format is a standardized way of storing experimental data in the Decision and Bayesian Computation lab at the Pasteur Institute. The file contains multiple fields, each corresponding to different aspects of the larvae's behavior. The fields include univariate and multivariate time series, classification labels and probabilities, behavior summaries, and metadata such as full paths, IDs, and neuron information.

Contribution

Contributions to this project are welcome. Feel free to open issues for bug reports or feature requests. If you'd like to contribute code, please submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytrxmat-0.0.5.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytrxmat-0.0.5-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file pytrxmat-0.0.5.tar.gz.

File metadata

  • Download URL: pytrxmat-0.0.5.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for pytrxmat-0.0.5.tar.gz
Algorithm Hash digest
SHA256 3fcd3048dc79de532b5135e6352d571ca1f0694a95b0be6f5fd5cda4970bc08f
MD5 6cfb7ebce741b15025ccd1677d118e66
BLAKE2b-256 0e9ea0b92ce84def33b7578c44a254d2e5566c39e72d4b631457b52ca58cc60b

See more details on using hashes here.

File details

Details for the file pytrxmat-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: pytrxmat-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for pytrxmat-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f0308c759f3d85d061e51c8a606d700e8bb8de1e9446b54de68c8622723894e4
MD5 7d1b7b1ba156c3e97260aa1687a1cd3f
BLAKE2b-256 dc47ce7436fe0b254db226f5ad365e2aa95a7ff5b98eb119dffc222c244c4df8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page