EPyR Tools: Electron Paramagnetic Resonance (EPR) Tools in Python
| License | Tests | Documentation | Version |
|---|---|---|---|
What is EPyR Tools?
EPyR Tools is a Python package for analyzing Electron Paramagnetic Resonance (EPR) spectroscopy data from Bruker spectrometers. It covers the full path from raw instrument files to publication-ready results: loading BES3T and ESP/WinEPR binary formats, baseline correction, lineshape and T1/T2 relaxation fitting, FFT-based analysis of pulse-EPR time-domain data, and FAIR-compliant export to CSV, JSON, and HDF5.
The package targets EPR researchers who want a reproducible, scriptable Python workflow in place of proprietary vendor software, with a command-line interface for routine processing and a documented Python API for custom analysis.
Key Features
Data Loading & FAIR Conversion
- Read Bruker BES3T (
.DTA/.DSC) and ESP/WinEPR (.spc/.par) files, 1D and 2D, with automatic format detection epyr.fair: export to CSV, JSON, and HDF5 with standardized, complete metadata- Batch conversion of entire directories
- Plugin architecture for adding new file formats
Baseline Correction (epyr.baseline)
- Polynomial, exponential, bi-exponential, and stretched-exponential models, for 1D and 2D data
- Automatic model selection ranked by AIC/BIC/R²
- Manual and interactive baseline-region selection
Lineshape Analysis & Fitting (epyr.lineshapes)
- Gaussian, Lorentzian, true Voigt (Faddeeva-function convolution), and pseudo-Voigt lineshapes
- Absorption and 1st/2nd derivative forms, phase mixing, optional affine baseline term
fit_epr_signal()andfit_multiple_shapes()for single-model and model-comparison fittingpseudo_modulation()simulates field-modulation lock-in detection on an unmodulated spectrum
T1/T2 Relaxation Fitting (epyr.relaxation, new in v0.4.0)
- Six decay/recovery models: mono- and stretched-exponential, bi-exponential, inversion/saturation recovery, and combined homogeneous/spectral-diffusion (Gamma0/GammaG) echo decay
fit_relaxation()for a single model,fit_multiple_decays()to rank candidates by reduced chi-squared- Fit results print a readable parameter summary directly
Signal Processing (epyr.signalprocessing)
- FFT-based frequency analysis for pulse-EPR time-domain data: Rabi oscillations, DEER, HYSCORE
- 1D and 2D FFT modes, apodization windows (Hann, Hamming, Blackman, Kaiser), automatic time-unit detection, zero-padding
- Power spectral density (Welch, periodogram) and spectrogram analysis
Physics & Units (epyr.physics)
- CODATA 2022 physical constants in SI and CGS units (
GFREE,BMAGN,NMAGN,PLANCK, ...) - Field/frequency conversion (mT ↔ MHz ↔ cm⁻¹) via
unitconvert()and dedicated helpers
Command-Line Interface
- Nine commands covering the full workflow:
epyr-convert,epyr-baseline,epyr-batch-convert,epyr-config,epyr-info,epyr-isotopes,epyr-plot,epyr-validate,epyrview epyr-plot --interactive --measure: click-to-measure delta x/y distance tool
Performance & Isotope Database
OptimizedLoader/DataCachefor large files, with memory monitoring and streamingepyr.isotopes/epyr-isotopes: interactive periodic-table GUI with NMR frequency calculator and X/Q/W-band presets
What's New in v0.5.0
Version 0.5.0 adds pseudo_modulation() to epyr.lineshapes: it reproduces the signal a lock-in amplifier would record under sinusoidal field modulation, applied numerically to a spectrum recorded without field modulation (Hyde et al., Appl. Magn. Reson. 1, 483-496, 1990).
from epyr.lineshapes import pseudo_modulation
# First-harmonic pseudomodulation, 2 G peak-to-peak modulation amplitude
y_mod = pseudo_modulation(field, spectrum, mod_amplitude=2.0, harmonic=1)
# Second harmonic
y_mod2 = pseudo_modulation(field, spectrum, mod_amplitude=2.0, harmonic=2)
See docs/release_notes/v0.5.0.rst for full details, or docs/release_notes.rst for the complete version history.
Installation
Prerequisites
- Python 3.8 or higher
- NumPy, SciPy, matplotlib, pandas, h5py (installed automatically)
Quick Install
pip install epyr-tools
Development Installation
git clone https://github.com/BertainaS/epyrtools.git
cd epyrtools
# Install with development dependencies
pip install -e ".[dev,docs]"
# Set up pre-commit hooks
pre-commit install
Verification
epyr --help
epyr-info
make test
Getting Started
1. Loading Data
import epyr
# Open a file dialog to select a .dta, .dsc, .spc, or .par file
x, y, params, filepath = epyr.eprload()
# Or specify a path directly:
# x, y, params, filepath = epyr.eprload('path/to/data.dsc')
2. Converting to FAIR Formats
from epyr.fair import convert_bruker_to_fair
convert_bruker_to_fair('path/to/data.dsc', output_dir='path/to/output')
3. Baseline Correction
import epyr
x, y, params, filepath = epyr.eprload("data.dsc")
# Automatic model selection
corrected, baseline, model_info = epyr.baseline.baseline_auto_1d(x, y, params)
# Or a specific model with manual region exclusion (e.g. signal regions, in mT)
corrected, baseline = epyr.baseline.baseline_polynomial_1d(
x, y, params,
manual_regions=[(3340, 3360), (3380, 3400)],
region_mode='exclude',
order=2,
)
4. Lineshape Fitting
from epyr.lineshapes import fit_epr_signal, fit_multiple_shapes
x, y, params, filepath = epyr.eprload('data.DTA')
# Single model
result = fit_epr_signal(x, y, 'gaussian')
print(result.summary())
# 1st-derivative signal with adjustable phase, comparing all lineshapes
results = fit_multiple_shapes(x, y, derivative=1, fit_phase=True)
5. T1/T2 Relaxation Fitting
from epyr.relaxation import fit_relaxation, fit_multiple_decays
t, y, params, filepath = epyr.eprload('echo_decay.DTA')
y = abs(y) # take the magnitude of a complex echo signal
result = fit_relaxation(t, y, model="stretched_exponential")
results = fit_multiple_decays(t, y) # compare mono/stretched/bi-exponential
6. Time-Domain Signal Processing (FFT)
from epyr.signalprocessing import analyze_frequencies
t, y, params, filepath = epyr.eprload('rabi_oscillation.DTA')
result = analyze_frequencies(t, y, window='hann', zero_padding=4)
print(f"Dominant frequency: {result['dominant_frequencies'][0]:.3f} MHz")
7. Plotting and the CLI
import epyr
x, y, params, filepath = epyr.eprload("data.dsc")
epyr.plot_1d(x, y, params, title="EPR Spectrum")
# Interactive plot with click-to-measure delta x/y
epyr-plot spectrum.dsc --interactive --measure
# Batch FAIR conversion
epyr-batch-convert ./data --formats csv,json,hdf5
Tutorials & Examples
Jupyter Notebook Series
An eight-notebook tutorial series in examples/notebooks/, using real experimental data from examples/data/. Notebooks are committed without outputs; run them to generate figures.
cd examples/notebooks
jupyter lab 00_Tutorial_Series_Index.ipynb # index and navigation
| Notebook | Topic |
|---|---|
01_Loading_and_Plotting.ipynb |
eprload, parameter inspection, 1D/2D plotting |
02_Baseline_Correction.ipynb |
Polynomial, automatic, and exponential baselines |
03_Lineshape_Analysis_and_Fitting.ipynb |
Gaussian/Lorentzian/Voigt, derivatives, fitting |
04_Relaxation_Fitting.ipynb |
T1/T2 decay/recovery models (new in v0.4.0) |
05_Signal_Processing_and_FFT.ipynb |
Frequency analysis of Rabi data, apodization |
06_FAIR_Conversion_and_Export.ipynb |
CSV/JSON/HDF5 export and validation |
07_Physics_Units_and_Constants.ipynb |
CODATA constants, field/frequency conversions |
Standalone Example Scripts
Six short, self-contained scripts in examples/clean/ exercising the public API end to end:
python examples/clean/01_basic_loading_and_plotting.py
python examples/clean/02_baseline_and_fitting.py
python examples/clean/03_advanced_fft_windows.py
python examples/clean/04_interactive_2d_slicer.py
python examples/clean/05_rabi_frequency_analysis.py
python examples/clean/06_relaxation_fitting.py
See docs/tutorials/clean_examples.rst for a description of each script.
Project Structure
epyrtools/
├── epyr/ # Main package
│ ├── eprload.py # Core data loading (BES3T, ESP formats)
│ ├── eprplot.py # EPR plotting (1D, 2D map, waterfall, slicer)
│ ├── cli.py # Command-line interface (9 commands)
│ ├── config.py # Hierarchical configuration system
│ ├── performance.py # OptimizedLoader, DataCache
│ ├── plugins.py # Plugin architecture
│ ├── logging_config.py # Centralized logging
│ ├── isotope_gui.py # Interactive isotope database GUI
│ ├── baseline/ # Baseline correction (correction, selection, models, interactive)
│ ├── lineshapes/ # Gaussian, Lorentzian, Voigt, pseudo-Voigt, fitting
│ ├── relaxation/ # T1/T2 decay/recovery models and fitting
│ ├── signalprocessing/ # FFT frequency analysis, apodization windows
│ ├── physics/ # CODATA constants and unit conversions
│ ├── fair/ # FAIR conversion, exporters, validation
│ └── sub/ # Bruker BES3T/ESP format loaders
├── docs/ # Sphinx documentation and tutorials
├── examples/
│ ├── notebooks/ # Jupyter tutorial series
│ ├── clean/ # Six standalone end-to-end scripts
│ └── data/ # Real EPR measurement files (CW, pulse, 2D)
├── tests/ # Test suite (369 tests; smoke/standard/deep/scientific)
└── pyproject.toml # Packaging, dependencies, entry points
Documentation
- Full documentation: guides and API reference (Sphinx)
- User guide: workflows and step-by-step tutorials
- CLI reference: command-line interface
- API reference: public API
- Release notes: version history
Testing & Quality
EPyR Tools follows a 4-level testing protocol (pytest -m smoke|standard|deep|scientific), with 369 tests covering basic functionality, broad feature coverage, edge cases, and scientific validation against NIST/CODATA values.
make test # full suite
make test-cov # with coverage report
make quality # lint, type-check, security
Contributing & Support
- Issues: GitHub Issues
- Contributing guide: docs/contributing.rst
License
This project is licensed under the MIT License, see LICENSE for details.
Contributors
Lead Developer & Maintainer:
- Sylvain Bertaina, sylvain.bertaina@cnrs.fr
Affiliation:
- Magnetism Group (MAG), IM2NP Laboratory
- CNRS (Centre National de la Recherche Scientifique)
EPyR Tools: EPR data analysis in Python.
Metadata
Release files for epyr-tools 0.5.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 | Provenance | Actions |
|---|---|---|---|---|
| epyr_tools-0.5.0.tar.gz | 5.2 MB | Without provenance | Details for epyr_tools-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| epyr_tools-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for epyr_tools-0.5.0-py3-none-any.whl |
Total release size: 5.3 MB
Release files / epyr_tools-0.5.0.tar.gz
| Download URL | epyr_tools-0.5.0.tar.gz |
|---|---|
| Size | 5.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a4d5a32157290c02d7778407a9cd65407f2d029e7ee01ed5195baf923c90139e
|
|
BLAKE2b-256 checksum How to use checksums |
a8182c8fd8aebe8f6a36157421cd651a1d74e832d16aa6ef92fc636bb1beb60a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.17
|
Release files / epyr_tools-0.5.0-py3-none-any.whl
| Download URL | epyr_tools-0.5.0-py3-none-any.whl |
|---|---|
| Size | 181.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89140cf588438541d7af9de6f01d6f131d71efa94899c09c6969306bcbf8bc12
|
|
BLAKE2b-256 checksum How to use checksums |
a35efe69ed0d9d89bb0f4e7602eae5fcc17f18a9b545411bc1d11e1e03ccb0d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.17
|
Security for epyr-tools 0.5.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.