# sitk Commands for N4

**URL:** https://discourse.itk.org/t/sitk-commands-for-n4/5465
**Category:** Beginner Questions
**Created:** [November 3, 2022, 11:38am UTC](https://discourse.itk.org/t/sitk-commands-for-n4/5465 "2022-11-03T11:38:36Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![spinicist](https://discourse.itk.org/user_avatar/discourse.itk.org/spinicist/32/183_2.png) [@spinicist](https://discourse.itk.org/u/spinicist)
#### Post date: [November 3, 2022, 11:38am UTC](https://discourse.itk.org/t/sitk-commands-for-n4/5465/1 "2022-11-03T11:38:36Z")

</div>

Hello,

I’d like to add loggin for N4BiasFieldCorrection in sitk, similar to that printed out by the ANTs version.

However, it looks like the `GetCurrentConvergenceMeasurement` and `GetCurrentLevel` methods are not currently wrapped by sitk? Have I understood this correctly? Is there any other way to get this information?

Thanks in advance.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 3, 2022, 11:49am UTC](https://discourse.itk.org/t/sitk-commands-for-n4/5465/2 "2022-11-03T11:49:06Z")

</div>

Hello @spinicist,

I believe these additional metrics can be easily added to the SimpleITK class. Can you please create a [GitHub issue](https://github.com/SimpleITK/SimpleITK/issues) for the feature request.

---

<div class="post-metadata">

### Author: ![spinicist](https://discourse.itk.org/user_avatar/discourse.itk.org/spinicist/32/183_2.png) [@spinicist](https://discourse.itk.org/u/spinicist)
#### Post date: [November 3, 2022, 12:43pm UTC](https://discourse.itk.org/t/sitk-commands-for-n4/5465/3 "2022-11-03T12:43:58Z")

</div>

Here you go: [Missing Logging Methods · Issue #1758 · SimpleITK/SimpleITK · GitHub](https://github.com/SimpleITK/SimpleITK/issues/1758)

Thanks!

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 9, 2022, 1:44pm UTC](https://discourse.itk.org/t/sitk-commands-for-n4/5465/4 "2022-11-09T13:44:53Z")

</div>

This feature has been added to SimpleITK: [N4 add observation metrics by blowekamp · Pull Request #1760 · SimpleITK/SimpleITK · GitHub](https://github.com/SimpleITK/SimpleITK/pull/1760)

---

<div class="post-metadata">

### Author: ![spinicist](https://discourse.itk.org/user_avatar/discourse.itk.org/spinicist/32/183_2.png) [@spinicist](https://discourse.itk.org/u/spinicist)
#### Post date: [November 15, 2022, 2:42pm UTC](https://discourse.itk.org/t/sitk-commands-for-n4/5465/5 "2022-11-15T14:42:42Z")

</div>

Thanks @blowekamp. Much appreciated.

I want to feed back that in the process of investigating this, my student and I found significant differences of the output of N4 using the parameters as suggested in the `sitk` example, the command-line version of the ANTs N4 wrapper, and the Python wrapped version of ANTs N4 (maybe a version issue between the latter two). The Python wrapped ANTs performed best. I wonder if it would be helpful to update the `sitk` N4 example to resemble the ANTs default parameters?

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 15, 2022, 3:06pm UTC](https://discourse.itk.org/t/sitk-commands-for-n4/5465/6 "2022-11-15T15:06:35Z")

</div>

Do you have a link to the default python ANTs parameters?

A PR to make the changes to the example is welcomed.

---

<div class="post-metadata">

### Author: ![spinicist](https://discourse.itk.org/user_avatar/discourse.itk.org/spinicist/32/183_2.png) [@spinicist](https://discourse.itk.org/u/spinicist)
#### Post date: [November 15, 2022, 9:05pm UTC](https://discourse.itk.org/t/sitk-commands-for-n4/5465/7 "2022-11-15T21:05:07Z")

</div>

The ANTsPy wrapper is here: [ANTsPy/bias\_correction.py at master · ANTsX/ANTsPy · GitHub](https://github.com/ANTsX/ANTsPy/blob/master/ants/utils/bias_correction.py#L161)

Annoyingly I think some spelunking in the ANTs C++ code is required to figure out how the defaults in the Python code interact with the executable. Off the top of my head I think spline parameter and convergence threshold aren’t the same as the ANTs command-line.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 17, 2022, 4:37pm UTC](https://discourse.itk.org/t/sitk-commands-for-n4/5465/8 "2022-11-17T16:37:19Z")

</div>

Many of the defaults in the SimpleITK Example come form the ITK filter defaults. The “spline parameter” or “NumberOfControlPoints” looks like it defaults to 4 in the ITK/SimpleITK filter and example but ANTs is using 200? There are like more parameters that are different. The goal of SimpleITK is not to provide turnkey programs/scripts for a particular application but to provide algorithms and an API that can be used to develop a script of program to solve a particular set of problems.

However help it improving the usability and generalization of the example is still welcomed.
