\documentclass{InsightArticle}

\usepackage{bm}
\usepackage[dvips]{graphicx}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  hyperref should be the last package to be loaded.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[dvips,
bookmarks,
bookmarksopen,
backref,
colorlinks,linkcolor={blue},citecolor={blue},urlcolor={blue},
]{hyperref}


\title{Generating a Deformation Field from an \doxygen{Transform}}

%
% NOTE: This is the last number of the "handle" URL that
% The Insight Journal assigns to your paper as part of the
% submission process. Please replace the number "1338" with
% the actual handle number that you get assigned.
%
\newcommand{\IJhandlerIDnumber}{1338}

% Increment the release number whenever significant changes are made.
% The author and/or editor can define 'significant' however they like.
\release{0.00}

% At minimum, give your name and an email address.  You can include a
% snail-mail address if you like.
\author{Marius Staring$^{1}$}
\authoraddress{$^{1}$Leiden University Medical Center, The Netherlands}

\begin{document}

%
% Add hyperlink to the web location and license of the paper.
% The argument of this command is the handler identifier given
% by the Insight Journal to this paper.
%
\IJhandlefooter{\IJhandlerIDnumber}


\ifpdf
\else
   %
   % Commands for including Graphics when using latex
   %
   \DeclareGraphicsExtensions{.eps,.jpg,.gif,.tiff,.bmp,.png}
   \DeclareGraphicsRule{.jpg}{eps}{.jpg.bb}{`convert #1 eps:-}
   \DeclareGraphicsRule{.gif}{eps}{.gif.bb}{`convert #1 eps:-}
   \DeclareGraphicsRule{.tiff}{eps}{.tiff.bb}{`convert #1 eps:-}
   \DeclareGraphicsRule{.bmp}{eps}{.bmp.bb}{`convert #1 eps:-}
   \DeclareGraphicsRule{.png}{eps}{.png.bb}{`convert #1 eps:-}
\fi


\maketitle

\ifhtml
\chapter*{Front Matter\label{front}}
\fi


% The abstract should be a paragraph or two long, and describe the
% scope of the document.
\begin{abstract}
\noindent This document describes a new class that takes an
\doxygen{Transform} and evaluates the deformation at points in a
user-defined region.
The class is implemented using the Insight Toolkit \url{www.itk.org}. \\
This paper is accompanied with the source code, input data, parameters and
output data that the authors used for validating the algorithm described in
this paper.
\end{abstract}

\IJhandlenote{\IJhandlerIDnumber}

\tableofcontents

\section{Introduction}

In the field of medical imaging it is often necessary to analyse the
deformation field resulting from a (nonrigid) registration process.
The result of registration in ITK is however a transformation and
not directly the deformation field.

This contribution provides a class that takes the transformation and
produces a deformation field. The user needs to specify were and
with what spacing the transformation should be evaluated. This is
similar to the \doxygen{ResampleImageFilter}.

\section{Implementation}

Our class, which we named \code{TransformToDeformationFieldSource},
inherits from \doxygen{ImageSource}. It is implemented as a
multi-threaded filter. Similar to the \doxygen{ResampleImageFilter},
advantage is taken in case the transformation is linear.

For every point $\bm{x}$ in the user-specified region we compute the
transformed point $\bm{T}(\bm{x})$, and compute the deformation
$\bm{d}$ at that point:
\begin{align}
\bm{d}(\bm{x}) &= \bm{T}(\bm{x}) - \bm{x}.
\end{align}

\section{Usage}

The filter is used as follows:

\small
\begin{verbatim}
typedef itk::TransformToDeformationFieldSource<
  DeformationFieldImageType,
  CoordRepresentationType >             DeformationFieldGeneratorType;

TransformType::Pointer transform
  = TransformType::New();
// .. define the transform (set the parameters, etc.)

DeformationFieldGeneratorType::Pointer defGenerator
  = DeformationFieldGeneratorType::New();
defGenerator->SetOutputSize( size );
defGenerator->SetOutputSpacing( spacing );
defGenerator->SetOutputOrigin( origin );
defGenerator->SetOutputIndex( index );
defGenerator->SetOutputDirection( direction );
defGenerator->SetTransform( transform );
try
{
  defGenerator->Update();
}
catch ( itk::ExceptionObject & e )
{
  // Print error message
}
\end{verbatim}
\normalsize

The\ \code{size, spacing, origin}, etc. parameters are user-defined.
After generation of the deformation field, it can for example be
written to file, or further analysis can be applied.

\end{document}
