Skip to main content

Rangefinder

CI

Automated ranging, species identification, and composition for atom probe tomography (APT) mass spectra. Rangefinder goes from an APT event list (.pos/.epos, represented internally by reconstructed positions and m/z) to ranged peaks, identified positive ionic species, and isotope-resolved composition — with no user-supplied ranges, no candidate element list, no interactive tuning, and no manual curation.

It is deterministic (operator variance is exactly zero), pure Python (NumPy/SciPy/pandas), and ships its own benchmark harness against the open-source APT ecosystem.

Scope

Rangefinder is an APT-specific end-to-end system, not a general-purpose mass spectrometry or spectroscopy toolkit. Its physical and chemical model assumes:

  • event-level, one-dimensional time-of-flight m/z data;
  • positive atomic and small molecular ions typical of field evaporation;
  • APT-like peak widths and one-sided thermal tails;
  • natural-isotope family patterns, APT charge-state priors, and elemental atomic percent as the final quantity; and
  • reconstructed x_nm, y_nm, and z_nm coordinates for the public pipeline data model and optional spatial analyses.

The histogramming, local peak detection, centroid refinement, and area-integration code is potentially reusable for other one-dimensional TOF mass spectra after adaptation and domain-specific validation. The MassBank and ToF-SIMS studies in this repository test that detector only. They do not validate Rangefinder's species assignment or composition outside APT; the benchmark adapters convert profile/centroid data to pseudo-events and disable APT family-assignment features.

Rangefinder does not currently model negative-ion assignment, adduct and fragment chemistry, tandem MS, chromatography or ion mobility, arbitrary profile/centroid inputs, instrument-pluggable resolution models, or non-mass-spectrometry axes. For those use cases, use a domain-specific toolkit or extract and validate only the low-level detector.

Range and overlap auditing

Every detected peak now carries two independent range estimates:

  • the production fixed/FWHM or crowded-window mixture-fit area; and
  • a clean-room equal-error range estimate with asymmetric boundaries, estimated purity, recovery, background, missed signal, counting uncertainty, and the fixed-versus-adaptive discrepancy.

Equal-error ranging was inspired by the public Atom-Probe-Toolbox, but no GPL source was copied. It remains a shadow diagnostic, because the bundled ablation found a large synthetic-data improvement but regressions on seven of ten real composition controls.

Composition uses a guarded natural-isotope-envelope deconvolution only for identifiable connected overlap groups with high-confidence species anchors, full-rank and conditioned envelope matrices, adequate observed coverage, optimizer convergence, and a residual pass. Rejected groups retain their assignment probabilities unchanged. Output tables preserve the uncorrected atomic_percent_assignment beside the promoted atomic_percent_weighted, and diagnostics.json records every accepted or rejected component.

Install

python -m pip install rangefinder

For development:

git clone https://github.com/kylemcdonald/rangefinder.git
cd rangefinder
python -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev]"

Quick start

from pathlib import Path

import rangefinder
from rangefinder.io.pos_loader import PosSampleData, PosSampleMetadata
from rangefinder.benchmark.truth import load_pos_arrays

sample_path = Path("your_sample.pos")
x, y, z, mz = load_pos_arrays(sample_path)
meta = PosSampleMetadata(path=sample_path, sample_name="s", sample_slug="s",
                         event_count=len(mz), file_size_bytes=len(mz) * 16,
                         verified_big_endian_float32=True,
                         verified_columns=("x_nm", "y_nm", "z_nm", "m_over_z_da"))
sample = PosSampleData(metadata=meta, x_nm=x, y_nm=y, z_nm=z, m_over_z_da=mz)

config = rangefinder.load_default_config()
artifacts = rangefinder.run_custom_pipeline(sample, Path("out"), config)
print(artifacts.elemental_composition)

Layout

  • src/rangefinder/ — the package.
    • analysis/ — the Rangefinder pipeline (custom_pipeline) plus the comparator front-ends (naive, PyCCAPT, pyOpenMS) and shared assignment/composition stages.
    • benchmark/ — ground-truth registry, metrics, and detection-ablation harness.
    • io/, references/, validation/, utils/ — POS loading, isotope tables, the synthetic generator, config/paths helpers.
    • bridge.py, bridge_runner.py — run foreign-toolchain comparators (APAV, ms_deisotope, APyT) in a separate environment.
    • config/defaults.yaml — the bundled default pipeline configuration (rangefinder.default_config_path()).
  • scripts/ — the benchmark and paper-table generators.
  • paper/ — rangefinder.tex and its auto-generated tables/.
  • controls/ — public CC-BY reference datasets (fetch large files with scripts/download_benchmark_controls.sh; reproducible raw data and generated synthetic controls are git-ignored, while provenance and range files are tracked).

Reproduce the benchmark and paper

scripts/download_benchmark_controls.sh          # fetch public controls
scripts/bootstrap_env.sh                        # install comparator environments
python scripts/run_benchmark.py                 # all methods x all datasets
python scripts/run_detection_ablation.py        # detection-stage ablation
python scripts/run_ablation.py                  # pipeline-stage ablation
python scripts/run_quantification_ablation.py   # range/deconvolution promotion test
python scripts/build_paper_tables.py            # regenerate paper/tables/*.tex
tectonic paper/rangefinder.tex

Every number in the paper regenerates from these commands; table numbers are never hand-edited.

License

The software is released under the MIT License. The reference data and range files under controls/ remain CC-BY-4.0 as documented in controls/README.md.

Metadata

Release files for rangefinder 0.3.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 rangefinder 0.3.0
File Size Uploaded Provenance Actions
rangefinder-0.3.0.tar.gz 127.5 kB With provenance Details for rangefinder-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 257.3 kB

Release files / rangefinder-0.3.0.tar.gz

Download URL rangefinder-0.3.0.tar.gz
Size 127.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dfa3a58eb8d7aa6b70094890f5f576868d661b6b74a59838d91ca7bc59dff710
BLAKE2b-256 checksum
How to use checksums
ec8b7d06c1a4590ba10ca6272a248a4276a9edfb531ac4c3cdac1dfef71f5f10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 24, 2026.

Transparency log

Release files / rangefinder-0.3.0-py3-none-any.whl

Download URL rangefinder-0.3.0-py3-none-any.whl
Size 129.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a42775fd417a557c16c46cde6b5ef559e032ba0d16db6e1a5192a7835e3448ef
BLAKE2b-256 checksum
How to use checksums
6f083ddf6392bae168dbb806238f625390cf8cbd9e90f494595d616572afdbdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 24, 2026.

Transparency log

Security for rangefinder 0.3.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rangefinder-0.3.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 Jul 24, 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.

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