Skip to content

Commit

Permalink
Merge pull request #457 from ANTsX/n4SplineDefault
Browse files Browse the repository at this point in the history
ENH: default n3 / n4 spline mesh size of 1
  • Loading branch information
cookpa authored Apr 25, 2023
2 parents cd808ed + 87dd109 commit e48677c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ants/utils/bias_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def n3_bias_field_correction2(
rescale_intensities=False,
shrink_factor=4,
convergence={"iters": 50, "tol": 1e-7},
spline_param=200,
spline_param=None,
number_of_fitting_levels=4,
return_bias_field=False,
verbose=False,
Expand Down Expand Up @@ -84,7 +84,7 @@ def n3_bias_field_correction2(
spline_param : float or vector Parameter controlling number of control
points in spline. Either single value, indicating the spacing in each
direction, or vector with one entry per dimension of image, indicating
the mesh size.
the mesh size. If None, defaults to mesh size of 1 in all dimensions.
number_of_fitting_levels : integer
Number of fitting levels per iteration.
Expand Down Expand Up @@ -113,6 +113,8 @@ def n3_bias_field_correction2(
tol = convergence["tol"]
if mask is None:
mask = get_mask(image)
if spline_param is None:
spline_param = [1] * image.dimension

N3_CONVERGENCE_1 = "[%i,%.10f]" % (iters, tol)
N3_SHRINK_FACTOR_1 = str(shrink_factor)
Expand Down Expand Up @@ -164,7 +166,7 @@ def n4_bias_field_correction(
rescale_intensities=False,
shrink_factor=4,
convergence={"iters": [50, 50, 50, 50], "tol": 1e-7},
spline_param=200,
spline_param=None,
return_bias_field=False,
verbose=False,
weight_mask=None,
Expand Down Expand Up @@ -201,7 +203,8 @@ def n4_bias_field_correction(
spline_param : float or vector
Parameter controlling number of control points in spline. Either single value,
indicating the spacing in each direction, or vector with one entry per
dimension of image, indicating the mesh size.
dimension of image, indicating the mesh size. If None, defaults to mesh size of 1 in all
dimensions.
return_bias_field : boolean
Return bias field instead of bias corrected image.
Expand All @@ -227,6 +230,8 @@ def n4_bias_field_correction(
tol = convergence["tol"]
if mask is None:
mask = get_mask(image)
if spline_param is None:
spline_param = [1] * image.dimension

N4_CONVERGENCE_1 = "[%s, %.10f]" % ("x".join([str(it) for it in iters]), tol)
N4_SHRINK_FACTOR_1 = str(shrink_factor)
Expand Down

0 comments on commit e48677c

Please sign in to comment.