<?xml version="1.0" encoding="utf-8"?>
<executable>
  <category>Segmentation.Specialized</category>
  <title>Foreground masking (BRAINS)</title>
  <description>This program is used to create a mask over the most prominent foreground region in an image.  This is accomplished via a combination of otsu thresholding and a closing operation.
  </description>
  <version>5.4.0</version>
  <documentation-url>https://slicer.readthedocs.io/en/latest/user_guide/modules/brainsroiauto.html</documentation-url>
  <license>https://www.nitrc.org/svn/brains/BuildScripts/trunk/License.txt</license>
  <contributor>Hans J. Johnson, hans-johnson -at- uiowa.edu, https://www.psychiatry.uiowa.edu</contributor>
  <acknowledgements>Hans Johnson(1,3,4); Kent Williams(1); Gregory Harris(1), Vincent Magnotta(1,2,3);  Andriy Fedorov(5), fedorov -at- bwh.harvard.edu (Slicer integration); (1=University of Iowa Department of Psychiatry, 2=University of Iowa Department of Radiology, 3=University of Iowa Department of Biomedical Engineering, 4=University of Iowa Department of Electrical and Computer Engineering, 5=Surgical Planning Lab, Harvard)  </acknowledgements>
  <parameters advanced="false">
    <label>IO</label>
    <description>Input/output parameters</description>
    <image>
      <name>inputVolume</name>
      <longflag>inputVolume</longflag>
      <label>Input Image Volume</label>
      <description>The input image for finding the largest region filled mask.</description>
      <channel>input</channel>
    </image>
    <image type="label">
      <name>outputROIMaskVolume</name>
      <longflag>outputROIMaskVolume</longflag>
      <label>Output Mask</label>
      <description>The ROI automatically found from the input image.</description>
      <channel>output</channel>
    </image>
    <image>
      <name>outputVolume</name>
      <longflag>outputVolume</longflag>
      <label>Output Image</label>
      <description>The inputVolume with optional [maskOutput|cropOutput] to the region of the brain mask.</description>
      <channel>output</channel>
    </image>
    <boolean>
      <name>maskOutput</name>
      <longflag>maskOutput</longflag>
      <label>Mask Output</label>
      <description>The inputVolume multiplied by the ROI mask.</description>
      <default>true</default>
    </boolean>
    <boolean>
      <name>cropOutput</name>
      <longflag>cropOutput</longflag>
      <label>Output Image Clipped by ROI</label>
      <description>The inputVolume cropped to the region of the ROI mask.</description>
      <default>false</default>
    </boolean>
  </parameters>

  <parameters advanced="false">
    <label>Configuration Parameters</label>

    <double>
      <name>otsuPercentileThreshold</name>
      <longflag>otsuPercentileThreshold</longflag>
      <label>Otsu Percentile Threshold</label>
      <description>Parameter to the Otsu threshold algorithm.</description>
      <default>0.01</default>
    </double>

    <double>
      <name>thresholdCorrectionFactor</name>
      <longflag>thresholdCorrectionFactor</longflag>
      <label>Otsu Correction Factor</label>
      <description>A factor to scale the Otsu algorithm's result threshold, in case clipping mangles the image.</description>
      <default>1.0</default>
    </double>

    <double>
      <name>closingSize</name>
      <longflag>closingSize</longflag>
      <label>Closing Size</label>
      <description>The Closing Size (in millimeters) for largest connected filled mask.  This value is divided by image spacing and rounded to the next largest voxel number.</description>
      <default>9.0</default>
    </double>

    <double>
      <name>ROIAutoDilateSize</name>
      <longflag>ROIAutoDilateSize</longflag>
      <label>ROIAuto Dilate Size</label>
      <description>This flag is only relevant when using ROIAUTO mode for initializing masks.  It defines the final dilation size to capture a bit of background outside the tissue region.  At setting of 10mm has been shown to help regularize a BSpline registration type so that there is some background constraints to match the edges of the head better.</description>
      <default>0.0</default>
    </double>

    <string-enumeration>
      <name>outputVolumePixelType</name>
      <longflag>outputVolumePixelType</longflag>
      <label>Output Image Pixel Type</label>
      <description>The output image Pixel Type is the scalar datatype for representation of the Output Volume.</description>
      <default>short</default>
      <element>float</element>
      <element>short</element>
      <element>ushort</element>
      <element>int</element>
      <element>uint</element>
      <element>uchar</element>
    </string-enumeration>
    <integer>
      <name>numberOfThreads</name>
      <longflag deprecatedalias="debugNumberOfThreads" >numberOfThreads</longflag>
      <label>Number Of Threads</label>
      <description>Explicitly specify the maximum number of threads to use.</description>
      <default>-1</default>
    </integer>
  </parameters>
</executable>
