Leopard-EM: Python based template matching
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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| leopard_em-1.3.0.tar.gz | 10.7 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| leopard_em-1.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.8 MB
Release files / leopard_em-1.3.0.tar.gz
| Download URL | leopard_em-1.3.0.tar.gz |
|---|---|
| Size | 10.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58185c6f0a1d3e56dcdd907d28d33192a13949c8e6608622226839f45f6f0681
|
|
BLAKE2b-256 checksum How to use checksums |
83399ca0356c4cd500e4d330157551d9fa9c58e4587fd4bad72ec33137bdc7e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.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 Sep 11, 2026.
Transparency logRelease files / leopard_em-1.3.0-py3-none-any.whl
| Download URL | leopard_em-1.3.0-py3-none-any.whl |
|---|---|
| Size | 154.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d52cc0b6370bb84dd8cf41e5aef2f8fdd8f6a920ac3cc8a528ac4a4debbdd3a
|
|
BLAKE2b-256 checksum How to use checksums |
a9317e0c4a5a2fcfc3f357f74bbb99c9fe66f83c6faed48a59afc2d7bd7ea3b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.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 Sep 11, 2026.
Transparency log