Metadata-Version: 2.4
Name: espirit
Version: 0.1.1
Summary: PyTorch-based ESPIRiT coil sensitivity calibration for MRI
Project-URL: Repository, https://github.com/oscarvanderheide/espirit
Author: Oscar van der Heide
License: MIT
License-File: LICENSE
Keywords: coil-sensitivity,csm,espirit,medical-imaging,mri,pytorch
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12
Requires-Dist: numpy>=2.0
Requires-Dist: torch>=2.0
Description-Content-Type: text/markdown

# ESPIRiT

PyTorch-based ESPIRiT coil sensitivity calibration for MRI.

Single codebase that runs on **CPU**, **CUDA GPU**, and **Apple Silicon (MPS)** — no separate code paths needed.

## Notice

This package contains a PyTorch translation of the ESPIRiT implementation from the BART (Berkeley Advanced Reconstruction Toolbox), © 2013–2026 The Regents of the University of California and BART Developer Team. BART is licensed under the BSD 3-Clause License. See https://codeberg.org/mrirecon/bart.

## Usage

### 1) CLI
```bash
uvx espirit kspace.npy
```

### 2) Python

```bash
uv add espirit
```

```python
import numpy as np
import torch
from espirit import espirit

# NumPy
kspace_np = np.load("kspace.npy")
csm_np = espirit(kspace_np)

# PyTorch 
kspace_pt = torch.randn(8, 24, 24, 24, dtype=torch.complex64)
csm_pt = espirit(kspace_pt)
```

### Options
```python
csm = espirit(
    kspace,             # (n_coils, *spatial_dims)
    calib_size=24,      # calibration region size
    kernel_size=6,      # sliding-window kernel size
    threshold=0.001,     # singular-value threshold
    mask_threshold=0.8, # eigenvalue mask threshold
    normalize=True,     # RSS=1 normalization
    rotphase=True,      # remove phase ambiguity
    device=None         # cuda, mps, or cpu (auto-detect when None)
)
```

## Device support

| Device | Backend | Notes |
|--------|---------|-------|
| `cpu`  | NumPy/MKL | Always available |
| `cuda` | NVIDIA GPU | Requires CUDA toolkit |
| `mps`  | Apple Metal | macOS with Apple Silicon |

The same code runs on all devices — PyTorch handles dispatch automatically.
