Skip to main content

Leopard-EM: Python based template matching

License PyPI Python Version CI codecov

Leopard-EM (Location & oriEntatiOn of PARticles found using two-Dimensional tEmplate Matching) is a python package for running two-dimensional template matching (2DTM) on cryo-EM images. Check out the online documentation for more details about using, configuring, and analyzing data from the Leopard-EM Python package.

Basic Installation

The newest released version of the package can be installed from PyPI using pip:

pip install leopard-em

Usage

Template Matching

Inputs to the template matching programs can be configured through a YAML file or a set of Python objects. The example YAML configuration file acts as a template for configuring your own runs with more details on configuring and running 2DTM on the programs section of the documentation. We also provide a default match_template.py script with some additional detail, but a compacted version of this script is shown below. Once configured with the proper paths, parameters, etc., the program can run as follows:

from leopard_em.pydantic_models.managers import MatchTemplateManager

YAML_CONFIG_PATH = "/path/to/match-template-configuration.yaml"
DATAFRAME_OUTPUT_PATH = "/path/to/match-template-results.csv"
ORIENTATION_BATCH_SIZE = 8

def main():
    mt_manager = MatchTemplateManager.from_yaml(YAML_CONFIG_PATH)
    mt_manager.run_match_template(ORIENTATION_BATCH_SIZE)
    df = mt_manager.results_to_dataframe()
    df.to_csv("/path/to/results.csv")

# NOTE: invoking from `if __name__ == "__main__"` is necessary
# for proper multiprocessing/GPU-distribution behavior
if __name__ == "__main__":
    main()

Template Refinement

Particle orientations and locations can be refined using the RefineTemplateManager objects after a template matching run. The RefineTemplateManager is similarly a set of Pydantic models capable of configuration via YAML files. The example YAML configuration file acts as a template for configuring your own runs. We also provide a default refine_template.py script with some additional detail, but a compacted version of this script is shown below. Once configured with the proper paths, parameters, etc., the program can run as follows:

from leopard_em.pydantic_models.managers import RefineTemplateManager

YAML_CONFIG_PATH = "/path/to/refine-template-configuration.yaml"
DATAFRAME_OUTPUT_PATH = "/path/to/refine-template-results.csv"
PARTICLE_BATCH_SIZE = 80

def main():
    rt_manager = RefineTemplateManager.from_yaml(YAML_CONFIG_PATH)
    rt_manager.run_refine_template(DATAFRAME_OUTPUT_PATH, PARTICLE_BATCH_SIZE)

if __name__ == "__main__":
    main()

Installation for Development

The package can be installed from source in editable mode with the optional development libraries via pip.

git clone https://github.com/Lucaslab-Berkeley/Leopard-EM.git
cd Leopard-EM
pip install -e '.[dev,test, docs]'

Further information on development and contributing to the repo can be found in our online documentation.

Citation

If you use Leopard-EM in your research, please include the following citations in your biblography:

@article{Giammar:rr5256,
  author = "Giammar, Matthew D. and Dickerson, Joshua L. and Hall, Laina N. and Lucas, Bronwyn A.",
  title = "{{\it Leopard-EM}: an extensible 2D template-matching package to accelerate {\it in situ} structural biology}",
  journal = "Acta Crystallographica Section D",
  year = "2026",
  volume = "82",
  number = "1",
  pages = "30--42",
  month = "Jan",
  doi = {10.1107/S2059798325009982},
  url = {https://doi.org/10.1107/S2059798325009982},
}

Metadata

Release files for leopard-em 1.3.1

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

Source distribution (sdist)

Source distribution for leopard-em 1.3.1
File Size Uploaded Provenance Actions
leopard_em-1.3.1.tar.gz 10.8 MB With provenance Details for leopard_em-1.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for leopard-em 1.3.1
File Interpreter ABI Platform Actions
leopard_em-1.3.1-py3-none-any.whl Python 3 none any Details for leopard_em-1.3.1-py3-none-any.whl

Total release size: 11.0 MB

Release files / leopard_em-1.3.1.tar.gz

Download URL leopard_em-1.3.1.tar.gz
Size 10.8 MB
Tags Source
SHA-256 checksum
How to use checksums
f80266606238d4d81d646e8afd6ab193fcf6422f350c29486287099e9c65331e
BLAKE2b-256 checksum
How to use checksums
cb5031244a97ae28804dda864a4af629e41ab4f3dfacfaa5affb4d21de803067
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 Nov 6, 2026.

Transparency log

Release files / leopard_em-1.3.1-py3-none-any.whl

Download URL leopard_em-1.3.1-py3-none-any.whl
Size 190.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba41875f31d42c053c75fd424ab100f34d6198141a0234558163b97aebf52979
BLAKE2b-256 checksum
How to use checksums
3f7c754f3774f5357a43934bc9afe51a7fb2a6cb2fa62bb0205ef677979d8217
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 Nov 6, 2026.

Transparency log

Security for leopard-em 1.3.1

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 leopard_em-1.3.1.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 Nov 6, 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