Single Molecule Trajectory Analysis: With MSD and Angle Modules
Project description
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
- Run:
pip install sptanalysis
Usage
MSD Analysis
# Initialize with track dictionary
track_dict = {
"track1": [[x1,y1], [x2,y2], ...],
"track2": [[x1,y1], [x2,y2], ...]
}
from sptanalysis.msd import MSD_Calculations_Track_Dict
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
from sptanalysis.angles import asymmetry_metric
# 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
- The module assumes sequential tau values for MSD calculations
- Angle calculations require a minimum of 3 points per track
- Angle measurements are in radians
- Asymmetry metrics are bounded between -1 and 1
- 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], ...],
...
}
MSD Analysis Output
ensemble_msd = {"tau_value": msd_value, ... }
track_msd = {"track_ID": {"tau_value": msd_value, ...}, ... }
Similar Structure for the errors.
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:
- Any modifications maintain backward compatibility
- New features are properly documented
- Test cases are included for new functionality
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sptanalysis-0.2.0.tar.gz.
File metadata
- Download URL: sptanalysis-0.2.0.tar.gz
- Upload date:
- Size: 42.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d10c7246de1bdfd90e4869f91b01d4da32a5552bc8497f6b55464bdaae6291f
|
|
| MD5 |
44d1b2ac594617519b0e5a81631d5dad
|
|
| BLAKE2b-256 |
33baabd9f4f7320e8bd917d36da3c6c3901b3bb66393a783b39b2e0bd9d67f13
|
Provenance
The following attestation bundles were made for sptanalysis-0.2.0.tar.gz:
Publisher:
pypi_publish.yml on joemans3/SPTanalysis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sptanalysis-0.2.0.tar.gz -
Subject digest:
2d10c7246de1bdfd90e4869f91b01d4da32a5552bc8497f6b55464bdaae6291f - Sigstore transparency entry: 176944545
- Sigstore integration time:
-
Permalink:
joemans3/SPTanalysis@ad3cd8e1e2559b0c36796479690d4473e86be49f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/joemans3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@ad3cd8e1e2559b0c36796479690d4473e86be49f -
Trigger Event:
push
-
Statement type:
File details
Details for the file sptanalysis-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sptanalysis-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abd0697224e190dccc6eb1cff7da2ac3511b7e8b1aeb3188023ac2a2b4b68bcc
|
|
| MD5 |
3d18677bfea6046c97a2dbfd661565a8
|
|
| BLAKE2b-256 |
438aa0e5433b6fcd312e66c7b8b0f3a0d8e33d17a9523d8e3e16783f740ab849
|
Provenance
The following attestation bundles were made for sptanalysis-0.2.0-py3-none-any.whl:
Publisher:
pypi_publish.yml on joemans3/SPTanalysis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sptanalysis-0.2.0-py3-none-any.whl -
Subject digest:
abd0697224e190dccc6eb1cff7da2ac3511b7e8b1aeb3188023ac2a2b4b68bcc - Sigstore transparency entry: 176944549
- Sigstore integration time:
-
Permalink:
joemans3/SPTanalysis@ad3cd8e1e2559b0c36796479690d4473e86be49f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/joemans3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@ad3cd8e1e2559b0c36796479690d4473e86be49f -
Trigger Event:
push
-
Statement type: