Skip to main content

brukerapi-python

https://zenodo.org/badge/DOI/10.5281/zenodo.3831320.svg https://github.com/isi-nmr/brukerapi-python/workflows/CI/badge.svg Documentation Status

A Python package providing I/O interface for Bruker data sets.

tl;dr

Install using pip:

pip install brukerapi

Load any data set:

from brukerapi.dataset import Dataset
dataset = Dataset('{path}/2dseq')    # also supports fid, fid_proc.64, traj, and rawdata.jobN
dataset.data                         # access data array
dataset.get_value('VisuCoreSize')    # get a parameter value

Raw acquisitions and k-space

Raw Bruker acquisitions have format-dependent historical .data semantics. For explicit code, use the representation that matches the task:

fid = Dataset('{path}/fid')
fid.raw                 # decoded (sample, shot, receiver) acquisitions
fid.kspace              # ordered FID k-space

job = Dataset('{path}/rawdata.job0')
job.raw                 # decoded (sample, shot, receiver) acquisitions
job.kspace              # ordered Cartesian PV360 k-space, when metadata proves the layout
job.to_kspace(bart=True)  # optional 16-axis BART layout

Dataset.data remains backward compatible: FIDs expose their historical ordered k-space view, whereas PV360 rawdata.jobN exposes its historical decoded stream and emits a FutureWarning. .kspace is not a reconstruction API; EPI and non-Cartesian jobs require acquisition-specific handling.

Frame-group metadata

For 2dseq data, frame_group_values aligns values named by VisuGroupDepVals to the corresponding array axes. Returned arrays use singleton dimensions where needed and therefore broadcast directly against dataset.data:

echoes = dataset.frame_group_values['VisuAcqEchoTime']
b_matrices = dataset.frame_group_values['VisuAcqDiffusionBMatrix']

metadata provides normalized, grouped access to parsed subject, study, series, equipment, and acquisition fields:

dataset.metadata['visu_study']['uid']
dataset.metadata['visu_acq']['sequence_name']
dataset.metadata['subject']['id']

Load an entire study:

from brukerapi.folders import Study
study = Study('{path_to_study_folder}')
dataset = study.get_dataset(exp_id='1', proc_id='1')

dataset.data                         # Study loads datasets by default

Load a parametric file:

from brukerapi.jcampdx import JCAMPDX

parameters = JCAMPDX('path_to_scan/method')

TR = parameters.params["PVM_RepetitionTime"].value
TR = parameters.get_value("PVM_RepetitionTime")

Features

  • I/O interface for fid data sets

  • I/O interface for 2dseq data sets

  • I/O interface for rawdata data sets

  • Random access for fid and 2dseq data sets

  • Split operation implemented over 2dseq data sets

  • Filter operation implemented over Bruker folders (allowing you to work with a subset of your study only)

  • ParaVision 5.1, 6.0.1, 7.0.0, and 360 metadata and binary-layout support

  • Metadata-based fallback inference for custom Cartesian, EPI, radial/UTE, spiral, ZTE, CSI, and spectroscopy sequences

Examples

Documentation

Online documentation of the API is available at Read The Docs.

Install

Using pip:

pip install brukerapi

From source:

git clone https://github.com/isi-nmr/brukerapi-python.git
cd brukerapi-python
python -m pip install -e .[dev]

Testing

To ensure reliability, every commit to this repository is tested against the following, publicly available data sets:

The corpus download is opt-in for local runs:

python -m pytest test --download_test_data

Without that flag, pytest uses any corpus already present under test/test_data and skips unavailable collections.

File format reference

Bruker ParaVision Raw Data Format is the source of truth for file-format parsing, binary layouts, dataset typing, and metadata-driven acquisition scheme inference in this project.

Compatibility

Tested releases are ParaVision 5.1, 6.0.1, 7.0.0, and PV360 3.x. Supported primary binaries are fid, fid_proc.64, 2dseq, traj, rawdata.jobN, and named jobs declared by ACQ_jobs (for example, rawdata.Navigator or rawdata.echoNavigator). Known fid.spiral, fid.navFid, and fid.orig files are exposed as auxiliary subdatasets of their parent fid; they are not accepted as standalone primary datasets. TopSpin/NMR ser is intentionally unsupported.

Known pulse-program names use dedicated layouts. For custom sequences the reader also infers common acquisition families from metadata; callers can pass scheme_id= when inference is ambiguous. Rawdata is returned as complex ordered samples, not as reconstructed k-space. See the compatibility page in the documentation for behavior and current reconstruction limitations.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brukerapi-0.4.5.tar.gz (112.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brukerapi-0.4.5-py3-none-any.whl (69.5 kB view details)

Uploaded Python 3

File details

Details for the file brukerapi-0.4.5.tar.gz.

File metadata

  • Download URL: brukerapi-0.4.5.tar.gz
  • Upload date:
  • Size: 112.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for brukerapi-0.4.5.tar.gz
Algorithm Hash digest
SHA256 91a34b2e495a0d49c4e2d89b3153cf40c5b658a10b42b4523627eadf49d2d655
MD5 9c436d493bee7b9a87a6bd51806ce349
BLAKE2b-256 71876e63a597865ee5b98f33ff08209042d78cc237617b2df312a432b8378029

See more details on using hashes here.

File details

Details for the file brukerapi-0.4.5-py3-none-any.whl.

File metadata

  • Download URL: brukerapi-0.4.5-py3-none-any.whl
  • Upload date:
  • Size: 69.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for brukerapi-0.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 61dea0fbb10a989e56ebfcf07aa1fb72ab647d9b64762ec36d3e38cf73a6ba50
MD5 5dfa5b7ab4cc2d8df198d1bd806ea030
BLAKE2b-256 0bd1f75b167ef9813747641d6d8039306622b726130623c66952f38a086a066b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.6

2 files

This release

0.4.5 This release

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.0

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4.0

2 files

0.1.3.0

2 files

0.1.2.0

2 files

0.1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page