Metadata-Version: 2.2
Name: bartorch
Version: 0.0.2
Summary: BART, the Berkeley Advanced Reconstruction Toolbox, embedded in PyTorch
License: MIT License
         
         Copyright (c) 2024 bartorch contributors
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
         
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: C
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Project-URL: Homepage, https://github.com/mcencini/bartorch
Project-URL: Documentation, https://mcencini.github.io/bartorch/
Project-URL: Repository, https://github.com/mcencini/bartorch
Project-URL: Issues, https://github.com/mcencini/bartorch/issues
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.10
Requires-Dist: torch>=2.1
Requires-Dist: finufft>=2.2
Provides-Extra: mkl
Requires-Dist: mkl>=2024; sys_platform == "linux" and platform_machine == "x86_64" and extra == "mkl"
Provides-Extra: cufinufft
Requires-Dist: cufinufft>=2.3; extra == "cufinufft"
Provides-Extra: deepinv
Requires-Dist: deepinv>=0.2; extra == "deepinv"
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: deepinv>=0.2; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx<9,>=7.3; extra == "docs"
Requires-Dist: sphinx-book-theme<2,>=1.1; extra == "docs"
Requires-Dist: sphinx-gallery<0.20,>=0.17; extra == "docs"
Requires-Dist: sphinx-copybutton<1,>=0.5; extra == "docs"
Requires-Dist: myst-parser<5,>=3; extra == "docs"
Requires-Dist: matplotlib<4,>=3.7; extra == "docs"
Description-Content-Type: text/markdown

# bartorch

bartorch runs BART, the Berkeley Advanced Reconstruction Toolbox, inside the
Python process on torch tensors: BART's applications as functions, its linear
and nonlinear operators as composable objects, and its iterative solvers as
classes.  It computes nothing BART does not, except where it substitutes a
faster implementation: FINUFFT for every non-Cartesian transform, and a SENSE
operator that applies its coils in batches.

## Install

```bash
pip install bartorch
pip install "bartorch[mkl]"          # Linux: MKL for BART's BLAS, LAPACK and FFT
pip install "bartorch[cufinufft]"    # non-Cartesian transforms on a CUDA device
```

Wheels are built for Linux x86_64 and macOS on Apple silicon; elsewhere pip
builds from source, which needs clang or GCC 14+ and CMake.  The
[installation guide](docs/guides/user/installation.md) covers CUDA builds and
platform notes.

## Where to start

| Task | Start here |
| --- | --- |
| Reconstruct with a BART application | `bartorch.tools`: `pics`, `nlinv`, `ecalib` |
| Build an encoding and solve it | `bartorch.linop` and `bartorch.optim` |
| Transform, filter or register arrays | the functions in `bartorch` |
| Fit a torch signal model | `bartorch.nlop` and `bartorch.optim.IRGNM` |

## Quickstart

```python
import bartorch
import bartorch.tools as bt
from bartorch import linop, optim, prox

kspace = bt.phantom(128, coils=8, kspace=True)        # (8, 1, 128, 128)
maps = bt.ecalib(kspace, maps=1)

# BART's own application ...
image = bt.pics(kspace, maps, regularizers=prox.Wavelet((-1, -2), 0.005), solver="fista")

# ... or the same problem assembled from an operator and a solver.
# pics also scales the data first; see optim.data_scaling.
A = linop.Sense(maps.squeeze(1), (8, 128, 128))
x = optim.FISTA(prox.Wavelet((-1, -2), 0.005), maxiter=50)(kspace, A)

spectrum = bartorch.fft(bt.phantom(128), axes=(-2, -1), unitary=True)
```

Shapes are C order, so the last axis is the one BART calls the first, and
wherever BART takes a bitmask or a dimension number a function here takes
axis indices; `pics` takes `bartorch.prox` terms where BART takes `-R`
strings.

## License

MIT.  BART is distributed under its own BSD license (`external/bart/LICENSE`);
pocketfft (BSD-3) and BlocksRuntime (MIT) are vendored under `external/` with
their licenses.
