Personal tools
  • Help

brains:ITK Scripting

From NITRC Wiki

Jump to: navigation, search

Return to brains:MainPage


Summary

BRAINS uses the WrapITK utilities to generate the TCL bindings. Many of the ITK filters are exposed using this method, and most of the class methods are available. However, not all classes and methods are available. WrapITK flattens C++ namespaces, therefore the syntax is slightly different. In the flattened namespace, a separate type is allowed for each of the template parameters. Here is an example.


RecursiveGaussianImageFilter Example

In this example we will create a new filter in TCL for the ITK RecursiveGaussianImageFilter. Looking at the C++ documentation, the filter is defined as follows:

  • itk::RecursiveGaussianImageFilter< TInputImage, TOutputImage >


By flattening the namespaces in TCL, this becomes

  • itkRecursiveGaussianImageFilter

No we have to handle the image types. Most filters are wrapped for unsigned-8bit, signed-16bit, and single precision floating point image types. These types are shortened to the following strings in WrapITK

  • IUC - Unsigned 8 bit
  • ISS - Signed 16 bit
  • IF - Single precision floating point

Finally, we need to handle the dimension. This can be either 2D or 3D. This makes the declaration of the filter as follows

brains3% set filter [itkRecursiveGaussianImageFilterISS3ISS3_New]
brains3% $filter SetDirection 0
brains3% $filter SetSigma 2.0
brains3% $filter Update
brains3% set resultImage [$filter GetOutput]


Simplified BRAINS ITK TCL Interface

  • Brains::itk::AndImage image1 image2
    • AND two integral images together. This is always pairwise unlike brains2 where N images could be specified simultaneously
  • Brains::itk::CastImage inputImage outputDataType
    • Cast an image between different pixel type representations. The keywords for the datatypes are:
      • Unsigned-8bit
      • Signed-16bit
      • Float-single
  • Brains::itk::ClipImage inputImage clipRegion backgroundValue
    • Clip an Image to the area specified by region. This procedure uses the PasteImageFilter.
  • Brains::itk::ImageMath inputImage1 inputImage2 operation outputDataType
    1. Add
    2. Subtract
    3. Multiply
    4. Divide
    5. Maximum
    6. Minimum
  • Brains::itk::ObjectMorphology {inputImage operation structureType radius {outputDataType Image-Type}
  • Brains::itk::GrayscaleMorphology {inputImage operation structureType radius {outputDataType Image-Type}
    • Perform the specified morhpology operation on a grayscale image. The radius of the structuring element is specified in mm and converted internally to voxels.
      • Operations:
        • Erode
        • Dilate
      • Element:
        • Ball
        • Box
      • Data-Types:
        • Unsigned-8bit
        • Signed-16bit
        • Unsigned-16bit
        • Float-single
  • Brains::itk::BinaryImageMorphology {inputImage operation structureType closingSize}
  • Brains::itk::IntensityWindowingImage {inputImage minValue maxValue windowMinValue windowMaxValue
  • Brains::itk::LoadImage ImageFileName DataType
  • Brains::itk::MaskImage inputImage inputMask outsideValue
  • Brains::itk::measureVolumeLabelImage inputImage
  • Brains::itk::measureLabelImageStatistics labelMap inputImage
  • Brains::itk::measureImageStatistics inputImage
  • Brains::itk::NotImage inputImage
  • Brains::itk::OrImage inputImage1 inputImage2
  • Brains::itk::RegionOfInterestImage inputImage roi
  • Brains::itk::ResampleImage inputImage transform outputDataType interpolatorType resolutions dimensions origin
  • Brains::itk::ResampleImageWithReferenceImage inputImage transform referenceImage interpolatorType RequestedDataType DefaultPixelValue>
  • Brains::itk::RelabelComponentImage inputImage minimumObjectSize
  • Brains::itk::RescaleImage inputImage outputDataType minValue maxValue
  • Brains::itk::SaveImage inputImage ImageFileName
  • Brains::itk::ShiftScaleImage inputImage shift scale
  • Brains::itk::BinaryThresholdImage inputImage lowerThreshold upperThreshold invertFlag OutputDataType
  • Brains::itk::ThresholdImage inputImage minValue maxValue outsideValue

  1. Brains::itk::PerimeterContrastThresholdImage inputImage lowerThreshold upperThreshold insideValue outsideValue
  • Brains::itk::SignedDistanceImage inputImage
  • Brains::itk::ConnectedComponentImage inputImage
  • Brains::itk::ConnectedThresholdImageFilterWithCornerSeeds inputImage lowerThreshold upperThreshold replaceValue
  • Brains::itk::JointCommonMaskEstimationFromSTAPLEFilter MaskFileNameList OutputImageFile
  • Brains::itk::readTransform filename
  • Brains::itk::MedianImageFilter InputImage size
  • Brains::itk::GrayScaleFillHoleImageFilter InputImage fullyConnected
  • Brains::itk::ImageRegion Dimensions Size Index

Memory management is slightly more complicated in TCL. You must register the resulting image before deleting the filter. The following two commands would handle this in the above example.

 brains3% $resultImage Register
 brains3% $filter Delete
Powered by MediaWiki
  • This page was last modified 22:48, 10 December 2010.
  • This page has been accessed 2,012 times.
  •