Skip to content

Repository files navigation

intensity-normalization

PyPI Docs

Normalize the intensities of magnetic resonance (MR) images — T1-w, T2-w, FLAIR, PD-w — across scanners, sites, and sessions.

MR images have no consistent intensity scale; the inconsistency is an acquisition artifact that breaks downstream processing (especially ML). This package implements the standard fixes:

  • Individual methodszscore, fcm, kde, whitestripe: plain functions of one image.
  • Population methodsnyul, lsq, ravel: learn a transform from a set of images; save it, apply it to new scans.
  • Tools — tissue membership maps, histogram plotting (validation), N4 preprocessing, co-registration (ANTs).

Install

pip install intensity-normalization            # or: uv add intensity-normalization
pip install "intensity-normalization[ants]"  # ravel registration, preprocess, coregister
pip install "intensity-normalization[plot]"  # histogram plotting

The CLI also runs without installing: uvx intensity-normalize --help.

Quickstart

import intensity_normalization as inorm

normed = inorm.whitestripe(t1w_image, mask=brain_mask)  # numpy or nibabel in → same type out

tx = inorm.nyul.fit(train_images, masks=train_masks)  # population: fit once...
tx.save("nyul.npz")
normed_new = tx(new_image)  # ...apply to new scans
intensity-normalize fcm t1w.nii.gz -m brain_mask.nii.gz -p
intensity-normalize nyul images/ -m masks/ -o normalized/ --save-state nyul.npz

Documentationquickstart, how-to guides, choosing a method, algorithms, CLI, API, migrating to v4.

Reference

If you use this package, please cite the accompanying pre-print:

@article{reinhold2019evaluating,
  title={Evaluating the impact of intensity normalization on MR image synthesis},
  author={Reinhold, Jacob C and Dewey, Blake E and Carass, Aaron and Prince, Jerry L},
  journal={Medical Imaging 2019: Image Processing},
  year={2019}
}

License

MIT

Releases

Used by

Contributors

Languages