Skip to main content

Multi-echo combinations

PyPI version PyPI - Python Version

MRI data acquisitions can involve multiple volumes acquired at different echo times. Typically, subsequent processing pipelines assume data to be acquired at a single echo time. This repository provides a command line tool to combine multiple echoes from a multi-echo (BOLD f)MRI acquisition. It currently provides three different echo avering algorithms:

algorithm description
1. average Echoes are weighted equally
2. PAID Echoes are weighted by their CNR, i.e. by their TE*tSNR contributions (BOLD fMRI data only)
3. TE Echoes are weighted by their TEs

For more information on multiecho acquisition and combination schemes, please refer to (for example):

  • Poser et al. (2006). BOLD Contrast Sensitivity Enhancement and Artifact Reduction with Multiecho EPI: Parallel-Acquired Inhomogeneity- Desensitized fMRI. Magn. Reson. Med. 55:6, pp. 1227–35.
  • Posse, Stefan (2012). Multi-Echo Acquisition. NeuroImage 62:2, pp. 665–671.

Multiecho has been developed at the Donders Institute of the Radboud University.

Installation

To install, simply run:

pip install multiecho

This will give you the latest stable release of the software. To get the very latest (possibly unreleased) version of the software you can install the package directly from the Github source code repository:

pip install git+https://github.com/Donders-Institute/multiecho

Alternatively, clone this repository and run the following on the root folder of the repository:

pip install .

The tool supports Python 3.6+.

Usage

Once installed, a command line tool called mecombine should be available in your PATH. Detailed usage information can be found by running mecombine -h:

usage: mecombine [-h] [-o OUTPUTNAME] [-a {PAID,TE,average}]
                      [-w [WEIGHTS [WEIGHTS ...]]] [-s] [-v VOLUMES]
                      pattern

Combine multi-echo echoes.

Tools to combine multiple echoes from an fMRI acquisition.
It expects input files saved as NIfTIs, preferably organised
according to the BIDS standard.

Currently three different combination algorithms are supported, implementing
the following weighting schemes:

1. PAID => TE * SNR
2. TE => TE
3. Simple Average => 1

positional arguments:
  pattern               Globlike search pattern with path to select the echo
                        images that need to be combined. Because of the
                        search, be sure to check that not too many files are
                        being read

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUTNAME, --outputname OUTPUTNAME
                        File output name. If not a fullpath name, then the
                        output will be stored in the same folder as the input.
                        If empty, the output filename will be the filename of
                        the first echo appended with a '_combined' suffix
                        (default: )
  -a {PAID,TE,average}, --algorithm {PAID,TE,average}
                        Combination algorithm. Default: TE (default: TE)
  -w [WEIGHTS [WEIGHTS ...]], --weights [WEIGHTS [WEIGHTS ...]]
                        Weights (e.g. = echo times) for all echoes (default:
                        None)
  -s, --saveweights     If passed and algorithm is PAID, save weights
                        (default: False)
  -v VOLUMES, --volumes VOLUMES
                        Number of volumes that is used to compute the weights
                        if algorithm is PAID (default: 100)

examples:
  mecombine '/project/number/bids/sub-001/func/*_task-motor_*echo-*.nii.gz'
  mecombine '/project/number/bids/sub-001/func/*_task-rest_*echo-*.nii.gz' -a PAID
  mecombine '/project/number/bids/sub-001/func/*_acq-MBME_*run-01*.nii.gz' -w 11 22 33 -o sub-001_task-stroop_acq-mecombined_run-01_bold.nii.gz

Caveats

Currently, the echo combination is resource hungry as we load all datasets into memory at once. We could iterate through the volumes and only keep the final combined series in memory at any given time.

You may receive a runtime warning (invalid value encountered in true_divide) when combining echoes with PAID. If your datasets have voxels with zeros, e.g., if they were masked, a division by 0 will lead to infinite weights. You may safely ignore the warning, but do check your data after the combination.

By default, PAID will compute the weights based on the last 100 volumes of the acquisition. Whether this is optimal or not is up to discussion. If you are testing out the combination on a small subset of volumes, say 5 or so, then the weights won't be stable and your image may look noisy.

Metadata

Release files for multiecho 0.31

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multiecho 0.31
File Size Uploaded Provenance Actions
multiecho-0.31.tar.gz 12.2 kB Without provenance Details for multiecho-0.31.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for multiecho 0.31
File Interpreter ABI Platform Actions
multiecho-0.31-py3-none-any.whl Python 3 none any Details for multiecho-0.31-py3-none-any.whl

Total release size: 25.9 kB

Release files / multiecho-0.31.tar.gz

Download URL multiecho-0.31.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0c853ddd8aaff8137410077e24d03cd63dade70c0b4c9da122fc573c415af28d
BLAKE2b-256 checksum
How to use checksums
6500c6aa8825481a59623c35cbc2522acb546cab4c658bf4c0f58679bbc7a02e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Release files / multiecho-0.31-py3-none-any.whl

Download URL multiecho-0.31-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82effc2ed25a6e2e81807ecbeca14499de1e137c3214fd4ca261bca1b5bcce32
BLAKE2b-256 checksum
How to use checksums
48706698c0f6cf9752c85fcfb51054d8e71f04876fcf24b6df95a300ec69d5f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Security for multiecho 0.31

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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