Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: default n3 / n4 spline mesh size of 1 #457

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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