SpinLab — Bringing the Power of Python to MR Spectroscopy
SpinLab is an open-source, object-oriented Python package for importing, processing, and analyzing data from:
- Electron Paramagnetic Resonance (EPR) spectroscopy
- Nuclear Magnetic Resonance (NMR) spectroscopy
- Dynamic Nuclear Polarization (DNP) spectroscopy
Documentation: spinlaboratory.com
Features
- Universal data import — load data from 13 spectrometer formats with automatic format detection
- N-dimensional data objects — the
SpinDataobject keeps data, axes, and experimental parameters together at all times - Comprehensive processing — apodization (7 window functions), Fourier transform with zero-filling, phase correction, baseline removal, alignment, integration, and more
- Analysis tools — relaxation fitting, peak finding, DNP enhancement profile simulation
- Publication-quality figures —
fancy_plot()automatically applies axis labels and formatting based on the experiment type - Processing audit log — every processing step is automatically recorded with its parameters for full reproducibility
- HDF5 save/load — store complete
SpinDataobjects including axes, attributes, and audit log
Supported File Formats
| Spectrometer / Software | Extension |
|---|---|
| Bruker Xepr / Elexsys (BES3T) | .DSC, .DTA |
| Bruker WinEPR / ESP | .par, .spc |
| Bruker TopSpin | experiment directory |
| Varian / Agilent VnmrJ | .fid directory |
| JEOL Delta | .jdf |
| Magritek Prospa | .1d, .2d, .3d, .4d |
| FeMi SpecMan4EPR | .d01, .exp |
| Tecmag TNMR | .tnt |
| RS2D | .xml, .dat |
| VNA (S-parameters) | .s1p, .s2p |
| SpinLab HDF5 | .h5 |
| CSV | (via sl.load_csv()) |
Quick Start
import spinlab as sl
# Load data — format detected automatically
data = sl.load("spectrum.DTA")
# Inspect the data object
print(data)
# Plot
sl.plt.figure()
sl.plot(data)
sl.plt.show()
NMR processing workflow:
import spinlab as sl
data = sl.load("experiment/1/") # load TopSpin FID
data = sl.apodize(data, kind="exponential", lw=5) # line broadening
data = sl.fourier_transform(data, zero_fill_factor=2) # FFT with zero-filling
data = sl.phase(data, p0=12.5) # phase correction
data = sl.remove_background(data, deg=1) # baseline correction
sl.plt.figure()
sl.plot(data)
sl.plt.show()
sl.save(data, "processed.h5") # save result
Installation
SpinLab requires Python 3.10 or higher.
pip install spinlab
To upgrade an existing installation:
pip install --upgrade spinlab
Documentation
Full documentation including user guides, processing reference, and API reference is available at:
Development
Contributions are welcome! See the Contributing Guide for details on setting up a development environment, running tests, and opening pull requests.
git clone https://github.com/SpinLab/spinlab
cd spinlab
pip install -e spinlab
python -m pytest
Citing SpinLab
If you use SpinLab to process data for a publication, please add a reference to the SpinLab documentation in your Materials and Methods section.
Authors
Current maintainers: Timothy Keller, Yen-Chun Huang, Thorsten Maly
SpinLab originally started as DNPLab, created by:
License
SpinLab is released under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spinlab-1.1.4.tar.gz.
File metadata
- Download URL: spinlab-1.1.4.tar.gz
- Upload date:
- Size: 106.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4b2e2ea8b7eaa8f86807f6b9f7258b005c1836c9dae948b86f961a8d5e5cbd7
|
|
| MD5 |
bc58e249301e04c692e71db250910acd
|
|
| BLAKE2b-256 |
84e9675f2fb636d1a79eaa3d98253545aa39aab8ed139e7b97cd9f7f43bfcc8b
|
File details
Details for the file spinlab-1.1.4-py3-none-any.whl.
File metadata
- Download URL: spinlab-1.1.4-py3-none-any.whl
- Upload date:
- Size: 129.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e5bcf7172c7911be62cbaa98dc795e681e8a46f318c22a242a07201594553da
|
|
| MD5 |
a787df644f1492c71a93e0be39ed4acf
|
|
| BLAKE2b-256 |
56483d61fc833645470f874898ed7383e53a09036725433cea7309b236192162
|