%======================================================================%
% Filename: Article.tex
% Project: Insight Journal Article - Tagged Volume Rendering of the Heart
% Author: Dan Mueller - d.mueller[at]qut.edu.au, dan.muel[at]gmail.com
%----------------------------------------------------------------------%
% Description:
% This artcile is for the Insight Journal.
% It describes the process and parameters for Tagged Volume Rendering
% of the Heart.
%======================================================================%
\documentclass{InsightArticle}

%\usepackage{courier}                 %Font
%\usepackage{charter}                 %Font
%\usepackage{times}                   %Font
%\usepackage{newcent}                 %Font
%\usepackage{pslatex}                 %Font
%\usepackage{lmodern}                 %Font
%\usepackage{palatino}                %Font
%\usepackage{bookman}                 %Font
\usepackage{amsfonts}                 %Maths fonts
\usepackage{amssymb}                  %Maths symbols
\usepackage{listing}                  %Used for list of listings
\usepackage{listings}                 %List program code source
\usepackage{subfigure}                %For subfigures
\usepackage{color}                    %Allow color
\usepackage{fancyhdr}                 %Use headers and footers
\usepackage{graphicx}                 %Graphics
\usepackage[dvipdfmx=true,
            bookmarks=true,
            bookmarksopen=true,
            bookmarksopenlevel=2,
            bookmarksnumbered=true,
            backref=section,
            colorlinks=true,
            linkcolor={blue},
            citecolor={blue},
            urlcolor={blue}]{hyperref}

%Set default font
%\renewcommand{\familydefault}{\rmdefault}  %Roman
\renewcommand{\familydefault}{\sfdefault}   %Sans serif
%\renewcommand{\familydefault}{\ttdefault}  %Typewriter

%Keywords
\newcommand{\keywords}[1]{\noindent\textbf{Keywords:}\it{\ #1}}

% TOC depth
\setcounter{tocdepth}{2}

%Stuff for images
\graphicspath{{../results/}}

%Create indent for description
\newenvironment{indentdescription}
               {\list{}{\leftmargin \leftmargin}%
                \item\relax}
               {\endlist}
               
%Allow symbol footnotes
\long\def\symbolfootnote[#1]#2{\begingroup%
\def\thefootnote{\fnsymbol{footnote}}\footnote[#1]{#2}\endgroup}   

%Allow code listings
\input{listcode}                 

%Create conditional to include or exclude figures 
%(saves time during debug compilation).
\makeatletter
\newif\if@includefigs@
\@includefigs@true

%======================================================================%
%                   F r o n t   M a t t e r                            % 
%======================================================================%
% The title should be descriptive enough for people to be able to find
% the relevant document.
\title{Tagged Volume Rendering of the Heart:\\A Case Study}

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

% Name and affiliation
\author{Dan Mueller$^{\scriptscriptstyle\textsf{1}}$}
\authoraddress{$^{\textsf{1}}$Queensland University of Technology, Brisbane, Australia}

% Set custom header style
\pagestyle{fancy}                               
\fancyhead{}            % clear all header fields
\fancyhead[L]{\textsf{Tagged Volume Rendering of the Heart: A Case Study}}
\fancyhead[R]{\textsf{\thepage}}
\fancyfoot{}            % clear all footer fields

% Document
\begin{document}

% Show the title
\maketitle

% Make the title page header/footer empty
\thispagestyle{empty}

%======================================================================%
%                       A b s t r a c t                                % 
%======================================================================%
\begin{abstract}
\noindent
This is a companion paper describing the process and parameters
for tagged volume rendering of the heart.
We firstly review the relevant concepts and consider the
problem of visualising the coronary arteries from 
computed tomography angiography (CTA) images.
We then discuss the implementation using the SharpImage
prototyping environment.
Finally, we list the set of commands capable of reproducing our results
using the accompanying dataset.
%
\newline
\newline
\keywords{tagged volume rendering, heart, coronary arteries, ITK, SharpImage}

\end{abstract}

%======================================================================%
%                     M a i n   M a t t e r                            % 
%======================================================================%
\tableofcontents


%----------------------------------------------------------------------%
% Section
%----------------------------------------------------------------------%
\section{Introduction}
For diagnostic and treatment planning purposes,
radiologists and surgeons require means to visualise the coronary
arteries from computed tomography angiography (CTA) images.
However, this task is non-trivial for various reasons: 
(a) unwanted structures (such as the thoracic cage) clutter the regions of interest;
(b) the contrast agent highlights the coronary arteries (as desired),
but also portions of the ventricles, atria, aorta, and pulmonary arteries,
and
(c) the coronary arteries can exhibit high-intensity calcification artefacts.
Clinicians currently have a number of tools at their disposal, including:
thin slab maximum intensity projection \cite{Fishman2006a},
curved planar reformatting \cite{Kanitsar2003a},
and direct volume rendering (DVR).

In the case of direct volume rendering, the dataset is segmented 
during the rendering process (`online') via a lookup table (`transfer function').
Various online segmentation algorithms for DVR have been
discussed in the literature
\cite{Pfister2001a,Kniss2002a,Tzeng2005a}.
Kniss et al. \cite{Kniss2002a} advocated the use of two dimensional
transfer functions dependent on pixel value and gradient magnitude
(termed `value-magnitude' transfer functions),
in which the user interactively specifies the function using a number of widgets.
This method is simple, fast and effective for simple datasets;
yet, it is insufficient for delineating objects of interest sharing similar characteristics.  
Tzeng et al. \cite{Tzeng2005a} proposed an approach using an online machine learning algorithm
(such as an artificial neural network or support vector machine),
with the current pixel value, gradient magnitude, location, and neighbourhood values as inputs.
Because of their online nature, both of these methods are constrained by the graphics hardware
on which they are implemented.

A number of more recent methods combine both offline and online segmentation.
Hadwiger et al. \cite{Hadwiger2003a} proposed tagged volume rendering which
uses a number of \emph{a priori} segmented binary masks (`tags'),
each assigned separate transfer functions.
Kniss et al. \cite{Kniss2005a} introduced a probabilistic method which
decouples classification from colour-mapping, simplifying the transfer function interface.
Weber et al. \cite{Weber2007a} proposed the use of contour-trees for classifying objects
based on topology
(the trees are computed and simplified offline before being uploaded the the graphics hardware).
Of these methods, tagged volume rendering is the most flexible as it does not restrict the choice
of segmentation algorithm.

In this paper we apply tagged volume rendering to the problem of visualising the
coronary arteries.
We utilise Hessian-based line filters for segmenting the coronary arteries \cite{Sato1998a}
and use the Fast Marching active contour method \cite{Sethian1999a} for segmenting the
pericardial cavity.
A suitable speed function is presented for controlling the expansion of the active
contour.
The exact set of SharpImage \cite{Mueller2007d} commands for reproducing the results
on the accompanying dataset are given.
For your reference, a pre-print of the main MICCAI paper can be found here:
\href{http://eprints.qut.edu.au/archive/00008421/}{http://eprints.qut.edu.au/archive/00008421/}

%----------------------------------------------------------------------%
% Section
%----------------------------------------------------------------------%
\section{Implementation}
This section details the implementation of the method.
It requires built versions of ITK 3.2, ManagedITK 3.2.0.3 \cite{Mueller2007b},
and SharpImage 0.9.2 \cite{Mueller2007d}.
Before tackling the case study, we must extend the SharpImage environment to
handle vessel segmentation and implement a fragment shader for tagged transfer
functions.

%----------------------------------------------------------------------%
\subsection{Vessel Segmentation}
SharpImage does not have an explicit vessel segmentation command,
however it is quite easy to add such a script.
The first step is to wrap the required filters using a ManagedITK external project
(see \code{source/vesselness/CMakeLists.txt}):
%
\begin{center}
  \listmakesmall
    \lstinputlisting{../source/vesselness/CMakeLists.txt}
\end{center}

We need to wrap two filters,
\code{itkHessianRecursiveGaussianImageFilter} and
\code{itkHessian3DToVesselnessMeasureImageFilter}:
%
\begin{center}
  \listmakesmall
    \lstinputlisting{../source/vesselness/managed_itkHessianRecursiveGaussianImageFilter.cmake}
\end{center}
%
\begin{center}
  \listmakesmall
    \lstinputlisting{../source/vesselness/managed_itkHessian3DToVesselnessMeasureImageFilter.cmake}
\end{center}

We point CMake at this folder, choose a build directory,
and configure the project for Visual Studio 8%
\footnote{We have not tried Visual Studio Express Edition,
so there may be issues if you are using that specific compiler.}.
ManagedITK should create the relevant files,
including a \code{FinishCMake.bat} file which must be run \emph{before}
opening the solution file and compiling the project.
The output will be a single executable \code{ManagedITK.Filtering.Vesselness.dll}.

The next step is to create a Python script for use with SharpImage
(see \code{source/vesselness/Vesselness.py}):
\begin{center}
  \listpythonsmall
    \lstinputlisting[linerange={1-1,4-4,17-31,36-41,54-67,70-76,79-92}]{../source/vesselness/Vesselness.py}
\end{center}

These files (\code{ManagedITK.Filtering.Vesselness.dll} and \code{Vesselness.py})
must be copied to the SharpImage Scripting folder
(we recommend creating a subfolder called \code{SharpImage/Scripting/Custom} or similar).
A pre-compiled version of the ManagedITK assembly is provided with this article if you wish
to bypass this step (see \code{results/ManagedITK.Filtering.Vesselness.dll}).

%----------------------------------------------------------------------%
\subsection{Fragment Shader}
We implement a derivation of the tagged volume rendering method
described by Hadwiger et al. \cite{Hadwiger2003a}.
In their original method tags represent exact objects, which
requires tri-linear interpolation and complex boundary filtering
to avoid artefacts and improve resolution.
Our application allows us to make a different assumption:
a tag is a mask guaranteeing to \emph{include} structures of
interest, but not \emph{exactly} delineate them.
We can therefore use nearest neighbour interpolation and
a stack of value-magnitude transfer functions
to refine the structures inside the tags
(ie. a 3-D texture, similar to Svakhine et al. \cite[Sec. 3]{Svakhine2005a}). 
%
The tagged transfer function is implemented using OpenGL Shading Language (GLSL)
(see \code{source/fragment-shader/shader-vmt-phong.frag}):
\begin{center}
  \listglslsmall
    \lstinputlisting[linerange={1-1,4-4,17-24,96-146,155-161}]
    {../source/fragment-shader/shader-vmt-phong.frag}
\end{center}


%----------------------------------------------------------------------%
% Section
%----------------------------------------------------------------------%
\section{Commands}
This section lists the SharpImage commands required to reproduce
our results.
You will need a good desktop computer with \emph{at least 2 GB RAM}
and a recent graphics card with \emph{at least 512 MB VRAM}
(you will receive memory allocation errors otherwise).
For this experiment we used an Intel Pentium D,
2 \hspace{-0.65mm}$\times$\hspace{-0.65mm} 3.0 GHz processors,
2 GB RAM, NVIDIA GeForce 8800 GTX, 768 MB VRAM.
We assume the data has been unzipped to \code{C:/Temp},
along with \code{source/commands/A-SPHERES.txt}.
The full list of commands can be found in 
\code{source/commands/commands.txt}.

%----------------------------------------------------------------------%
\subsection{Orient and Resize}
Because our data came from various sources,
we found it desirable to orient the images to the same anatomical position.
Much of the processing is undertaken on subsampled images,
so we also resize the image at this point.
\begin{center}
  \listsharpimagesnip
    \lstinputlisting[linerange={2-9}]{../source/commands/commands.txt}
\end{center}

%----------------------------------------------------------------------%
\subsection{Speed Function}
We now compute the edge-based speed function:
\begin{center}
  \listsharpimagesnip
    \lstinputlisting[linerange={12-15,17-19,28-29}]{../source/commands/commands.txt}
\end{center}

The seed for the region growing can be anywhere in the sternum
(we used [50, 90, 100]) and the parameters for the speed function
were as follows:
\begin{center}
  \listconsolesnip
    \lstinputlisting[linerange={20-27}]{../source/commands/commands.txt}
\end{center}

%----------------------------------------------------------------------%
\subsection{Initial Contour}
The initial contour could be computed from a set of points
or --- as we prefer --- from a set of spheres generated using a 3-D interface:
\begin{center}
  \listsharpimagesnip
    \lstinputlisting[linerange={32-39}]{../source/commands/commands.txt}
\end{center}
%
Notice the morphological opening which removes unwanted pulmonary vessels.
The list of spheres is defined in \code{source/commands/A-SPHERES.txt}:
\begin{center}
  \listconsolesnip
    \lstinputlisting{../source/commands/A-SPHERES.txt}
\end{center}


%----------------------------------------------------------------------%
\subsection{Fast Marching}
We now evolve the active contour, extract the contour at a suitable arrival
time, and return the tag to full size:
\begin{center}
  \listsharpimagesnip
    \lstinputlisting[linerange={42-51}]{../source/commands/commands.txt}
\end{center}

%----------------------------------------------------------------------%
\subsection{Vesselness}
We now segment the vessels using the script created earlier:
\begin{center}
  \listsharpimagesnip
    \lstinputlisting[linerange={54-56,60-64}]{../source/commands/commands.txt}
\end{center}

The \code{ImageRange} script is required to increase the contrast for selecting
the seeds.
We specified two seeds for the region growing:
one in the left coronary artery (LCA) [95, 122, 169],
and
one in the right coronary artery (RCA) [126, 86, 96].

%----------------------------------------------------------------------%
\subsection{Combine Tags}
We are now ready to combine our two tags into a single image:
\begin{center}
  \listsharpimagesnip
    \lstinputlisting[linerange={67-72}]{../source/commands/commands.txt}
\end{center}

%----------------------------------------------------------------------%
\subsection{Histogram}
This step is purely optional,
but it is often desirable to have a histogram to aid transfer function
specification:
\begin{center}
  \listsharpimagesnip
    \lstinputlisting[linerange={75-79}]{../source/commands/commands.txt}
\end{center}

%----------------------------------------------------------------------%
\subsection{Volume Render}
The preparation is now complete and we are ready to render the volumes:
\begin{center}
  \listsharpimagesnip
    \lstinputlisting[linerange={82-88}]{../source/commands/commands.txt}
\end{center}

Select the ``Renderer Editor'' and configure the ``FragmentProgramPath''.
Select the ``Transfer function editor'' and right-click on the transfer
function to add components similar to those shown in the results section.

%----------------------------------------------------------------------%
% Section
%----------------------------------------------------------------------%
\section{Results}

\newlength{\dvrimageheightA}
\setlength{\dvrimageheightA}{46mm}
\newlength{\dvrimageheightC}
\setlength{\dvrimageheightC}{52mm}

\begin{figure}[!htb]
    \centering
  \subfigure[Dataset A: Normal]
  {\includegraphics[height=\dvrimageheightA]{Final-DVR-A-Montage-Norm.png}}
  \subfigure[Dataset A: Tagged]
  {\includegraphics[height=\dvrimageheightA]{Final-DVR-A-Montage-Tags.png}}
  %
  \newline
  %
  \subfigure[Dataset C: Normal]
  {\includegraphics[height=\dvrimageheightC]{Final-DVR-C-Montage-Norm.png}}
  \subfigure[Dataset C: Tagged]
  {\includegraphics[height=\dvrimageheightC]{Final-DVR-C-Montage-Tags.png}}
  \caption{\label{fig:Results}%
  Resultant images using the normal and tagged volume rendering approaches.
  Dataset A is provided with this article.
  }
\end{figure}

%----------------------------------------------------------------------%
% Conclusion
%----------------------------------------------------------------------%
\section{Conclusion}
We have presented a method for tagged volume rendering of the heart.
The method is comprised of two stages:
offline segmentation of the coronary arteries and pericardial cavity;
followed by the online application of value-magnitude
transfer functions to refine the tags.
The method was presented using the SharpImage prototyping environment
which made the steps somewhat involved,
but easily reproduced.
Feel free to contact us with any questions or suggestions%
\footnote{Corresponding author: Dan Mueller: %
\href{mailto:d.mueller@qut.edu.au}{d.mueller@qut.edu.au} or
\href{mailto:dan.muel@gmail.com}{dan.muel@gmail.com}.
}.

%======================================================================%
%                    B i b l i o g r a p h y                           % 
%======================================================================%
\newpage
\bibliographystyle{plain}
\bibliography{article}

\end{document}
