Menu

Package that provides tools for brain MRI Deep Learning pre-processing.

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the gallery for the big picture.

brainprep.spatial.biasfield(imfile, bfcfile, maskfile=None, nb_iterations=50, convergence_threshold=0.001, bspline_grid=(1, 1, 1), shrink_factor=1, bspline_order=3, histogram_sharpening=(0.15, 0.01, 200), check_pkg_version=False)[source]ΒΆ

Perform MRI bias field correction using N4 algorithm.

Note

This function is based on ANTS.

Parameters:

imfile : str

the input image.

bfcfile : str

the bias fieled corrected file.

maskfile : str, default None

the brain mask image.

nb_iterations : int, default 50

Maximum number of iterations at each level of resolution. Larger values will increase execution time, but may lead to better results.

convergence_threshold : float, default 0.001

Stopping criterion for the iterative bias estimation. Larger values will lead to smaller execution time.

bspline_grid : int, default (1, 1, 1)

Resolution of the initial bspline grid defined as a sequence of three numbers. The actual resolution will be defined by adding the bspline order (default is 3) to the resolution in each dimension specified here. For example, 1,1,1 will result in a 4x4x4 grid of control points. This parameter may need to be adjusted based on your input image. In the multi-resolution N4 framework, the resolution of the bspline grid at subsequent iterations will be doubled. The number of resolutions is implicitly defined by Number of iterations parameter (the size of this list is the number of resolutions).

shrink_factor : int, default 1

Defines how much the image should be upsampled before estimating the inhomogeneity field. Increase if you want to reduce the execution time. 1 corresponds to the original resolution. Larger values will significantly reduce the computation time.

bspline_order : int, default 3

Order of B-spline used in the approximation. Larger values will lead to longer execution times, may result in overfitting and poor result.

histogram_sharpening : 3-uplate, default (0.15, 0.01, 200)

A vector of up to three values. Non-zero values correspond to Bias Field Full Width at Half Maximum, Wiener filter noise, and Number of histogram bins.

check_pkg_version : bool, default False

optionally check the package version using dpkg.

Returns:

bfcfile, bffile : str

the generatedd files.

Follow us

© 2025, brainprep developers