Skip to main content

NX Bias Correction

This module provides 3D bias correction for NIfTI (.nii/.nii.gz) images based on the N3 and N4 algorithms. It provides a simple command to apply N3 and N4, as well as a platform to further develop the algorithms.

Requires https://github.com/imalone/SplineSmooth3D

Straightforward N3 with a default Otsu mask:

nxbc -i image.nii.gz -o imagenorm.nii.gz

Recommended N3 using brain masking:

nxbc -a niftytools -i image.nii.gz -o imagenorm.nii.gz

This mode requires FSL to be installed, as well as NiftyReg and NiftySeg.

Alternative modes for automated brain masking are -a flirt (requires FSL only) and -a ants (requires python packages antspyx and templateflow). These are less well tested and it is worth checking the mask generated (also possible for -a niftytools):

nxbc -a ants -i image.nii.gz -o imagenorm.nii.gz --outmask imagemask.nii.gz

Options

nxbc is intended to allow experimentation with the N3/N4 algorithm class, which means there are a lot of options that may not be useful to the average user. Some of the more useful ones:

  • -h/--help Show help
  • -i/--infile Input image
  • -a/--automask Brain masking method, options are flirt, niftytools, ants and niftytoolsreplicate (for replicating original results)
  • -m/--mask Input mask image
  • -o/--outfile Output image
  • --outmask Output mask image
  • --N4 use N4 mode
  • -l/--maxlevel maximum level, in N4 mode the number of levels to use

Options that will be familiar to N3 and N4 users:

  • --Lambda/-L spline smoothing lambda, default 1 as in MINC N3 version<=1.11
  • -b/--bfield Output bias field image
  • --fwhm Full Width Half Maximum of the log intensity histogram deconvolution
  • --nbins Number of bins for histogram deconvolution
  • -Z noise estimate for histogram deconvolution
  • -r subsampling factor, default 2 (MINC -shrink option)
  • -d/--dist Control point spacing, default 75mm

The default 75mm control point distance is intended to be more appropriate for 3T MP-RAGE images in line with Boyes et al. 2008, which suggests a distance in the range 50-100mm. Template mask registration prior to bias correction is also due to Boyes et al.

From version 1.11 to 1.12 MINC nu_correct changed from an interpretation of Lambda measured over the whole volume to one scaled by number of voxels. The default Lambda thus changed from 1.0 (as in the original N3 paper by Sled et al.) to 1.0e-7. For a common MPRAGE volume size of 240x256x208 voxels this would result in an effective total lambda of ~1.28, however this varies as the number of voxels included in bias correction is always less (often much less) than the total in the image. nxbc currently uses the MINC<=1.11 global lambda with a default of 1.0.

Metadata

Release files for nxbc 0.2.0

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

Source distribution (sdist)

Source distribution for nxbc 0.2.0
File Size Uploaded
nxbc-0.2.0.tar.gz 20.4 kB Details

Built distribution (wheel)

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

Total release size: 42.2 kB

Release files / nxbc-0.2.0.tar.gz

Download URL nxbc-0.2.0.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6e5db9a459c070e524f9d1ea8b1925b0274e400fa81193928d40f8c8bc1aca26
BLAKE2b-256 checksum
How to use checksums
3b1302e3e4817d495c8f0e11faee7b19d453485e91b9f39335e710d24f8ad6bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / nxbc-0.2.0-py3-none-any.whl

Download URL nxbc-0.2.0-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f815c152822f513d5dad667669770c7ef2afd6b8103a9f9cffcb03d0c01d805
BLAKE2b-256 checksum
How to use checksums
e72b2bc3a8a1c6acf8cb520b71560a4710e60c8600fdb0df316cda4ecf556f68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.2

2 release 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