Skip to main content

MRI algorithms for fat-water separation based on chemical shift with B0-correction

Project description

License: GPL v3 Python Version

mri-fatwater

MRI chemical shift-based fat-water separation with B0-correction using multi-scale graph cuts.

Overview

mri-fatwater is a Python package for MRI fat-water separation based on the multi-scale graph-cut algorithm described in Berglund & Skorpil, 2017. It can be used in Python scripts and as a command line tool.

⚠️ Repository rename notice: This repository was previously named fwqpbo. Existing links remain valid.

Installation

pip install mri-fatwater

Alternatively, clone the repository and install dependencies, for instance using uv:

git clone https://github.com/bretglun/mri-fatwater.git
cd mri-fatwater
uv sync

Usage

Command-Line Interface

# Show help
fatwater -h

# Run with parameter files
fatwater -d configs/dataParams.yml -a configs/algoParams.yml -m configs/modelParams.yml -o output_dir/

Python API

Example using config files:

from mri_fatwater import fatwater, io

results = fatwater.separate(
    data_param_file='configs/dataParams.yml',
    algo_param_file='configs/algoParams.yml',
    model_param_file='configs/modelParams.yml'
)
io.save(results, 'output_dir/')

Example using config dicts:

from mri_fatwater import fatwater, io

data = io.load_numpy_data('17.npy', 'data')

results = fatwater.separate(
    data=data,
    data_params={'B0': 1.5, 't': [0.00287, 0.00607, 0.00927]}, 
    algo_params={
        'graphcut': True, 
        'output': ['wat', 'fat', 'ff', 'B0map', 'R2map']}, 
    model_params={
        'watCS': 4.7, 
        'fatCS': [5.3, 4.31, 2.76, 2.1, 1.3, 0.9], 
        'relAmps': [0.048, 0.039, 0.004, 0.128, 0.693, 0.087]}
    )
io.save(results, data_path / '17_REC')

See scripts/demo.py for a complete example.

Configuration

Input parameters can be provided as:

  • Human-readable YAML configuration files
  • Python dictionaries

Example configuration files are available in the configs/ directory. Input data should be a complex NumPy array or a .npy file specified in the data configuration file with chemical shift encoded "echoes" along the first dimension.

Dependencies

See pyproject.toml for the complete list of dependencies.

Citation

If you use this software in your research, please cite:

Berglund J and Skorpil M. Multi-scale graph-cut algorithm for efficient water-fat separation. Magn Reson Med, 78(3):941-949, 2017. [doi: 10.1002/mrm.26479]

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License v3.0.

See LICENSE.md for the full license text.

Contact

Johan Berglund, Ph.D.
Uppsala University Hospital, Uppsala, Sweden
📧 johan.berglund@akademiska.se

Copyright © 2016–2026 Johan Berglund

Project details


Download files

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

Source Distribution

mri_fatwater-1.1.0.tar.gz (40.5 kB view details)

Uploaded Source

Built Distribution

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

mri_fatwater-1.1.0-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file mri_fatwater-1.1.0.tar.gz.

File metadata

  • Download URL: mri_fatwater-1.1.0.tar.gz
  • Upload date:
  • Size: 40.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mri_fatwater-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2a308a86507fdba849d684f9b1240c4f5c4f3286140bb61a13dbef470d8c6116
MD5 39e407b1e72aefce501c1d942b155c34
BLAKE2b-256 f0f527bbe3bd215efb2816d78fa169b05885ca5b885d8960fc8f93eb722cc9e0

See more details on using hashes here.

File details

Details for the file mri_fatwater-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: mri_fatwater-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mri_fatwater-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6e705c27a7c62e06852210f79fb6baf63c0e6628bfa18b89503ad8e2dc6b90b
MD5 a10efe1158c23b74e1029b28d11fa322
BLAKE2b-256 920a7beaf8f124476ff419148b8c18a5cca982f62a5b703f216ccb615f151b3c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page