<?xml version="1.0" encoding="UTF-8"?>
<executable>
  <category>Filtering</category>
  <title>N4ITK MRI Bias correction</title>
  <index>3</index>
  <description><![CDATA[Performs image bias correction using N4 algorithm. This module is based on the ITK filters contributed in the following publication:  Tustison N, Gee J "N4ITK: Nick's N3 ITK Implementation For MRI Bias Field Correction", The Insight Journal 2009 January-June, https://hdl.handle.net/10380/3053]]></description>
  <version>9</version>
  <documentation-url>https://slicer.readthedocs.io/en/latest/user_guide/modules/orientscalarvolume.html</documentation-url>
  <license/>
  <contributor>Nick Tustison (UPenn), Andrey Fedorov (SPL, BWH), Ron Kikinis (SPL, BWH)</contributor>
  <acknowledgements><![CDATA[The development of this module was partially supported by NIH grants R01 AA016748-01, R01 CA111288 and U01 CA151261 as well as by NA-MIC, NAC, NCIGT and the Slicer community.]]></acknowledgements>
  <parameters>
    <label>IO</label>
    <description><![CDATA[Input/output parameters]]></description>
    <image>
      <name>inputImageName</name>
      <label>Input Image</label>
      <channel>input</channel>
      <index>0</index>
      <description><![CDATA[Input image where you observe signal inhomegeneity]]></description>
    </image>
    <image>
      <longflag>maskimage</longflag>
      <name>maskImageName</name>
      <label>Mask Image</label>
      <channel>input</channel>
      <description><![CDATA[Binary mask that defines the structure of your interest. NOTE: This parameter is OPTIONAL. If the mask is not specified, the module will use internally Otsu thresholding to define this mask. Better processing results can often be obtained when a meaningful mask is defined.]]></description>
    </image>
    <image reference="inputImageName">
      <name>outputImageName</name>
      <label>Output Volume</label>
      <channel>output</channel>
      <index>1</index>
      <description><![CDATA[Result of processing]]></description>
    </image>
    <image reference="inputImageName">
      <longflag>outputbiasfield</longflag>
      <name>outputBiasFieldName</name>
      <label>Output bias field image</label>
      <channel>output</channel>
      <description><![CDATA[Recovered bias field (OPTIONAL)]]></description>
    </image>
  </parameters>
  <parameters>
    <label>N4 Parameters</label>
    <float-vector>
      <name>initialMeshResolution</name>
      <longflag>meshresolution</longflag>
      <label>BSpline grid resolution</label>
      <description><![CDATA[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)]]></description>
      <default>1,1,1</default>
    </float-vector>
    <float>
      <name>splineDistance</name>
      <longflag>splinedistance</longflag>
      <label>Spline distance</label>
      <description><![CDATA[An alternative means to define the spline grid, by setting the distance between the control points. This parameter is used only if the grid resolution is not specified.]]></description>
      <default>0</default>
    </float>

    <float>
      <name>bfFWHM</name>
      <longflag>bffwhm</longflag>
      <label>Bias field Full Width at Half Maximum</label>
      <description><![CDATA[Bias field Full Width at Half Maximum. Zero implies use of the default value.]]></description>
      <default>0</default>
    </float>

  </parameters>
  <parameters advanced="true">
    <label>Advanced N4 Parameters</label>
    <description><![CDATA[Advanced parameters of the algorithm]]></description>

    <integer-vector>
      <name>numberOfIterations</name>
      <longflag>iterations</longflag>
      <label>Number of iterations</label>
      <description><![CDATA[Maximum number of iterations at each level of resolution. Larger values will increase execution time, but may lead to better results.]]></description>
      <default>50,40,30</default>
    </integer-vector>
    <float>
      <name>convergenceThreshold</name>
      <longflag>convergencethreshold</longflag>
      <label>Convergence threshold</label>
      <description><![CDATA[Stopping criterion for the iterative bias estimation. Larger values will lead to smaller execution time.]]></description>
      <default>0.0001</default>
    </float>

    <integer>
      <name>bsplineOrder</name>
      <longflag>bsplineorder</longflag>
      <label>BSpline order</label>
      <description><![CDATA[Order of B-spline used in the approximation. Larger values will lead to longer execution times, may result in overfitting and poor result.]]></description>
      <default>3</default>
    </integer>

    <integer>
      <name>shrinkFactor</name>
      <longflag>shrinkfactor</longflag>
      <label>Shrink factor</label>
      <description><![CDATA[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.]]></description>
      <default>4</default>
    </integer>

    <image>
      <longflag>weightimage</longflag>
      <name>weightImageName</name>
      <label>Weight Image</label>
      <channel>input</channel>
      <description><![CDATA[Weight Image]]></description>
    </image>

    <float>
      <name>wienerFilterNoise</name>
      <longflag>wienerfilternoise</longflag>
      <label>Wiener filter noise</label>
      <description><![CDATA[Wiener filter noise. Zero implies use of the default value.]]></description>
      <default>0</default>
    </float>

    <integer>
      <name>nHistogramBins</name>
      <longflag>nhistogrambins</longflag>
      <label>Number of histogram bins</label>
      <description><![CDATA[Number of histogram bins. Zero implies use of the default value.]]></description>
      <default>0</default>
    </integer>

  </parameters>
</executable>
