<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Change SYSTEM "https://itk.org/migrationv4/ITKMigration.dtd">

<!--**
**
** MultiPrecisionVersionOfITK.xml
**
** Please, make sure this file validates the following w3c test before committing it: http://validator.w3.org
**-->
<Change>
    <!--**
    ** Title for the online migration page
    **-->
    <Title>
      Multi Precision Version of ITK
    </Title>

    <!--**
    ** The author of the change
    **-->
    <Author>
      Ali Ghayoor
    </Author>

    <!--**
    ** Date of creation for the XML document
    **-->
    <Date>
      2013-06-06
    </Date>

    <!--**
    ** Plain text description of the change
    ** Extracted from git commit messages
    **-->
    <Description>
      <![CDATA[
      Float Type for Transform Classes and Registration Framework of ITKv4

      The current registration framework of ITK just can process data using double
      precision. However, in some cases using &apos;float&apos; type is enough for the
      precision of computations.

      This feature allows the CPU to process more data in its cache in a limited
      period of time, so it can increase the computation speed.
      Also, writing outputs to the disk using single precision needs much less memory
      than when we save them in double precision.
      Saving memory space is especially important when our outputs are huge
      files that need hundreds of gigabytes of disk space. An example of
      such outputs are transform files that contain several deformation fields.

      We need many changes in several files of ITK to make that consistent
      with this new feature.
      The following provides a short description of the main obstacles and the
      ways that are used to tackle them:

      I) One of the main obstacles to computation in single precision
      is the definition of &quot;ParametersValueType&quot; in the &quot;itkTransformBase&quot; class,
      which is hard coded to &apos;double&apos;.

      This issue can be solved by re-definition of the itkTransformBase class as
      a template class over the internal computation type e.g.
      &quot;itkTransformBaseTemplate&amp;lt;ParametersValueType&gt;&quot;. The template parameter
      can be set to &apos;float&apos; or &apos;double&apos;.

      Also, to keep backward compatiblity, we define the original
      TransformBase after the definition of this new template class as:

      &gt;&gt; typedef TransformBaseTemplate&amp;lt;double&gt; TransformBase;

      At the lower levels of the class hierarchy, we are not worried about the other
      transform classes because they are already defined as a template over
      the &apos;ScalarType&apos;, so the backward compatibility issues are automatically
      solved for them.
      Also for the IO classes that are related to Reading/Writing transforms,
      we use the same procedure used for TransformBase class.

      While backward compatibility is met, we can use this new set of classes
      to write more flexible programs that can support both single and double precision
      for their internal computations.

      II) The second main obstacle is that &quot;ParametersValueType&quot; is hard
      coded as &apos;double&apos; in &quot;itkCostFunction&quot; base class.

      Therefore, I changed all the Metric and Optimizer classes the same way that
      I did for transform IO classes.

      All these classes are modified in a way such that minimal changes are needed
      from the original version of ITK.
      In many of them just a new template parameter is added as
      &quot;TInternalComputationValueType&quot; that is set to double as default.

      PS: New templated versions of metric and optimizer classes we added in ITK 4.0.
      ]]>
    </Description>

    <!--**
    ** Sample code snippets
    ** Extracted from git diff of changed files in Examples and Testing
    **-->
  <SampleCode>
    <Old>
      <![CDATA[
        typedef TransformFileWriter   WriterType;
        typedef TransformFileReader   ReaderType;
      ]]>
    </Old>

    <New>
      <![CDATA[
        /* transform file read/write filters are redefined as a template over the output precision type. */

        // save a transform to the disk in single precision type:
        typedef TransformFileWriterTemplate<float>   WriterType;

        // read a transform and store that to the memory in single precision type:
        typedef TransformFileReaderTemplate<float>   ReaderType;

        // The legacy writer/reader APIs are aliases for the following definitions:
        typedef TransformFileWriterTemplate<double>   WriterType;
        typedef TransformFileReaderTemplate<double>   ReaderType;

        // In above example, a reader/writer filter returns a double precision transform as its output.
      ]]>
    </New>
    </SampleCode>
    <SampleCode>
      <Old>
        <![CDATA[
        typedef ObjectToObjectMetric<TFixedDimension, TMovingDimension, TVirtualImage> MetricType;
        ]]>
      </Old>

      <New>
        <![CDATA[
        typedef ObjectToObjectMetric<TFixedDimension, TMovingDimension, TVirtualImage, float> MetricType;

        - or in a general way:
        typedef ObjectToObjectMetric<TFixedDimension, TMovingDimension, TVirtualImage, TInternalComputationValueType> MetricType;
        ]]>
      </New>

    </SampleCode>
    <!--// Forward declarations can not be made through typedefs. -->
    <SampleCode>
      <Old>
        <![CDATA[
        // Forward decalaration for pointer
        class TransformBase;
        ]]>
      </Old>

      <New>
        <![CDATA[
        // Forward decalaration for pointer
        template< typename TScalar > class TransformBaseTemplate;
        ]]>
      </New>

    </SampleCode>

    <!--**
    ** The change-ids for all commits in the topic branch
    **-->
    <Gerrit-ChangeId>
      If55fcd401fcc9373cba2e0749e27e3c2fa4b2cd1
    </Gerrit-ChangeId>

    <!--**
    ** List of all changed files from the topic branch
    **-->
    <FileList>
      CMake/UseITK.cmake
      Modules/Core/Transform/include/itkTransform.h
      Modules/Core/Transform/include/itkTransformBase.h
      Modules/Filtering/DisplacementField/include/itkTimeVaryingVelocityFieldIntegrationImageFilter.h
      Modules/Filtering/DisplacementField/include/itkTimeVaryingVelocityFieldIntegrationImageFilter.hxx
      Modules/Filtering/ImageGrid/include/itkVectorResampleImageFilter.h
      Modules/Filtering/ImageGrid/include/itkVectorResampleImageFilter.hxx
      Modules/IO/TransformBase/include/itkCompositeTransformIOHelper.h
      Modules/IO/TransformBase/include/itkCompositeTransformIOHelper.hxx
      Modules/IO/TransformBase/include/itkTransformFileReader.h
      Modules/IO/TransformBase/include/itkTransformFileReader.hxx
      Modules/IO/TransformBase/include/itkTransformFileWriter.h
      Modules/IO/TransformBase/include/itkTransformFileWriter.hxx
      Modules/IO/TransformBase/include/itkTransformIOBase.h
      Modules/IO/TransformBase/include/itkTransformIOBase.hxx
      Modules/IO/TransformBase/include/itkTransformIOFactory.h
      Modules/IO/TransformBase/include/itkTransformIOFactory.hxx
      Modules/IO/TransformBase/src/CMakeLists.txt
      Modules/IO/TransformBase/src/itkCompositeTransformIOHelper.cxx
      Modules/IO/TransformBase/src/itkTransformFileReader.cxx
      Modules/IO/TransformBase/src/itkTransformFileWriter.cxx
      Modules/IO/TransformBase/src/itkTransformIOBase.cxx
      Modules/IO/TransformBase/src/itkTransformIOFactory.cxx
      Modules/IO/TransformBase/test/itkTransformFileReaderTemplateTest.cxx
      Modules/IO/TransformBase/test/itkTransformFileWriterTemplateTest.cxx
      Modules/IO/TransformHDF5/include/itkHDF5TransformIO.h
      Modules/IO/TransformHDF5/include/itkHDF5TransformIO.hxx
      Modules/IO/TransformHDF5/include/itkHDF5TransformIOFactory.h
      Modules/IO/TransformHDF5/include/itkHDF5TransformIOFactory.hxx
      Modules/IO/TransformHDF5/src/itkHDF5TransformIO.cxx
      Modules/IO/TransformHDF5/src/itkHDF5TransformIOFactory.cxx
      Modules/IO/TransformHDF5/test/CMakeLists.txt
      Modules/IO/TransformHDF5/test/itkIOTransformHDF5TemplateTest.cxx
      Modules/IO/TransformInsightLegacy/include/itkTxtTransformIO.h
      Modules/IO/TransformInsightLegacy/include/itkTxtTransformIO.hxx
      Modules/IO/TransformInsightLegacy/include/itkTxtTransformIOFactory.h
      Modules/IO/TransformInsightLegacy/include/itkTxtTransformIOFactory.hxx
      Modules/IO/TransformInsightLegacy/src/CMakeLists.txt
      Modules/IO/TransformInsightLegacy/src/itkTxtTransformIO.cxx
      Modules/IO/TransformInsightLegacy/src/itkTxtTransformIOFactory.cxx
      Modules/IO/TransformInsightLegacy/test/itkIOTransformTxtTemplateTest.cxx
      Modules/IO/TransformMatlab/include/itkMatlabTransformIO.h
      Modules/IO/TransformMatlab/include/itkMatlabTransformIO.hxx
      Modules/IO/TransformMatlab/include/itkMatlabTransformIOFactory.h
      Modules/IO/TransformMatlab/include/itkMatlabTransformIOFactory.hxx
      Modules/IO/TransformMatlab/src/CMakeLists.txt
      Modules/IO/TransformMatlab/src/itkMatlabTransformIO.cxx
      Modules/IO/TransformMatlab/src/itkMatlabTransformIOFactory.cxx
      Modules/IO/TransformMatlab/test/CMakeLists.txt
      Modules/IO/TransformMatlab/test/itkIOTransformMatlabTemplateTest.cxx
      Modules/Numerics/Optimizers/include/itkCostFunction.h
      Modules/Numerics/Optimizers/include/itkCostFunction.hxx
      Modules/Numerics/Optimizers/src/CMakeLists.txt
      Modules/Numerics/Optimizers/src/itkCostFunction.cxx
      Modules/Numerics/Optimizersv4/include/itkConjugateGradientLineSearchOptimizerv4.h
      Modules/Numerics/Optimizersv4/include/itkConjugateGradientLineSearchOptimizerv4.hxx
      Modules/Numerics/Optimizersv4/include/itkGradientDescentLineSearchOptimizerv4.h
      Modules/Numerics/Optimizersv4/include/itkGradientDescentLineSearchOptimizerv4.hxx
      Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerBasev4.h
      Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerBasev4.hxx
      Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerBasev4ModifyGradientByLearningRateThreader.h
      Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerBasev4ModifyGradientByLearningRateThreader.hxx
      Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerBasev4ModifyGradientByScalesThreader.h
      Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerBasev4ModifyGradientByScalesThreader.hxx
      Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerv4.h
      Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerv4.hxx
      Modules/Numerics/Optimizersv4/include/itkMultiGradientOptimizerv4.h
      Modules/Numerics/Optimizersv4/include/itkMultiGradientOptimizerv4.hxx
      Modules/Numerics/Optimizersv4/include/itkMultiStartOptimizerv4.h
      Modules/Numerics/Optimizersv4/include/itkMultiStartOptimizerv4.hxx
      Modules/Numerics/Optimizersv4/include/itkObjectToObjectMetric.h
      Modules/Numerics/Optimizersv4/include/itkObjectToObjectMetric.hxx
      Modules/Numerics/Optimizersv4/include/itkObjectToObjectMetricBase.h
      Modules/Numerics/Optimizersv4/include/itkObjectToObjectMetricBase.hxx
      Modules/Numerics/Optimizersv4/include/itkObjectToObjectOptimizerBase.h
      Modules/Numerics/Optimizersv4/include/itkObjectToObjectOptimizerBase.hxx
      Modules/Numerics/Optimizersv4/include/itkOptimizerParameterScalesEstimator.h
      Modules/Numerics/Optimizersv4/include/itkQuasiNewtonOptimizerv4.h
      Modules/Numerics/Optimizersv4/include/itkQuasiNewtonOptimizerv4.hxx
      Modules/Numerics/Optimizersv4/include/itkQuasiNewtonOptimizerv4EstimateNewtonStepThreader.h
      Modules/Numerics/Optimizersv4/include/itkQuasiNewtonOptimizerv4EstimateNewtonStepThreader.hxx
      Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesEstimator.h
      Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesEstimator.hxx
      Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromIndexShift.hxx
      Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromPhysicalShift.hxx
      Modules/Numerics/Optimizersv4/include/itkSingleValuedCostFunctionv4.h
      Modules/Numerics/Optimizersv4/src/CMakeLists.txt
      Modules/Numerics/Optimizersv4/src/itkConjugateGradientLineSearchOptimizerv4.cxx
      Modules/Numerics/Optimizersv4/src/itkGradientDescentLineSearchOptimizerv4.cxx
      Modules/Numerics/Optimizersv4/src/itkGradientDescentOptimizerBasev4.cxx
      Modules/Numerics/Optimizersv4/src/itkGradientDescentOptimizerBasev4ModifyGradientByLearningRateThreader.cxx
      Modules/Numerics/Optimizersv4/src/itkGradientDescentOptimizerBasev4ModifyGradientByScalesThreader.cxx
      Modules/Numerics/Optimizersv4/src/itkGradientDescentOptimizerv4.cxx
      Modules/Numerics/Optimizersv4/src/itkMultiGradientOptimizerv4.cxx
      Modules/Numerics/Optimizersv4/src/itkMultiStartOptimizerv4.cxx
      Modules/Numerics/Optimizersv4/src/itkObjectToObjectMetricBase.cxx
      Modules/Numerics/Optimizersv4/src/itkObjectToObjectOptimizerBase.cxx
      Modules/Numerics/Optimizersv4/src/itkQuasiNewtonOptimizerv4.cxx
      Modules/Numerics/Optimizersv4/src/itkQuasiNewtonOptimizerv4EstimateNewtonStepThreader.cxx
      Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerBasev4Test.cxx
      Modules/Numerics/Optimizersv4/test/itkObjectToObjectOptimizerBaseTest.cxx
      Modules/Registration/Common/include/itkBSplineTransformParametersAdaptor.hxx
      Modules/Registration/Common/include/itkTimeVaryingBSplineVelocityFieldTransformParametersAdaptor.hxx
      Modules/Registration/Metricsv4/include/itkANTSNeighborhoodCorrelationImageToImageMetricv4.h
      Modules/Registration/Metricsv4/include/itkANTSNeighborhoodCorrelationImageToImageMetricv4.hxx
      Modules/Registration/Metricsv4/include/itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx
      Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4.h
      Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4.hxx
      Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx
      Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4HelperThreader.hxx
      Modules/Registration/Metricsv4/include/itkDefaultImageToImageMetricTraitsv4.h
      Modules/Registration/Metricsv4/include/itkDemonsImageToImageMetricv4.h
      Modules/Registration/Metricsv4/include/itkDemonsImageToImageMetricv4.hxx
      Modules/Registration/Metricsv4/include/itkImageToImageMetricv4.h
      Modules/Registration/Metricsv4/include/itkImageToImageMetricv4.hxx
      Modules/Registration/Metricsv4/include/itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.hxx
      Modules/Registration/Metricsv4/include/itkJointHistogramMutualInformationComputeJointPDFThreaderBase.hxx
      Modules/Registration/Metricsv4/include/itkJointHistogramMutualInformationImageToImageMetricv4.h
      Modules/Registration/Metricsv4/include/itkJointHistogramMutualInformationImageToImageMetricv4.hxx
      Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.h
      Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx
      Modules/Registration/Metricsv4/include/itkMeanSquaresImageToImageMetricv4.h
      Modules/Registration/Metricsv4/include/itkMeanSquaresImageToImageMetricv4.hxx
      Modules/Registration/Metricsv4/include/itkObjectToObjectMultiMetricv4.h
      Modules/Registration/Metricsv4/include/itkObjectToObjectMultiMetricv4.hxx
      Modules/Registration/RegistrationMethodsv4/include/itkBSplineSyNImageRegistrationMethod.hxx
      Modules/Registration/RegistrationMethodsv4/include/itkImageRegistrationMethodv4.h
      Modules/Registration/RegistrationMethodsv4/include/itkImageRegistrationMethodv4.hxx
      Modules/Registration/RegistrationMethodsv4/include/itkSyNImageRegistrationMethod.hxx
      Modules/Registration/RegistrationMethodsv4/include/itkTimeVaryingBSplineVelocityFieldImageRegistrationMethod.hxx
      Modules/Registration/RegistrationMethodsv4/include/itkTimeVaryingVelocityFieldImageRegistrationMethodv4.hxx
      Modules/Core/Common/include/itkVectorImage.h
      Modules/Core/ImageAdaptors/test/itkVectorImageTest.cxx
    </FileList>

    <!--**
    ** If the migration can be accomplished by a simple string
    ** substitution, then use the following construct to define
    ** the substitution rule.
    **
    ** <MigrationFix-Automatic>
    **   <Old>
    **     <![CDATA[MipsleledName]]>
    **   </Old>
    **   <New>
    **     <![CDATA[MisspelledName]]>
    **   </New>
    ** </MigrationFix-Automatic>
    **-->

    <!--**
    ** If the migration can NOT be accomplished by a simple string
    ** substitution, but potential problem spots can be identified,
    ** use the following construct to define a migration flag rule.
    **
    ** <MigrationFix-Manual>
    **   OldFunctionName
    ** </MigrationFix-Manual>
    **-->

</Change>
