Skip to main content

massphoto Python Package

PyPI Python License Docs CI

A Python package for processing, analyzing, and quantifying mass photometry data.

  • For mass photometry users: Analyse your measurements directly in Python, keeping your entire workflow transparent, shareable, and fully under your control.
  • Simple yet flexible: Turn raw movies into calibrated mass distributions with a single command, or customise parameters like integration time and PSF shape.
  • Open and reproducible: Automate batch processing across large datasets and output single-molecule events as standard pandas DataFrames to integrate into your analysis pipelines.

Key Features

  • Reading and writing mass photometry data in various formats (MP, TIFF, TDMS)
  • Image processing and filtering optimized for mass photometry signals
  • Drift correction for measurements
  • Event detection using temporal and spatial filters
  • PSF fitting for accurate contrast and mass measurements
  • Parallel processing with Dask for large datasets

Getting Started

Install Python 3.10 or higher. Check with python --version on Windows or python3 --version on macOS/Linux.

Installing massphoto

Create a new virtual environment and activate it using your shell's commands.

Windows (PowerShell):

python -m venv mp-venv
.\mp-venv\Scripts\Activate.ps1

For Windows Command Prompt, use mp-venv\Scripts\activate.bat instead.

macOS/Linux (bash or zsh):

python3 -m venv mp-venv
source mp-venv/bin/activate

After activation, the following commands work on all platforms. Use python -m pip to install into the active interpreter's environment:

python -m pip install --upgrade pip
python -m pip install massphoto
python -c "import massphoto as mp; print(mp.__version__)"

Runtime dependencies, including acceleration and file-format libraries, are installed automatically.

For an editable installation, run this from the source directory containing pyproject.toml:

python -m pip install -e .

For testing, use python -m pip install -e ".[testing]"; for development including documentation, use python -m pip install -e ".[dev,docs]".

Upgrading massphoto

Activate your environment using the appropriate command above, then run:

python -m pip install --upgrade massphoto

The current version can be checked with:

python -m pip show massphoto

Running tests

After installing the testing or development dependencies, run from the repo root:

python -m pytest

Usage Example

In the simplest case, you only call a single function to read a movie file, detect, and fit events:

import massphoto as mp
mpresults = mp.fit("path/to/movie.mp")

mpresults will be a dataframe with the detected and fitted events.

Common operations stay at the package root. Use mp.detection for alternative detection strategies, mp.mass_calibration for calibration, and mp.distfit for distribution fitting:

movie, metadata = mp.read_movie("path/to/movie.mp")
events = mp.fit(movie, detection_func=mp.detection.event_correlation)
distribution = mp.distfit.fit(events["contrasts"])

API Overview

A full API reference is available in the documentation. The main functions include:

Data I/O

  • read_movie: Read mass photometry data files (.mp, .mpr, .tiff, .tdms)

Image Processing

  • calc_ratiometric: Calculate ratiometric representation
  • normalize_frames: Normalize native frame means
  • correct_drift: Correct drift in measurement sequences

Event Detection

  • detect: Detect candidate events using chunked execution
  • detection.event_correlation: Detect using cross-correlation maps (spatial only)
  • detection.event_correlation_step: Spatial-temporal correlation detection (default detector)

Event Fitting

  • fit_event: Fit point spread function to detected events
  • fit: Full detection and fitting workflow, with configurable chunked execution

Calibration and Distributions

  • mass_calibration.fit: Fit a contrast-to-mass calibration
  • mass_calibration.apply: Apply a calibration to contrasts or an event table
  • distfit.fit: Fit a mass or contrast distribution and return distfit.FitResult

Event Metrics

  • events.add_nearest_neighbour: Spatial nearest neighbor distances
  • events.add_local_density: Local landing density
  • events.annotate_frame_metrics: Correlate events with frame-level quality metrics

Custom Pipelines

  • process: Compose annotated processing steps
  • resolve_record: Resolve an analysis record into a replay callable

Metadata

Release files for massphoto 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for massphoto 0.1.0
File Size Uploaded Provenance Actions
massphoto-0.1.0.tar.gz 137.2 kB With provenance Details for massphoto-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for massphoto 0.1.0
File Interpreter ABI Platform Actions
massphoto-0.1.0-py3-none-any.whl Python 3 none any Details for massphoto-0.1.0-py3-none-any.whl

Total release size: 222.8 kB

Release files / massphoto-0.1.0.tar.gz

Download URL massphoto-0.1.0.tar.gz
Size 137.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1985e1e481909a6e026b1fdadd4b4d0af9687fa1fecada8000fc68b23bd94c89
BLAKE2b-256 checksum
How to use checksums
bc216a01fe061befb08716ebf40dab13eb5a52142a889a1fd51b08fc1e2bfc4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / massphoto-0.1.0-py3-none-any.whl

Download URL massphoto-0.1.0-py3-none-any.whl
Size 85.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6603b11754414ac9b4cfeffaa90dc36b4da627f82a535f0cbb88dfd6d19f081f
BLAKE2b-256 checksum
How to use checksums
05686fe66e1b6e195f3db458348595837ac9b1ddaa9d57543edb047954e7f79b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for massphoto 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for massphoto-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page