\documentclass[fleqn,11pt,openany]{book}

% These two need to be set before including scirun style package
\title{SCIRun Lab Walkthrough}
\author{Jess Tate}

% INCLUDE SCI STYLE DOCUMENT
\usepackage{scirun}
\usepackage{graphicx}
\usepackage{float}
\usepackage{hyperref}

% This makes displaying bold greek letters easier
\newcommand{\BM }[1]{\mbox{\boldmath $#1$}}

\begin{document}

%% starting from SCIRun Doc wiki


% CREATE TITLE PAGE --------------------------------------------------
\maketitle

% CHAPTERS ---------------------------------------------------------------

\chapter{Overview}

\begin{introduction}

This walkthrough was written for use in CIBC workshop as a guide for the allotted lab time.  This document is meant to provide the information needed for the first time users to begin using SCIRun.  It provides step by step instructions to install, setup, and run SCIRun with basic functionality.  There are several example networks, datasets, and tutorials that will provide specific direction and training for using SCIRun to solve specific problems; this walkthrough will provide the information needed setup your system, and to acquaint inexperienced users to use SCIRun so that they may run the example networks especially, and the tutorials.

\end{introduction}


\section{SCIRun Description}


SCIRun is a \emph{modular dataflow programming} Problem Solving Environment (PSE).
SCIRun has a set of Modules that perform specific functions on a data stream.
Each module reads data from its input ports, calculates the data, and sends new data from output ports.

In SCIRun, a module is represented by a rectangular box on the Network Editor canvas.
Data flowing between modules is represented by pipes connecting the modules.
A group of connected modules is called a Dataflow Network, or net (see Figure~\ref{fig:sample_network}).
An infinite number of nets can be created, each solving a separate problem.

For a more detailed description of SCIRun and its uses, please see the \href{http://www.sci.utah.edu/devbuilds/scirun_docs/UserGuide.pdf}{SCIRun User Guide}.

\begin{figure}[H]\label{fig:sample_network}
\begin{centering}
\scalebox{0.5}{\includegraphics{figures/sample_network.png}}
\caption{SCIRun Dataflow Network}
\end{centering}
\end{figure}

%---------------------------------------------

\chapter{System requirements}

Graphics cards must support OpenGL 2.0 or greater.

\section*{Windows} 

Windows XP or later is supported.

\section*{Mac OS X} 

SCIRun runs on OS X 10.5 - 10.7.
SCIRun is not currently supported on OS X 10.8.

\section*{Linux} 

SCIRun must be compiled from source and requires the following:
\begin{itemize}
\item{GCC 4 compiler}
\item{CMake 2.8 or greater}
\item{NVIDIA card and drivers}
\item{Installing platform-specific packages may be required. (\href{http://scirundocwiki.sci.utah.edu/SCIRunDocs/index.php/CIBC:Documentation:SCIRun}{See CIBC wiki})}
\end{itemize}

SCIRun is known to compile on OpenSuSE 10 - 12, Ubuntu 9 -11 and RHEL 5 (also CentOS and Fedora).


%---------------------------------------------

\chapter{Getting Started}

Using SCIRun may seem daunting because of the numerous modules and arrangements possible, yet getting started on SCIRun is actually very simple.
SCIRun can be installed on your machine from a binary installer if you are using Windows or OS X, or can be installed from source code.
Once SCIRun is installed properly, it can be run with the graphic interface, or through the command line and supports scripting.
In this chapter we will explain how to install and set up SCIRun to run the example networks and tutorials provided.  

\section{Installation}

SCIRun is available from our website at \url{http://www.scirun.org} in both precompiled binaries and source code only distributions and from the flash drive provided.
To compile from source code or for more information in general on SCIRun installation, please refer to the \href{http://www.sci.utah.edu/devbuilds/scirun_docs/InstallationGuide.pdf}{SCIRun Installation Guide}.

\subsection{SCIRun Data}

The SCIRunData archive consists of example datasets that are used in the example networks and tutorials.
It can be downloaded from the \href{http://www.scirun.org}{website} mentioned above, or from the flash drive provided
under \textbf{software/SCIRun\_BioMesh3D/data}.
\textbf{\large This file should be downloaded, unpacked, and placed in a convenient location for the purposes of this lab}.

Additional material for the labs can be found under the \textbf{labs} folder on the provided flash drive.

\subsection{Windows}

Download the SCIRun installer executable from the \href{http://www.scirun.org}{website} mentioned above or from the flash drive provided.
Chose the version (32 or 64 bit) that corresponds to your operating system.
Run the installer and follow the prompts to install the software.
You can open SCIRun from the Start menu.

%%%needs to be checked%%%    

\subsection{Mac OS X}

Download the SCIRun disk image (.dmg) from the \href{http://www.scirun.org}{website} mentioned above or from the flash drive provided.
Chose the version (32 or 64 bit) that corresponds to your operating system (OS X 10.5 and later is usually 64 bit).
Unpack the disk image by double clicking on its icon.
Move the \textbf{SCIRun} folder to a suitable location such as your Desktop or Applications directory.
Open SCIRun by double clicking on the application icon located within the folder. 

\subsection{Linux}

Installing SCIRun on Linux systems requires compiling from source code.
The source code is available from \href{http://www.scirun.org}{the website} mentioned above or from the flash drive provided.
Please see the \href{http://www.sci.utah.edu/devbuilds/scirun_docs/InstallationGuide.pdf}{SCIRun Installation Guide}.

\section{SCIRun Configuration}
\label{sec:config}

SCIRun has environment variables that can be set to facilitate the loading of data and networks.
Configuration referred to here is the setting of these environment variables to enable easier running of the example networks provided.
This step is not essential to running SCIRun, but the example networks assume that these environment variables are properly set.  

Configuring SCIRun to run the example networks requires changing the path variables in configuration file: \textbf{.scirunrc} (usually found in the home directory, check under AppData subdirectories on Windows).
This can be done through the SCIRun interface by clicking on the \texttt{Configure} button located in the lower right corner (Figure~\ref{fig:button}). 

\begin{figure}[H]
\begin{centering}
\scalebox{.5}{\includegraphics{figures/config_button.png}}
\caption{Expand configuration options}
\label{fig:button}
\end{centering}
\end{figure}
This will bring up a frame with three tabs.
Click the \texttt{Options} tab to bring up the path variable settings as shown in Figure~\ref{fig:config}.

\begin{figure}[H]
\begin{centering}
\scalebox{0.5}{\includegraphics{figures/config_menu.png}}
\caption{Configuration menu to set path variables}
\label{fig:config}
\end{centering}
\end{figure}

In the first field (SCIRun Data) put the path to the SCIRunData directory and press the set button.
An example would be: \textbf{/Volumes/flashdrive/software/SCIRun\_BioMesh3D/data}.
For the second field (SCIRun Nets) put the path to the example nets directory included with SCIRun, \emph{e.g.} \textbf{/home/Desktop/SCIRun/example\_nets}
or \textbf{c:\textbackslash Program Files\textbackslash SCIRun 4.6\textbackslash example\_nets}.
The third field (User Data) can be left blank or set to where ever your data resides.
The fourth field (Data set) is used by some networks in the BioPSE library and can be set to a number of the datasets within the \textbf{SCIRunData} directory, \emph{e.g.} \textbf{/Volumes/flashdrive/software/SCIRun\_BioMesh3D/data/sphere}.
Not all datasets in the \textbf{SCIRunData} directory are compatible with each network.
\textbf{\large Make sure that you press the set button after you input the desired path for each variable}, otherwise it will not work.
Finally, make sure that under SCIRun Options, only the top check box is checked.  

\section{Running Networks}

With the path variables set properly, you should now be able to run any of the networks distributed with SCIRun very easily.
Simply click the \texttt{File} menu, then \texttt{Load}, then use the dialogue window to chose an example network that you would like try, \emph{e.g.} \textbf{example\_nets/SCIRun/FwdInvToolbox/potential-based-fem/forward\_problem.srn} as shown in Figure~\ref{fig:menu}.
Then press \texttt{Execute All} button.
Once the network finishes executing, the visualization window will update and you will see the output (Figure~\ref{fig:examp}).  

\begin{figure}[H]
\begin{centering}
\scalebox{0.5}{\includegraphics{figures/file_menu.png}}
\scalebox{0.5}{\includegraphics{figures/load_dialogue.png}}
\caption{Loading example networks in SCIRun}
\label{fig:menu}
\end{centering}
\end{figure}

\begin{figure}[H]
\begin{centering}
\scalebox{0.25}{\includegraphics{figures/example_net.png}}
\caption{An example network \textbf{forward\_problem.srn}}
\label{fig:examp}
\end{centering}
\end{figure}

\begin{figure}[H]
\begin{centering}
\scalebox{0.3}{\includegraphics{figures/toolkit_menu.png}}
\caption{The Forward Inverse Toolbox menu in SCIRun.}
\label{fig:toolkit_menu}
\end{centering}
\end{figure}

%---------------------------------------------

\chapter{Example Networks \& Tutorials}

\section{Example Networks}

There are a number of example networks that are available for users to use to acquaint themselves with SCIRun and to use as a platform to expand into their own applications.
Most of these networks are associated with tutorials (Sec.~\ref{sec:tutorials}), and some are grouped into toolkits as examples to solve specific problems.
Any of these example networks should run without modification if SCIRun is configured properly (Sec.~\ref{sec:config}).  

The example networks are found with the SCIRun distribution in a directory called \textbf{example\_nets}.
In a Windows installation, \textbf{example\_nets} is located in the installed \textbf{SCIRun4.6} folder (likely in \textbf{Program Files}).
For Mac OS X installation, \textbf{example\_nets} is located in the \textbf{SCIRun} folder copied from the disk image.
\textbf{Note: if SCIRun was built from source code, \emph{i.e.} Linux users, the example networks are in SCIRun/src/nets and will organized a little differently.}

In the \textbf{example\_nets} directory are several sets of networks.
The most useful networks are in the \textbf{SCIRun} folder, yet the \textbf{BioPSE} folder contains useful example solutions for some neural electrophysiology problems (make sure the four path variable is set in the configuration, Sec.~\ref{sec:config}).
Within the \textbf{SCIRun} folder, there are examples of how to use most of the modules in SCIRun (\textbf{Modules}), networks described in the tutorials (\textbf{Optional}), visualization networks for BioMesh3D (\textbf{MeshingPipeline}), and some networks that are useful in solving forward and inverse problems in cardiac electrophysiology (\textbf{FwdInvToolbox}) called the Forward Inverse Toolbox.\\

Additional material for the labs can be found under the \textbf{labs} folder on the provided flash drive.

\subsection{Forward Inverse Toolbox} 

The Forward Inverse Toolbox may be the most useful set of networks, perhaps because it highlights various ways to solve problems in electrophysiology, but more likely because these networks are all documented and describe in the SCIRun ECG Toolkit Guide.
In this toolbox are several examples of how to use SCIRun to solve the forward problem, solving for the torso potentials using a known heart source, and the inverse problem, using known torso potentials to solve for heart sources.
Figure~\ref{fig:examp} shows a network from the toolbox that solve the potential based FEM problem.
The Forward Inverse Toolbox networks can be loaded from the Toolkits menu (Figure~\ref{fig:toolkit_menu}).

For further information about these networks please refer to ECGToolkitGuide.pdf, located in the \textbf{Documentation} directory installed with SCIRun.  

%---------------------------------------------

\section{Tutorials}
\label{sec:tutorials}

There are three tutorials available to guide you in solving problems using SCIRun.
These are found in the \textbf{Documentation} folder included in the SCIRun distribution and at \url{http://www.scirun.org}.
The tutorials currently available are:
\begin{itemize}
\item{\href{http://sci.utah.edu/devbuilds/scirun_docs/BasicTutorial.pdf}{Basic Tutorial}}
\item{\href{http://sci.utah.edu/devbuilds/scirun_docs/DefibrillationTutorial.pdf}{Defibrillation Modeling Tutorial}}
\item{\href{http://sci.utah.edu/devbuilds/scirun_docs/IschemiaModelTutorial.pdf}{Cardiac Ischemia Modeling Tutorial}}
\end{itemize}
A brief description of each of these tutorials is provided.

\subsection{Basic Tutorial}

The SCIRun Basic Tutorial provides directions on how to build networks in SCIRun.
Some of the features demonstrated in this tutorial include: loading data of various types, processing data for visualization and calculation, configuring and using SCIRun's interactive visualization tools, and creation and manipulation of simple data for use in calculations.
This tutorial will also provide details and descriptions of some of the specific functionalities, options, and nuances of SCIRun.

\subsection{Defibrillation Modeling Tutorial}

The SCIRun Defibrillation Modeling Tutorial provides a step by step description of how to calculate potential fields in a volume using finite element method, specifically as it applies to predicting the effects of defibrillation in the torso.
The use of this kind of calculation is highlighted in the Simulation of Defibrillation case study.
This tutorial will guide the reader in using many of the same features as the Basic Tutorial, but focuses more on calculation and data setup and formating.  

\subsection{Cardiac Ischemia Modeling Tutorial}

The SCIRun Cardiac Ischemia Modeling Tutorial provides a description to calculate the extracellular potentials in the myocardium during a portion of the cardiac cycle using an artificial ischemic region as an electric source.
This tutorial will provide insights into different ways to solve problems, and visualize data in SCIRun.
This tutorial highlights SCIRun's ability to handle vector and tensor data.

\end{document}
