Skip to main content

NX Bias Correction. NIfTI image bias correction, implementation of N3 (Sled) and N4 (Tustison) algorithms

Project description

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.

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

nxbc-0.2.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

nxbc-0.2.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file nxbc-0.2.0.tar.gz.

File metadata

  • Download URL: nxbc-0.2.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for nxbc-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6e5db9a459c070e524f9d1ea8b1925b0274e400fa81193928d40f8c8bc1aca26
MD5 fb1c9613698ffbc8dd1b5d80ff6f27ad
BLAKE2b-256 3b1302e3e4817d495c8f0e11faee7b19d453485e91b9f39335e710d24f8ad6bc

See more details on using hashes here.

File details

Details for the file nxbc-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: nxbc-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for nxbc-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f815c152822f513d5dad667669770c7ef2afd6b8103a9f9cffcb03d0c01d805
MD5 7f8cd71555c723181767fd31e87d3c35
BLAKE2b-256 e72b2bc3a8a1c6acf8cb520b71560a4710e60c8600fdb0df316cda4ecf556f68

See more details on using hashes here.

Supported by

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