# N4 bias field correction - Can't find "spline spacing" in simpleITK

**URL:** <https://discourse.itk.org/t/n4-bias-field-correction-cant-find-spline-spacing-in-simpleitk/6267>\
**Category:** Algorithms\
**Tags:** n4biasfield, simpleitk, python\
**Created:** [October 28, 2023, 2:18pm UTC](https://discourse.itk.org/t/n4-bias-field-correction-cant-find-spline-spacing-in-simpleitk/6267 "2023-10-28T14:18:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonkeln](https://discourse.itk.org/letter_avatar_proxy/v4/letter/t/dc4da7/32.png) [@tonkeln](https://discourse.itk.org/u/tonkeln)\
**Post date:** [October 28, 2023, 2:18pm UTC](https://discourse.itk.org/t/n4-bias-field-correction-cant-find-spline-spacing-in-simpleitk/6267/1 "2023-10-28T14:18:30Z")

</div>

Hello everyone,

In 3D Slicer (and ANTs) there is the parameter “spline spacing” or “spline distance” to define the distance between control points for the N4 bias field correction.  
I would like to reproduce a paper where a spline distance of 200 is used (ANTs), but I can’t find the parameter in simpleITK.  
The N4BiasFieldCorrectionImageFilter only has the parameter " SetNumberOfControlPoints".  
Does anyone have a solution for this problem?

Many thanks,  
Sebastian

---

<div class="post-metadata">

**Author:** ![ntustison](https://discourse.itk.org/user_avatar/discourse.itk.org/ntustison/32/462_2.png) [@ntustison](https://discourse.itk.org/u/ntustison)\
**Post date:** [October 29, 2023, 3:33am UTC](https://discourse.itk.org/t/n4-bias-field-correction-cant-find-spline-spacing-in-simpleitk/6267/2 "2023-10-29T03:33:43Z")

</div>

In ANTs, we pad the images to get close to get as close as possible to the specified spline distance parameter, consistent with the original N3 algorithm. [Here’s the relevant code snippet](https://github.com/ANTsX/ANTs/blob/master/Examples/N4BiasFieldCorrection.cxx#L253-L284) which should be straightforward to port to simpleITK.

The reason why we do it this way is B-spline fitting and reconstruction is much more computationally efficient if done directly in the sampled image space.

---

<div class="post-metadata">

**Author:** ![tonkeln](https://discourse.itk.org/letter_avatar_proxy/v4/letter/t/dc4da7/32.png) [@tonkeln](https://discourse.itk.org/u/tonkeln)\
**Post date:** [October 29, 2023, 11:43am UTC](https://discourse.itk.org/t/n4-bias-field-correction-cant-find-spline-spacing-in-simpleitk/6267/3 "2023-10-29T11:43:09Z")

</div>

Many thanks for the answer! I am using simpleITK in python and have no knowledge of C++. Is there a corresponding code snippit in ANTsPy? I did not find it on github.

---

<div class="post-metadata">

**Author:** ![ntustison](https://discourse.itk.org/user_avatar/discourse.itk.org/ntustison/32/462_2.png) [@ntustison](https://discourse.itk.org/u/ntustison)\
**Post date:** [October 29, 2023, 11:10pm UTC](https://discourse.itk.org/t/n4-bias-field-correction-cant-find-spline-spacing-in-simpleitk/6267/4 "2023-10-29T23:10:17Z")

</div>

No, as it directly interfaces with the C++ front-end I linked to. However, the code should be easy to understand even with no knowledge of C++. It’s just using the image geometry to calculate the necessary pad lower and upper bound sizes and then calling the equivalent of `sitk::ConstantPad(...)`.

---

<div class="post-metadata">

**Author:** ![tonkeln](https://discourse.itk.org/letter_avatar_proxy/v4/letter/t/dc4da7/32.png) [@tonkeln](https://discourse.itk.org/u/tonkeln)\
**Post date:** [October 30, 2023, 10:25am UTC](https://discourse.itk.org/t/n4-bias-field-correction-cant-find-spline-spacing-in-simpleitk/6267/5 "2023-10-30T10:25:40Z")

</div>

Thanks I will try it out!
