Skip to main content

Single Molecule Trajectory Analysis: With MSD and Angle Modules

Project description

Alt text

SPT(Single Particle Tracking)Analysis

A Python module for calculating and analyzing Mean Square Displacement (MSD) and trajectory angles from particle tracking data. This module provides robust tools for both ensemble and individual track analysis, with support for various statistical calculations and data transformations.

Features

MSD Analysis

  • Calculate MSD for individual tracks and ensemble averages
  • Support for multi-dimensional tracking data (2D/3D)
  • Flexible unit conversion (pixels to microns, frames to seconds)
  • Bootstrap analysis capabilities
  • Built-in error calculation and statistical analysis

Angle Analysis

  • Calculate trajectory angles between consecutive segments
  • Ensemble and individual track angle distributions
  • Asymmetry metrics for directional analysis
  • Flexible track length filtering

Installation

PyPi

  1. Run:
pip install sptanalysis

Usage

MSD Analysis

# Initialize with track dictionary
track_dict = {
    "track1": [[x1,y1], [x2,y2], ...],
    "track2": [[x1,y1], [x2,y2], ...]
}

msd_calc = MSD_Calculations_Track_Dict(
    track_dict,
    pixel_to_um=0.13,
    frame_to_seconds=0.02
)

# Access results
ensemble_msd = msd_calc.individual_store.ensemble_MSD
track_msds = msd_calc.individual_store.track_MSD

Default does not consider bootstrap for errors, rather uses SEM. For bootstrap:

msd_calc = MSD_Calculations_Track_Dict(
    track_dict,
    pixel_to_um=0.13,
    frame_to_seconds=0.02,
    bootstrap=True,
    bootstrap_samples=0.1,
    bootstrap_percentile=0.9,
    bootstrap_num=100,
)
# Initialize angle calculations
angle_calc = Track_Calculations_Individual_Dict(
    track_dict,
    pixel_to_um=0.13,
    frame_to_seconds=0.02,
    min_track_length=3
)

# Access angle results
ensemble_angles = angle_calc.individual_store.ensemble_angles
track_angles = angle_calc.individual_store.track_angles

# errors for the above
ensemble_angles_error = angle_calc.individual_store.ensemble_angles_error
track_angles_error = angle_calc.individual_store.track_angles_error


# Calculate asymmetry metric
asymmetry = asymmetry_metric(
    angle_distribution=ensemble_angles[0],  # angles at tau=0
    forward_angle_range=np.array([0, np.pi/2]),
    backward_angle_range=np.array([np.pi/2, np.pi])
)

Notes

  1. The module assumes sequential tau values for MSD calculations
  2. Angle calculations require a minimum of 3 points per track
  3. Angle measurements are in radians
  4. Asymmetry metrics are bounded between -1 and 1
  5. All calculations support unit conversions from pixels to physical units

Data Structure

Track Dictionary Format

track_dict = {
    "track_ID": [[x1,y1], [x2,y2], ...],
    ...
}

or if including z values:

track_dict = {
    "track_ID": [[x1,y1,z1], [x2,y2,z2], ...],
    ...
}

Angle Analysis Output

{
    "ensemble_angles": {tau: [angles...]},
    "track_angles": {track_ID: {tau: [angles...]}},
    "track_storage": {track_ID: [[x,y]...]}
}

Contributing

When contributing to this module, please ensure:

  1. Any modifications maintain backward compatibility
  2. New features are properly documented
  3. Test cases are included for new functionality

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

sptanalysis-0.1.1.tar.gz (42.4 kB view details)

Uploaded Source

Built Distribution

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

sptanalysis-0.1.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file sptanalysis-0.1.1.tar.gz.

File metadata

  • Download URL: sptanalysis-0.1.1.tar.gz
  • Upload date:
  • Size: 42.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sptanalysis-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cb299294781722a4092b215a46f23a141ac550120d7c1e5500a162e37d3696f1
MD5 b4601f2720e72853dc79ad77dc9dc880
BLAKE2b-256 198fbe870b31f91aca53459df26934539d88704bacacb5817b50a6d5c3a6fe1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sptanalysis-0.1.1.tar.gz:

Publisher: pypi_publish.yml on joemans3/SPTanalysis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sptanalysis-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sptanalysis-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sptanalysis-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f62074c83e914f61bcfaf0d32ea41abaeaf1a2d6396d15a76b3535ef99916e74
MD5 cfa1099b2eb71fb1aa3b7d11b5cbc3b5
BLAKE2b-256 f02f35abea47ed48c57d899925b1c94144c5adf20990b998fc9dcb81ae76c75d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sptanalysis-0.1.1-py3-none-any.whl:

Publisher: pypi_publish.yml on joemans3/SPTanalysis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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