SimVascular UserManual
SimVascular UserManual
COPYRIGHT 2003-2007 STANFORD UNIVERSITY. THE WORK (AS DEFINED BELOW) IS PROVIDED
UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE
WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK
OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE
BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO
BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN
CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS
PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR
OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS
LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE
BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO
BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN
CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such
as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or
artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in
which the Work may be recast, transformed, or adapted including in any form recognizably derived from
the original, except that a work that constitutes a Collection will not be considered an Adaptation for the
purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or
phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be
considered an Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or
performances, phonograms or broadcasts, or other works or subject matter other than works listed in
Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute
intellectual creations, in which the Work is included in its entirety in unmodified form along with one or
more other contributions, each constituting separate and independent works in themselves, which together
are assembled into a collective whole. A work that constitutes a Collection will not be considered an
Adaptation (as defined above) for the purposes of this License.
c. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as
appropriate, through sale or other transfer of ownership.
d. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of
this License.
e. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or
entities who created the Work or if no individual or entity can be identified, the publisher; and in addition
(i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing,
deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore;
(ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a
performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the
broadcast.
f. "Work" means the literary and/or artistic work offered under the terms of this License including without
limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form
of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address,
sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or
entertainment in dumb show; a musical composition with or without words; a cinematographic work to
which are assimilated works expressed by a process analogous to cinematography; a work of drawing,
painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated
works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan,
sketch or three-dimensional work relative to geography, topography, architecture or science; a
performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a
copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise
considered a literary or artistic work.
g. "You" means an individual or entity exercising rights under this License who has not previously violated
the terms of this License with respect to the Work, or who has received express permission from the
Licensor to exercise rights under this License despite a previous violation.
h. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public
those public recitations, by any means or process, including by wire or wireless means or public digital
2
performances; to make available to the public Works in such a way that members of the public may access
these Works from a place and at a place individually chosen by them; to perform the Work to the public by
any means or process and the communication to the public of the performances of the Work, including by
public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or
images.
i. "Reproduce" means to make copies of the Work by any means including without limitation by sound or
visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a
protected performance or phonogram in digital form or other electronic medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright
or rights arising from limitations or exceptions that are provided for in connection with the copyright protection
under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide,
royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in
the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work
as incorporated in the Collections;
b. to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any
medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to
the original Work. For example, a translation could be marked "The original work was translated from
English to Spanish," or a modification could indicate "The original work has been modified.";
c. to Distribute and Publicly Perform the Work including as incorporated in Collections; and,
d. to Distribute and Publicly Perform Adaptations.
e. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect
royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor
reserves the exclusive right to collect such royalties for any exercise by You of the rights granted
under this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect
royalties through any statutory or compulsory licensing scheme can be waived, the Licensor
waives the exclusive right to collect such royalties for any exercise by You of the rights granted
under this License; and,
iii. Voluntary License Schemes. The Licensor waives the right to collect royalties, whether
individually or, in the event that the Licensor is a member of a collecting society that administers
voluntary licensing schemes, via that society, from any exercise by You of the rights granted
under this License.
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above
rights include the right to make such modifications as are technically necessary to exercise the rights in other media
and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved.
4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following
restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a
copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You
Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms
of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient
under the terms of the License. You may not sublicense the Work. You must keep intact all notices that
refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or
Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective
technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise
the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as
3
incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made
subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to
the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested. If
You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from
the Adaptation any credit as required by Section 4(b), as requested.
b. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a
request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide,
reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if
applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties
(e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's
copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the
title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor
specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing
information for the Work; and (iv) , consistent with Section 3(b), in the case of an Adaptation, a credit
identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original
Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4
(b) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or
Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation
or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for
the other contributing authors. For the avoidance of doubt, You may only use the credit required by this
Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this
License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or
endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your
use of the Work, without the separate, express prior written permission of the Original Author, Licensor
and/or Attribution Parties.
c. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law,
if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or
Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work
which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those
jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the
right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other
derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not
assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable
You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but
not otherwise.
4
7. Termination
a. This License and the rights granted hereunder will terminate automatically upon any breach by You of the
terms of this License. Individuals or entities who have received Adaptations or Collections from You under
this License, however, will not have their licenses terminated provided such individuals or entities remain
in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this
License.
b. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the
applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the
Work under different license terms or to stop distributing the Work at any time; provided, however that any
such election will not serve to withdraw this License (or any other license that has been, or is required to
be, granted under the terms of this License), and this License will continue in full force and effect unless
terminated as stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient
a license to the Work on the same terms and conditions as the license granted to You under this License.
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to
the original Work on the same terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the
validity or enforceability of the remainder of the terms of this License, and without further action by the
parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such
provision valid and enforceable.
d. No term or provision of this License shall be deemed waived and no breach consented to unless such
waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with respect to the Work licensed here.
There are no understandings, agreements or representations with respect to the Work not specified here.
Licensor shall not be bound by any additional provisions that may appear in any communication from You.
This License may not be modified without the mutual written agreement of the Licensor and You.
f. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the
terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO
Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July
24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms
are sought to be enforced according to the corresponding provisions of the implementation of those treaty
provisions in the applicable national law. If the standard suite of rights granted under applicable copyright
law includes additional rights not granted under this License, such additional rights are deemed to be
included in the License; this License is not intended to restrict the license of any rights under applicable
law.
5
Authors:
6
Table Of Contents
SimVascular Users Manual ...................................................................... 1
Introduction .............................................................................................. 9
Theory and Implementation ...................................................................................................... 10
Getting Started ....................................................................................... 13
Installation: Basic Steps for SimVascular Users ...................................................................... 13
Cygwin ...................................................................................................................................... 14
Demo Data ................................................................................................................................ 15
Starting Up Simvascular ........................................................................................................... 16
Loading in MRI Files ................................................................................................................ 19
Saving File Information ............................................................................................................ 22
Section 1: Visualizing Volumetric Medical Imaging Data ................... 23
Exercise 1.1: Viewing image slice planes............................................................................ 24
Exercise 1.2: Changing the window level............................................................................ 26
Exercise 1.3: Visualizing point clouds................................................................................. 29
Exercise 1.4: Using volume rendering ................................................................................. 32
Exercise 1.5: Creating a Maximum Intensity Projection (MIP) .......................................... 35
Exercise 1.6: Resampling the volume data .......................................................................... 36
Exercise 1.7: Combining several visualization techniques .................................................. 40
Exercise 1.8: I can’t find the visualization windows ........................................................... 41
Section 2: Creating Geometric Models from Medical Imaging Data..... 42
Section 2.1: Path Planning ....................................................................................................... 44
Exercise 2.1.1: Creating a path ............................................................................................ 45
Exercise 2.1.2: Smoothing a path-OPTIONAL ................................................................... 52
Exercise 2.1.3: Saving and loading paths ............................................................................ 55
Section 2.2: Segmentation ....................................................................................................... 57
Exercise 2.2.1: Using Groups .............................................................................................. 58
Exercise 2.2.2: Visualizing Segmentations.......................................................................... 63
Exercise 2.2.3: Using Thresholding to Define a Contour .................................................... 68
Exercise 2.2.4: Using Level Sets to Define a Contour ........................................................ 78
Exercise 2.2.5: Segmenting an Image by Hand ................................................................... 93
Exercise 2.2.6: Fitting an Analytic Shape to the Image ....................................................... 97
Exercise 2.2.7: Copying and Pasting Contours .................................................................... 99
Exercise 2.2.8: Modifying Contours .................................................................................. 102
Section 2.3: Creating a Solid Model from 2-D Segmentations ............................................. 105
Exercise 2.3.1: Using Groups of Segmentations to Create Solid Models ......................... 106
Exercise 2.3.2: Joining Vessels Together to Create a Model ............................................ 124
Exercise 2.3.3: Blending the Junction of Two Vessels...................................................... 132
Section 3: Robust Model-Building and Instructions for the AAA Project
.............................................................................................................. 136
Section 3.1: Determining Right and Left ................................................................................ 138
Section 3.2: Determining Which Branch Vessels to Include .................................................. 138
Section 3.3: Perpendicular Outlets.......................................................................................... 140
Section 3.4: Where to End a Branch Vessel: Avoiding Tortuosity and Bifurcations ............. 142
7
Section 3.5: Which Segmentation Technique to Use.............................................................. 144
Section 3.6: Construction and Naming Conventions .............................................................. 148
Section 4: Generating Volumetric Flow Waveforms from PC-MRI Data
.............................................................................................................. 150
Exercise 4.1.1: Loading and Viewing PC-MRI Data ........................................................ 151
Exercise 4.1.2: Segmenting PC-MRI Data ........................................................................ 154
Exercise 4.1.3: Applying Baseline Corrections to PC-MRI Data ...................................... 161
Exercise 4.1.4: Computing Volumetric Flow Rates .......................................................... 165
Exercise 4.1.5: Getting the Heartrate from the Phase Contrast Data ................................. 168
Exercise 4.1.6: Importing and Graphing the Volumetric Flows in Excel.......................... 169
Exercise 4.1.7: Fourier Filtering the Volumetric Flow in MATLAB ................................ 174
Glossary ............................................................................................... 177
Glossary: Unix Commands .................................................................. 178
Files ......................................................................................................................................... 178
Directories ............................................................................................................................... 178
References ............................................................................................ 179
8
INTRODUCTION
One of the main goals of the Cardiovascular Biomechanics Research Lab (CVBRL) at Stanford
is to use numerical flow simulations to study hemodynamics. These simulation results can
provide insight into vascular disease processes. They can also aid vascular surgeons in treatment
planning, as well as help engineers in designing better medical devices. A number of software
packages are used in generating the files for and running these flow simulations.
The primary software system is SimVascular, which is descended from the ASPIRE2 internal lab
software. Primarily designed by Ken Wang, Ph.D. and Nathan Wilson, Ph.D., SimVascular is
customized for building geometric models from medical imaging data, generating the data files
needed to run flow simulations, and processing and visualizing the results from these
simulations. It can also be used to interact with and visualize the medical imaging data directly.
SimVascular also incorporates an integrated one-dimensional and three-dimensional flow solver.
The three-dimensional solver is developed jointly with research colleagues at Rennselaer
Polytechnic Institute led by Prof. Ken Jansen.
Although SimVascular was designed for internal lab use, Charles Taylor, the director of the
CVBRL, decided to open source much of his lab’s software through Simbios, the NIH Center for
Biomedical Computation at Stanford. The released SimVascular software is a snapshot of the
lab’s software with proprietary elements either removed or made available to the general public
through a licensing process.
SimVascular currently requires the use of three commercial software packages. Parasolid is a
high-performance 3D geometric modeling software component from UGS. MeshSim, from
Simmetrix Inc., is component software for automatically generating high-quality meshes directly
geometric models. LesLib, from AcuSim Inc., is an iterative solver. Rather than expend
substantial time trying to duplicate the functionality provided by these commercial components,
the CVBRL simply licensed the commercial software and integrated it into the SimVascular
system. The initial public release of SimVascular requires licensing of these components as well.
In addition, this tutorial will show you how to make the following “deliverables:"
1. A solid model representing the flow domain of file type model_name.xmt_txt
2. A volumetric flow waveform, processed in SimVascular, MATLAB, and excel
A separate manual, SimVascular Solver Users Manual, describes the use of the software for
three-dimensional blood flow numerical simulations.
9
Theory and Implementation
The theory and implementation details are not covered in this document. For more information
about those details, please refer to the following theses:
K.C. Wang, “Level Set Methods for Computation Prototyping with Application to
Hemodynamic Modeling,” Department of Electrical Engineering, Stanford University, 2001.
N.M. Wilson, “Geometric Algorithms and Software Architecture for Computational Prototyping:
Applications in Vascular Surgery and MEMS,” Department of Mechanical Engineering, Stanford
University, 2002.
The above theses as well as papers and videos useful to SimVascular users can be found on the
SimVascular documentation page and the SimVascular Application project page.
10
Using this Manual
This document is designed both as a training manual and a reference guide. If you are unfamiliar
with SimVascular , you can go through the exercises in this document sequentially to learn how
to use this software package. A demo data set can be downloaded from the SimVascular
Application download page at Simtk.org. The figures correspond to results using this demo data
set.
NOTE: The exercises assume that you do not shut down SimVascular. If you need to stop at
any point, make sure you save the data that you’ve generated and that you load them back in
when you start up again. Below is a chart detailing what you need to load for a given task when
restarting SimVascular.
If you already know how to use these software packages, this document is still valuable,
addressing many common mistakes and errors that users make. Look for the HELPFUL HINTS.
1. Text in italics are things that you type into the command window.
2. Text in brackets < > describe what you need to type in. You do not type in the
brackets and text, but instead substitute it with what it’s asking for. Example:
If the instructions tell you to type in more <file_name>, what you actually type in is
more output.log, where output.log is the name of the file you’re interested in.
3. Buttons, window names, and other labels in a window in the SimVascular program
will be in quotes.
11
5. There is a lot of flexibility in this software. The exercises typically will show you
one way to accomplish a task. Other ways to get the same results will be indicated
with the label ALTERNATIVE.
6. Experience is the best teacher. Useful tips from experienced users are given
throughout this manual and are indicated by the HELPFUL HINT label. Common
errors are indicated by the label GETTING AN ERROR? Things that may cause
SimVascular to close, crash, or lead to other problems are shown as a WARNING.
12
GETTING STARTED
1. If running Windows, download Cygwin, a Linux-like environment for Windows. Install the
full cygwin environment. (For a tutorial on Cygwin installation, please go to the
SimVascular wiki page: http://wiki.simtk.org/simvascular/Cygwin)
3. Download the SimVascular base install tarball. (A tarball is an archive that can be opened
using tar zxvf my-archive.tar.gz.) Separate tarballs are available for academic and
commercial users, so choose download one of the following:
simvascular-x86-academic-install.<Date>.tar.gz
or
simvascular-x86-commercial-install.<Date>.tar.gz
This tarball includes precompiled x86 binaries for libraries like VTK, MPICH2, Tcl/TK, and
support libraries for Fortran and Visual Studio C++.
4. Open a cygwin shell (see the following section on opening the cygwin shell) and type the
following:
% cd <directory-where-you-put-tarball>
% tar zxvf simvascular-x86-academic-install-Aug-30-2007.tar.gz
% cd remote_install_simvascular
simvascular-licensed-x86.<Date>.tar.gz
6. Download the SimVascular Parasolid Driver tarball from a UGS FTP site. Your account and
password for the UGS ftp site will be provided after licensing Parasolid from UGS. This
tarball, like the tarball in #5, should be placed in the remote_install_simvascular
13
directory.
% ./simvascular-x86-install.sh
The script will extract the files from the tarballs and place them in the appropriate directory.
Cygwin
SimVascular is run from a Linux environment. On the PC, you can use a program called
Cygwin to emulate the Linux environment. Linux? What’s that? It’s an operating system, like
Windows or DOS. And while you won’t need to know how to use it to get through these
exercises, it will be important to know the basics once you start running simulations on your
own. For more Linux commands, please see the “Glossary: Linux Commands” at the end of this
tutorial.
Now let’s get started. From one of the lab PCs, double-click on the Cygwin icon to start up
Cygwin:
14
Demo Data
1. Next, we need some data. The demo data we will be using is of the aorta and the iliac
bifurcation, shown below in blue. You can also see parts of the kidney attached to the renal
arteries, which branch off of the aorta.
2. The demo data can be downloaded from the SimVascular project documentation page at
Simtk.org (http://simtk.org/home/simvascular_docs). Download the demo data tarball onto
your local computer. (The image data is also available in DICOM and VTK VTI formats
within the subversion repository for the simvascular_docs project.)
This will create a directory, Tutorial_Files, containing the tutorial image files.
4. Then copy the extracted directory to your personal area. In the Stanford lab where
SimVascular was created, lab members own a directory labeled with their user name. For the
purposes of this tutorial, we'll assume you have a home directory on a hypothetical "x" drive.
For most people, they'll use a "c" drive instead of a "x" drive. Copying the extracted image
data will look something like this:
cp –R Tutorial_Files /cygdrive/x/<your_user_name>
The /cygdrive/ command allows you to switch between drives. This copies all the files and sub-
directories in the Tutorial_Files directory to a directory (<your_user_name>) on the x drive.
15
Starting Up Simvascular
1. Changing to the correct directory. Before we launch SimVascular, we need to make sure
that we are in the correct directory. The directory where you launch SimVascular will be the
directory where all your paths, segmentations, and groups will be saved. In general, you
should always launch SimVascular from the same directory for any given model. Thus if you
have three different patients, patients 1, 2, and 3, that you need to build models for, you
should be careful to launch SimVascular from within the “patient_1” directory when you are
working on the model for patient 1, likewise, if you are working on patient 2, you should be
sure to launch SimVascular from within the “patient_2 directory”. If you are not careful
about this, you may end up mixing segmentations, groups, or paths between models, which
leads to mayhem!
WARNING: SimVascular does not handle spaces well. Thus, all of your directories in your
path must not have any spaces. That is why the directory in the example above is called
“patient_1” and not “patient 1.” For this reason, do not store any of your SimVascular folders
on your desktop, because the path to the desktop is:
Okay, let’s change to the correct directory. At the command prompt ($) in the Cygwin
window, type:
cd /cygdrive/x/<your_user_name>/Tutorial_Files
The cd command, under both Linux and DOS, is the command to change directory (or
"folder" in Windows terminology).
simvascular
16
The following window may appear:
The default option ("Yes") selects the new Graphical User Interface (GUI) under
development for SimVascular. Selecting "No" uses the old interface, which may be
necessary for some operations. However, this interface will be eliminated in the Beta release
of the software (scheduled for September 2007). This manual will be updated with the new
17
interface as functionality is available, but users may need to use the old interface for some
functionality.
After selecting "YES", two additonal windows will appear (see below). The "SimVascular
Command Console" is where you can type in special commands In addition, the window
contains numerous debugging messages as well as error messages.
The “SimVascular GUI” will be your guide in constructing models and running simulations.
It consists of a number of tab notebook pages. It is roughly organized in the order of the
steps you will be performing.
WARNING: You should not close the "SimVascular Command Console" window since it
cannot be redisplayed unless you restart SimVascular! You can safely minimize this
window, however.
18
Loading in MRI Files
1. In the “SimVascular Main Menu,” select File->Load Image Data (see below). If you have
magnetic resonance imaging (MRI) data, you can use this window to load in your data.
“Volumetric Image Data” usually refers to a magnetic resonance angiography (MRA) data,
while the "Load PCMRI Data" tab is used to load Phase Contrast MR Image (PC-MRI) Data
which is experimental temporal planes of velocity and flow data information. For example,
the velocity information may be used at the inlet of your model.
2. In the “Load Image Data” window, under the “Volumetric Image Data,” click on the
“Browse” button for the “Slices Directory.” The window below appears. Click on the folder
x:<your_user_name>/Tutorial_Files /Image_Data/004, and then click on OK.
19
Click on the “Load Volumetric Image Data” button.
ALTERNATIVE: You could also have typed in the file name for the first image in the data
series (not the directory!) into the field for “Slices Directory.”
3. Similarly, for the Phase Contrast MR Image Data, click on the “File->Load PCMRI data.”
Click on the browse button and select the directory x:<your_user_name>/Tutorial_Files
/Image_Data/005.
When the data loads in, it shows the number of pixels in the data set under the “minimum”
and “maximum” columns. If you only want to load in a subset of the data, you can modify
these values.
ALTERNATIVE: You could also have typed in the name for the first velocity image file in
the data series (not the directory!) into the field for “Slices Directory.” This is usually not he
file I.001!
4. Once the volumetric imaging data have been loaded into SimVascular, two more windows
will appear: the "SimVascular Volume Visualization" window and the “SimVascular 3-D
Graphics Window”, shown below. (See the section on Visualizing Volumetric Medical
Imaging Data for more information about these windows.)
20
21
Saving File Information
1. To avoid remembering exactly which files were used and what parameters were specified,
you can save all this data into a single file. From the “SimVascular GUI,” select "File->Save
Options" and click on the "Save Options" button.
2. In the "SimVascular Command Console" window, you will see a message saying: Save file
created (Tutorial_Files.patient). The Tutorial_Files.patient is the name of the file, so the next
time you start up SimVascular from this directory, the information about the volumetric
imaging data file, the phase contrast MR imaging data file, etc. will already be available.
Note that you will still need to actually load in the data, but the file names will be filled in
already.
22
SECTION 1: VISUALIZING VOLUMETRIC MEDICAL
IMAGING DATA
Typically imaging data is a set of scalar values (e.g. integers ranging from 0 to 4096) defined on
a structured 3D grid. Note that this data may be acquired in 2D slices and resampled in some
fashion.
The most common use for (diagnostic) medical imaging data is for visualization. For example, a
vascular surgeon may acquire image data on a patient suspected of having vascular disease.
Traditionally, most surgeons and radiologists look at sets of 2D slices of image data acquired in a
3D volume. This requires the person to create a mental image of the patient’s 3D anatomy.
SimVascular has numerous ways to view and interact with medical imaging data. The first is to
visualize slices of image data parallel to the major coordinate axes. See Exercise 1.1: Viewing
image slice planes. Note that this method is somewhat similar to the way some radiologists
visualize data.
A very common technique in viewing image data is to use “window leveling.” Window leveling
basically creates a non-linear color mapping function to help distinguish features in the image
data. See Exercise 1.2: Changing the window level.
An additional technique gaining popularity is known as 3D volume rendering. The user defines
an opacity transfer function (which can be non-linear) and uses ray casting (or hardware
acceleration) to render the 3D volume. It should be noted that 3D volume rendering is the most
computationally intensive method of visualizing imaging data and usually requires very high-end
graphics cards for decent performance. See Exercise 1.4: Using volume rendering.
Dealing with the entire volume of data can be a computational challenge (particularly for
computed tomography angiography, or CTA, data). Often you may only be interested in viewing
a sub-volume or sub-sampled part of the data. Inside of SimVascular, all of the techniques
discussed previously can be used on a sub-sampled/sub-volume of the dataset. See Exercise 1.5:
.
Most of the above techniques can be combined inside of SimVascular. This will be especially
useful when automated techniques do not work on your data set and you must manually generate
information for the model construction or simulation. See Exercise 1.7: Combining several
visualization techniques.
23
Exercise 1.1: Viewing image slice planes
This exercise will work with the “SimVascular Volume Visualization” window and
“SimVascular 3-D Graphics Window” extensively.
You can turn on/off the image slices by checking / deselecting the checkboxes labeled “L/R”,
“P/A”, and “I/S”. You can change the location of each plane by moving the scale bars. “L/R”
refers to left/right direction; “P/A” refers to posterior/anterior direction; “I/S” refers to
inferior/superior direction.
The volume dataset we are using for this demo is 512 x 64 x 512 voxels. This explains why the
L/R and I/S scale widget allows you to move between 0-511, while the P/A scale widget only
allows you to go from 0-63. These are indices. The actual physical location (in mm, cm, etc.) is
indicated by the numbers at the top for R, A, and S.
Select the options exactly as they appear below (L/R: 258, A/P: 26, S/I: 351). The corresponding
physical location in space is indicated at the top of the window (R: -2.047, A: 1.800, S: 45.110).
toggle image
image plane
planes scale
on/off bars
24
And you should see something similar the image below in the “SimVascular 3-D Graphics
Window.”
Try changing the size of the viewing window, moving the sliders and turning on/off different
combinations of the image planes.
Use the mouse buttons to look at the data from different perspectives.
Rotations: Hold down left mouse button and move the mouse.
Zoom: Hold down the right mouse button and move the mouse.
Pan: Hold down the middle (or the shift key + the left mouse button) and move the
mouse.
HELPFUL HINT: If you ever get lost navigating through your data, press the “r” key to resize
your data.
25
Exercise 1.2: Changing the window level
Window leveling determines the mapping between your imaging data and the colors that are
displayed. Specifically, the “window” value actually defines the center of the color range, while
the level defines the width of the “band” around the center. For example, the default color map
of “[0 255]” corresponds to values of window = 127.5 and level = 255 as seen in the following
color lookup table:
26
1. To see what effect the window leveling has on the data displayed, first turn off all of the
visualization techniques from the previous exercises before continuing.
2. Position the P/A scale to position 30. Display (i.e. click the checkbox) the “P/A” image
plane. Click on the radio button to switch between the “[0 255]” color map to “native [0
715]” in the “Volume Image Browser” window (see below).
You should see (or in reality barely see) an image similar to that below.
27
The reason you don’t see much for the native range is because we are doing a simple linear
mapping from black to white as seen in the following color lookup table:
The useful range of the imaging data is much smaller than the total range (0 to 715) that is
available.
3. Now we are going to try a non-linear color mapping function. Move the cursor (i.e. arrow
pointer) into the “SimVascular 3-D Graphics Window.” By holding down the up-and-down
arrow keys, you change the maximum displayed value (all values equal to or greater than this
value are displayed as white). By pressing the left or right arrow keys you change the
minimum displayed value (all values equal or below this value are shown as black). Can you
get an image similar to that shown below?
4. Set the color map radio button back to “[0 255]” in the “Volume Image Browser” window.
28
Exercise 1.3: Visualizing point clouds
1. Turn off all of the image planes in the view window (i.e. remove checks for “L/R”, “P/A”,
and “I/S” planes) from the previous exercises.
2. Click on the “point cloud” checkbox to threshold the image data in the “Volume Image
Browser” window. The default minimum value for thresholding is 128.
29
3. Now try two different minimum threshold values: 80, 175. To change the threshold value,
enter the new value in the entry widget in the “Volume Properties” tab and hit RETURN.
When you enter the value of 80 you should see something similar to (b) above. Finally, try a
value of 175. You should get something similar to (c) above. Only the image intensity
values that fall within the specified min and max range are displayed.
30
physical location in space is indicated at the top of the window (R: -2.047, A: 1.800, S:
45.110).
Now change the "Threshold Range" to 90, click the "use seed" checkbox inside of the
"Threshold Range" frame, and then turn on the point cloud by checking "point cloud." You
see an image similar to the left below. Note that if you didn't use the "connectivity" filter,
you would get an image as shown on the right.
WARNING: Due to a bug in the interface, you may have to deselect and then reselect "point
cloud" if you change the value of "use seed" after you have already displayed a point cloud.
31
Exercise 1.4: Using volume rendering
1. Be sure to turn off all of the visualization techniques from the previous exercises before
continuing (no point clouds, no imaging slices).
2. In the "SimVascular Volume Visualization" window, click on the “Volume Rendering” tab.
You can manually set the transfer functions for volume rendering by clicking on the
"Manually set transfer functions" checkbox. You should see a window similar to below.
3. Check on "Turn on Volume Rendering." Depending on your hardware and dataset, you may
see the program run slower using this visualization technique.
The default opacity transfer function should be a list of points with each point enclosed in
brackets:
32
4. Now we are going to try a different opacity and color transfer function. In the “Volume
Rendering Options” window enter the following:
and press RETURN inside the entry widget. You should see an image like that below.
33
How did that work? The color function corresponds to the following table, where each color
component is specified as a value between 0 (turned off) to 1.0 (full intensity):
In addition to entering the points manually, you can interactively select the points using the
"interactively select transfer funtions" checkbox. You will see interactive lines where you
can move the boxes to change the value of the function (from 0 to 1 on the y-axis, from x-
minimum and x-maximum as specified in the "Intensity Range" entry widgets). To add
points, click on a box and a point will appear to the left at the midpoint of the current line
segment. Note that currently, you can only add points and not delete points.
34
Exercise 1.5: Creating a Maximum Intensity Projection (MIP)
1. To create a Maximum Intensity Projection (MIP), select the "MIP" tab in the "SimVascular
Volume Visualization" window (see below). Click on "Coronal MIP", and a new image
should appear as shown below (be sure to play with the window level!).
2. Click on the "Do not display" radiobutton to hide the window displaying the MIP.
HELPFUL HINT: You can change the "Slice Range" to use only some of the image slices when
creating a MIP.
35
Exercise 1.6: Resampling the volume data
In some cases, you may only want to interact with a subset of the volumetric data.
2. Now select the "Subvolume Properties" tab in the "SimVascular Volume Visualization"
window (see below).
36
Determining the Sub-Volume to Be Displayed
1. By defining the size and center of a box, you determine what sub-volume of the data to show.
The size of the box is a function of both the voxel size (can be integer or floating number)
and the box dimensions (integer values).
To begin with, set the values as follows (also shown in image above):
Box dims: R A S
min: -50 -50 -100
max: 50 50 100
There are 3 ways to set the center of the box: using the “Volume Sliders” (controlled with
image plane scale bars in “Volume Properties”), the “Path Plan Cursor” (controlled with
scale bars in the “Path Planner” window, discussed in the next section), or the “Path Point.”
For this example, select the “Volume Slider” option. Now click on the “Volume Properties”
window and set the image plane scale bars to:
L/R: 275
P/A: 41
I/S: 193
Click on the “Resample voxel size” checkbox in the “Subvolume properties” window. A
green outline of a box should appear in the “SimVascular 3-D Graphics Window.”
This box shows the bounding box of the sub-volume to be displayed.
HELPFUL HINT: Some of the changes occur automatically but others won’t take place until
you hit the “Update display” button in the upper-right-hand corner. Changes to the values of
the image plane scale bars in the “Volume Image Browser” window won’t be observed until
the “Update display” button is pressed.
3. Enter a value of “2.34375” into the “resample voxel size” entry widget and hit RETURN.
Don’t forget to hit RETURN or else the new value doesn’t register with the system.
You are now resampling the volumetric data to a 2.34375 mm3 voxel volume from the
original submillimeter voxel data. This is 3 times larger than the original voxel size.
Visually, this displays the same sub-volume as using a “resample voxel size” of 0.78125 and
increasing the box dims min and max value by 3 (R min: -150, R max: 150, A min: -150, A
max: 150, S min :–300, S max: 300). The crucial difference is in the computational
37
overhead. The larger voxel size of 2.34375 mm3 has (1/3) 3 or 1/27th fewer voxels in the
sub-volume than that with a voxel size of 0.78125 mm3 and consequently, a significantly
lower computational overhead. Techniques such as resampling are useful when you are
interested in coarse representations of large anatomic features (e.g. the aorta).
1. Reset the values in the “Resample Volume Image Browser” window as follows:
Box dims: R A S
min: -50 -50 -100
max: 50 50 100
In the “Volume Image Browser” window, set the image plane scale bars to:
L/R: 275
P/A: 41
I/S: 193
2. There are 3 different ways to visualize the data inside this sub-volume:
a. point cloud: uses the threshold range information (see Exercise 1.3: Visualizing
point clouds above)
b. isosurface
c. volume rendering (see Exercise 1.4: Using volume rendering above)
For this example, we will just look at the data as a point cloud and as an isosurface.
3. Visualizing Point Clouds: Set the Threshold Range to min: 100, max: 715. Click the
“point cloud” checkbox in the “Resampled Volume Image Browser” window. You should
see something like the figure below. Notice that we now have only displayed part of the
volume (the aortic bifurcation, where the aorta divides into the right and left common iliacs).
38
Now turn off the point cloud (deselect the “point cloud” checkbox).
39
Exercise 1.7: Combining several visualization techniques
1. Uncheck the “Resample voxel size” box in the “Subvolume Properties” window.
2. One commonly used combination is the point cloud with an image slice. This is very helpful
when you are building geometric models.
In the “Volume Properties” window, set the threshold min value to 128 and click on the
“point cloud” checkbox in the “Volume Properties” window. In addition, turn on the “A/P”
image slice. Try changing the position of the A/P scale bar. You should see something
similar to that shown below.
3. When you are finished, reset the defaults in the “Volume Image Browser” window and turn
off all image visualization techniques.
40
Exercise 1.8: I can’t find the visualization windows
In the old GUI, if the windows for visualizing the data disappear or you just can’t find them, go
to the “SimVascular Main Menu.” Select Display->Show/hide 3-D window to bring up the
“SimVascular 3-D Graphics Window.” Select Display->Show/hide image browser window to
bring up the “Volume Image Browser” window. These selections are toggle choices, so if a
window is showing, clicking on this choice will hide the window. If the window is hidden,
clicking on this choice will show the window.
You may need to click on the selection twice in a row before the window pops up on top of all
your other windows. This happens if the window was originally on the screen but perhaps
hidden under some other windows. So the first time you click, say, Display->Show/hide 3-D
window, the “SimVascular 3-D Graphics Window” is hidden. The second time you make this
selection, the “SimVascular 3-D Graphics Window” appears.
Try this. Make sure both the “SimVascular 3-D Graphics Window” and the “Volume Image
Browser” window appear on your screen before continuing with the next exercises.
41
SECTION 2: CREATING GEOMETRIC MODELS FROM
MEDICAL IMAGING DATA
Our eye is able to distinguish different objects within an image, but to the computer, the image is
just a group of numbers to be displayed in a grid format. It is not able to distinguish what parts
of the image correspond to a specific object.
One way to describe an object within a computing environment is with geometric solid models.
SimVascular is one system that allows users to generate geometric models from medical imaging
data. The first step is to segment the medical imaging data and identify what parts of the image
describe the object of interest. While 3D segmentation methods are being developed,
SimVascular currently only supports a 2D segmentation method. The information from the
segmentations is then transformed into a solid model.
The figure on the next page describes the process in more detail. For the segmentation step,
paths along the vessels of interest need to be specified first (See Section 2.1: Path
Planning). 2D segmentations are then generated along each of the paths (See Section 2.2:
Segmentation) These segmentations can then be lofted together to create a solid model (See
Section 2.3.1: Using Groups of Segmentations to Create Solid Models ). A separate solid
model is created for each vessel, and these are all unioned together to create the final model (See
Section 2.3.2). The last step is to blend the vessel junctions so that they are smoother (see
section Section 2.4: Blending).
42
43
Section 2.1: Path Planning
Exercise 2.1.1 shows you how to generate a path. Exercise 2.1.2 shows you how to smooth a
path (this is optional). Lastly, exercise 2.1.3: Saving and Loading Your Paths, will explain how
to save your work, and then load it again after restarting SimVascular.
1. The paths you create determine where you will be able to perform segmentations.
Make sure your paths cover the entire distance of the vessel that you’re interested in
modeling. In general, it is a good idea to make your paths as long as possible. It is
much easier to make a path a little longer in both directions than to try to “add on” to
a path later.
2. The paths are also important in determining how individual vessels can be joined
together. It’s generally helpful if there is some overlap in the paths. This will ensure
that the inlet of the branch vessel will fit entirely inside of the main vessel.
3. Lastly, it’s easier if the paths pass near the center of the vessel lumens. This makes it
easier for the segmentation part of the process.
44
Exercise 2.1.1: Creating a path
The goal of this exercise is to create a path for the abdominal aorta and the right common and
external iliac. For more information on the anatomy of the abdominal aorta and its branch
vessels, please see the beginning of section 3. For more information on determining right and left
in your data, please see Section 3.1: Determining Right and Left.
Step 1: Open
path planner
window
Step 2: Specify
identification
information
about the path
Step 3: Either
pick points in
your path using
“t” command
(recommended)
or using slider
bars
Step 4: Click on
this button, and
the point should
appear in the
yellow list box
above
2. In the “Path Planner” window, specify fields that identify and characterize the path:
• The “Path ID” field requires an identification number (an integer) for the path. For
this example, enter the value “100” in the “Path ID” field and hit RETURN.
• The “Path Name” field associates a name with the path you are about to create. The
path name CANNOT have any spaces. For this example, enter the name “aorta” in
the “Path Name” field and hit RETURN.
45
• The “Num. Of Spline Pts” specifies the total number of points to include in the path.
It’s important to choose an appropriate number of spline points since they determine
the maximum number 2D segmentations of the vessel. If you only have 10 points in
your path, then you will only be able to generate 10 segmentations along your vessel.
We typically use 100 for smaller vessels and 300 to 500 for larger vessels. The
default is 50 points.
For this example, enter the value “300” in the “Num. of Spline Pts” field and hit
RETURN.
GETTING AN EROR? Make sure to hit RETURN after the entries, or else the path
will not be created!
2. Now we are ready to actually make a path. First, we need to decide where we should
start the path. In general, it is better to make your path as long as possible, within reason.
This is because it much easier to adjust an existing long path, than try to “add on” to a
path that is too short.
3. Let’s pick our first point at the very top of the aorta. To pick this first point, turn on your
point cloud (if possible) and use the volume image brower slider bars (not the path
planning slider bars) to navigate to the top of the image. You should see something like
this:
You will see later that our model won’t actually start this high. We are just making the
path long in case we need to later adjust the path length.
46
4. Next, zoom in and rotate the image so that you are looking at the inferior/superior plane
head-on. You will be looking at a cross-section of the aorta (see the image below). Move
the cursor to the center of the aorta and hit the “t” button. A point corresponding to the
spatial location will appear in the yellow “hand picked” points box.
Clicking on “t”
at a given
cursor location
adds the point
to the path-
5. Continue to move down the aorta using the “volume image browser” slide, adding 10-20
points per path. If you don’t move the “volume image browser” as you move down the
path, the points will not necessarily be in the correct 3D location.
6. To visualize the current path, click on “spline” in the path planner window (the location
of the spline button is shown below.)
47
Spline
“spline”
button
In the step 9, you will see that the points do not need to be perfectly centered in the
vessel.
HELPFUL HINT: When creating your paths, the 3D point clouds are a helpful guide in
selecting your points. However, they are highly dependent on the threshold values, so the
slice planes are a better way to check if your path is inside the vessels of interest.
7. Here are some other ways to modify the points in your path:
a. Select the point you want to delete by clicking on the point in the yellow
‘“Hand Picked” Points’ “Path Planner” window.
a. You can cut a point by first deleting the point in the step “deleting a point in
your path” above.
48
b. Select the location where you want to insert the point by clicking on the
coordinates in the list of “Hand Picked Points” in the “Path Planner” window.
This point should be BELOW the insertion point.
8. When you are finished with the aorta and right iliac (on the left side of the screen), you
might have something that looks like this.
You will notice that the path doesn’t do a very good job of staying within the model. This
is okay! We will fix this in steps 8 and 9.
9. Next we need to modify the path so it does a better job of staying in the vessel. In order
to do this, we first need to increase the number of grey balls—which are called
‘handles’—in the spline. In step 9, we will be moving these handles (and thus the path) so
that it does a much better job of following the vessel.
49
To change the number of handles, enter the number of handles you want in “num
handles” in the path planning window and hit RETURN. Next, click on the spline and
move it slightly (this will fix a bug in SIMVASCULAR that fails to immediately update
the path to the new number of handles). The location of “num handles” is shown below.
10. Now we are ready to adjust the path so it does a better job of staying within the vessel.
Begin to move the handles so that they (and thus the path) are in the center of the
vasculature. You may need to rotate the data in the “3-D graphics window” to make sure
that the path is truly in the vessel. If you zoom in on the right common and external iliac,
you will see that the path should do a much better job of staying in the vasculature now
(see below). When you are done, click “Update Path” (immediately to the right of the
“num handles” button and then save the path, as described in Section 2.1.3: Saving and
Loading Your Paths.
WARNING: If you don’t click “Update Path” and then save the path, none of the handle
adjustments will be saved! When you click “Update Path” you will notice that the
numbers in the yellow ‘“Hand Picked” Points window’ will be updated.
50
51
Exercise 2.1.2: Smoothing a path-OPTIONAL
If you made your path by moving around the grey handles, then the path will automatically be
smoothed and you can skip this exercise. However, if you made your path by hand-selecting
each point and then did not adjust the grey handles, or if your resultant path appears jagged, you
may want to smooth your path. SimVascular provides several parameters for smoothing the
path.
1. From the “Path Planner” window, click on the light blue button labeled “Smooth Path.” The
“Path Planner Additional Options” window will appear.
2. Under “Smoothing Options” in the “Path Planner Additional Options” window, set the
“Smooth path automatically” choice to “true.” Also set the following parameters:
Now click on the light blue “Smooth Current Path” button in the “Path Planner Additional
Options” window. You should see a much smoother path that better represents the medial
axis of the vessel, as shown below. Note that smoothing occurs on the current working
path. (See the section on “Use Fourier Smoothing” below for an example of how to select
52
the current working path.) Depending on how many points you had in your original path,
you may find that the smoothing may make the new path deviate from the vessel! This is
why smoothing should be used with caution.
If the “true” button is selected, then smoothing is applied to the path. If this is turned on
(“true” button checked) when you click on “Automatically Find Path,” SimVascular will
automatically generate a smoothed path for you, based on the smoothing parameters that
you’ve set. If you don’t want smoothing to occur, make sure the “false” button is
checked.
This parameter specifies which points will be used in the smoothing. If you enter “5,”
then only every 5th point will be used.
53
The resulting smoothed path will be saved under this ID number (integers only). If you
specify a path ID that has already been used, then that original path will be overwritten so
BE CAREFUL! In this example, our original path had a path ID of 100 and the
smoothed path was written to a path ID of 101.
Fourier smoothing generates a path using only a subset of the modes that describe your
original path. High modes correspond to very sharp changes in your path, while low
modes describe the smoother parts of your path. If you turn on the Fourier smoothing,
you need to specify the “Number of Modes” to keep. The fewer modes your path has, the
smoother it will be.
Try this exercise. If path “100: aorta” is not already in your path planner window,
choose it by clicking on the “select” button across from “Path ID” in the of the Path
Planner window.
HELPFUL HINT: Smoothing occurs on whatever path is selected as the current working
path. Make sure you’ve selected the right Path ID for your current working path!
4. Click the blue “DONE” button in the “Path Planner Additional Options” window to close the
window.
54
Exercise 2.1.3: Saving and loading paths
Saving Paths
That manual path took a while to create and you would probably prefer not to have to re-do it, so
make sure you SAVE your work as you go along.
Just select Path Planning->Save Paths from the “SimVascular Main Menu.” The dialog box
below will appear:
Enter the desired name for the file under “File name:” and click on the “Save” button. All the
paths since opening SimVascular that you’ve created will be saved into this one file. To avoid
confusion, please save all your paths under one name, such as mypaths.
WARNING: To avoid overwriting your old paths, if you close and then restart SimVascular, be
sure to load your mypaths file before you save a new path to mypaths.
Loading Paths
If you need to read in a file containing path information, simply select Path Planning -> Load
Paths from the “SimVascular Main Menu.” Select the file and click on the “Open” button. Note
that the paths are NOT created with the .path extension (this is a bug), so you will need to look
under “Files of Type->All Types” to load in a previously created path.
WARNING: When loading a path, there are two things to look for:
1. After you load a path, you may see that the path is not as tortuous as it should be (figure
A below). This is likely because the path has insufficient handles. To fix this problem,
55
increase the number of handles in the “Path Planner” window (be sure to press return).
This leads us to the next caveat.
2. When you increase the number of handles, you may see that the path goes straight and
skips a bunch of handles (figure B below). This is a bug. If you click on one of the
handles and move it very, very slightly, the path will update and follow the path of the
handles (figure C below). If the path still does not appear as tortuous as it should be turn
off and on the spline by clicking on “none” and then “spline” buttons next to the
“interactor button” in the “Path Planner” window.
56
Section 2.2: Segmentation
Extensive research has been conducted in the field of image segmentation, and as a result, many
different techniques have been proposed. The goal of all these techniques is to identify objects
or structures within an image in an automated fashion. For our purposes, we want to find the
vessel lumen.
Currently, only 2D segmentation methods have been incorporated into SimVascular. That means
that the segmentations are performed in a plane. So if we want to create a 3D model from our
3D imaging data, we generate a set of 2D segmentations along a given path (See Section 2.1 on
Path Planning). These 2D segmentations can be stitched together later to create a 3D model.
We use groups to organize these 2D segmentations, and in Exercise 2.2.1: Using Groups, we
will show you how to work with groups. In Exercise 2.2.2: Visualizing Segmentations, you will
learn about different ways to visualize data in the planes used for the 2D segmentations. This
will be important because ultimately, you, the user, must determine the acceptability of a given
segmentation. Look at the image below. Is the segmentation, show in blue, good or bad? You
really can’t answer that question without more information about the object. The semi-
automated segmentation methods provided within SimVascular save you the work of generating
the segmented contours, but you must decide if the segmentations are suitable for your purposes.
The next 5 exercises teach you about the different techniques available for producing a 2D
contour. One basic segmentation technique available in SimVascular is thresholding, which uses
the image intensities to define a shape (Exercise 2.2.3: Using Thresholding to Define a
Contour). The level set method uses both image intensity values and geometric constraints to
generate a segmentation (Exercise 2.2.4: Using Level Sets to Define a Contour). You can draw
the segmentation by hand (Exercise 2.2.5: Segmenting an Image by Hand), and in some cases,
you may just want to approximate the object with an analytic shape, such as a circle or an ellipse
(Exercise 2.2.6: Fitting an Analytic Shape to the Image). Or you may have to copy and paste a
shape. Exercise 2.2.7 (Copying and Pasting Contours). The last exercise teaches you how you
can modify the contour, if needed (Exercise 2.2.8: Modifying Contours).
In the end, you will be using a level-set technique to build the abdominal aorta, and you
will be drawing segmentations by hand and then using fit-circle to build the branch vessels.
Keep this in mind as you work through the exercises. More details about when to use each
segmentation technique will be discussed in section 3.5.
57
Exercise 2.2.1: Using Groups
Groups are used to organize the 2D segmentations or contours that you create. You want to have
a different group for each vessel that you are creating. In addition, you might only use a subset
of the 2D contours for producing the solid model of the vessel, so for future reference, it’s
helpful to save that subset of contours to a new group.
1. Open up the main window for generating the 2D contours. From the “SimVascular Main
Menu,” select Solid Modeling->Create Vessel. The “Branch Controls” window should
appear, as shown below.
2. To see what groups currently exist in your workspace, click on Commands->Group Control-
>Select Current Group. An empty yellow listbox will appear, as shown below. That is
because we have not created any groups yet.
58
Click the “DONE” button in this “Select a Group” window to close the window.
3. Create a group
a. Under “Group Options,” type the name aorta into the field for “current group.” The
names of your groups must not have any spaces in them.
c. Now create a group called oops. Type the name oops into the field for “current group”
and click on Commands->Group Controls->New Group to create the group.
c. Look at what groups you currently have in your workspace (Click on Commands->Group
Controls->Select Current Group. The list will now contain 2 groups, as shown below.
59
4. Delete a group
a. We don’t really want a group called oops. For one, it isn’t a very descriptive name. To
delete the group, enter the name of the group to be deleted into the field for “current
group.” You can type the name in or use the “Select” button to choose the group. (See
Step 5 below for more information about the “Select” button).
For this example, type oops in the field for “current group.”
b. Click on the Commands->Group Controls->Delete Group button. Notice that oops is still
listed as the “current group.” However, it is actually not in your workspace anymore. If
you open up the listbox again, oops will no longer be there.
HELPFUL HINT: Make sure you check the name of the group in the “current group” field
before you hit the “Delete” button. You don’t want to accidentally delete the wrong group!
5. Select a group
a. Click on the “Select” button under “Group Options.” The “Select a Group” window will
appear.
b. Double-click on the group with which you want to work. In this case, your only choice is
the group aorta. Double-click on aorta. The “Select a Group” window will close and the
name of the selected group will appear in the field for “current group.”
a. Loading and saving groups can be done using the “Group Re-Organizer” window. This
window is launched from the “SimVascular Main Menu” by selecting Solid Modeling ->
Group Control.
More information about the “Group Re-Organizer” window will be given in Exercise
2.3.1 Using Groups of Segmentations to Create Solid Models. All we want to do at this
point is save and load information about our groups.
60
b. To save your groups, enter a name for the directory where you want to save the data.
You can leave the default name “groups” in the group directory if you like. To see what
directory you’re currently in, go to the “tkcon” window and look at the prompt, as shown
below.
61
This part in parenthesis is the
directory that you are
currently operating in.
This is the same as typing in the full directory path (e.g. x:/<user_name>/Tutorial_Files/
groups).
Click on the “Save” button in the “Load/Save Groups” section. This will save ALL your
groups.
b. Loading your groups is similarly straightforward. In the field “group directory,” you
would enter the name of the directory where your group data exists. The same guidelines
for specifying directory paths when saving data apply here. Then click on the “Load”
button in the “Load/Save Groups” section.
WARNING: If you close SIMVASCULAR and then reopen it, the first thing you should
do is to load your groups. If you don’t do this, and you make a new vessel, your old
groups directory may be overwritten!
c. If you want to load an INDIVIDUAL group and then restore the segmentations
associated with that group (for instance after you close and re-open SimVascular), from
the Solid Modeling main menu go to branch controls-> Commands->Group Control-
>Load All Groups, and then Commands->Group Control-> Restore All Groups. If you
then make sure that the appropriate segmentation is checked in the potential and intensity
windows, you will see that the segmentation has been restored.
62
Exercise 2.2.2: Visualizing Segmentations
The “SimVascular 3-D Graphics Window” provides certain visualization features that are helpful
when generating the 2D segmentations.
1. Display the current path by selecting Display Options -> Branch Controls -> Show Path in
the “SimVascular 3-D Graphics Window.” The current path is listed in the “Branch
Controls” window. The default path when you open up the “Branch Controls” window is the
path with the lowest ID number.
2. Now turn on the 2D plane which you will use for your segmentations. We call this plane the
intensity probe and it is the image data perpendicular to your path. From the “SimVascular
3-D Graphics Window,” select Display Options -> Branch Controls -> Intensity Probe. You
can move the probe along the path by using the slider bar in the “Branch Controls” window.
63
3. To hide this path, select Display Options -> Branch Controls -> Show Path in the
“SimVascular 3-D Graphics Window” again. Similarly to turn off the intensity probe, select
Display Options -> Branch Controls -> Intensity Probe in the “SimVascular 3-D Graphics
Window” again.
HELPFUL HINT: If the “SimVascular 3-D Graphics Window” does not update, move the
cursor into the window and press the left mouse button. That will refresh the window.
64
4. If you want to select a different path (pretend for a moment that you have a path named 100:
aorta and 101: aorta), go to the “Branch Controls” window and click on “Select Current
Path” button. The “Select Path” window will appear, as shown below.
5. For the next step, display the path and the intensity probe, as described in steps 1 and 2
above.
There are two additional ways to view the data as you perform the segmentations.
1. The 2-D Reslice Intensity Window, shown below, displays the intensities of the slice plane
that is perpendicular to the path. This is the same image as that displayed in the intensity
probe but it’s easier to view in this separate window. Bring up this window by selecting
Commands->Display Windows -> Intensity Window in the “Branch Controls” window.
65
2. The 2-D Reslice Potential Window shows the magnitude of the image intensity gradients,
again in the slice plane perpendicular to the path. This means that large changes in intensity
values, such as that at the edge of vessels, are very bright in this view, and locations with
small changes in intensity values, such as in the vessel lumen, are dark, as shown below.
Bring up this window by selecting Commands->Display Windows -> Intensity Window in
the “Branch Controls” window.
3. To query the actual value at a given pixel, select Display Options -> Views -> Parallel
Projection in the “2-D Reslice Intensity Window.” The 2-D windows should disappear and
then reappear. Now, when you move the cursor over a pixel in the “2-D Reslice Intensity
Window” and press the left-mouse button the value of pixel under the cursor (and the
magnitude of the gradient at the given location) will appear as text in the graphics window,
as shown below.
66
You may need to resize the window to see the entire display at the bottom. Now turn off the
parallel projection by selecting Display Options->Views->Parallel Projection in the “2-D
Reslice Intensity Window.”
4. Additional options for using these windows are listed below. The level set and the threshold
options will be discussed in more detail in the corresponding exercises.
Display Options -> Show Window: Click on this to close the window.
Display Options -> Show All Options: Select this if you want to choose several display
options at once. Clicking on this will bring up a checklist for all the different options.
Window -> Save Image to File: Save the window display as a JPEG image.
Window -> Clear Window: Removes all objects in the window so that only the original
image intensity or potential is displayed.
67
Exercise 2.2.3: Using Thresholding to Define a Contour
WARNING: Currently, thresholding sometimes makes SimVascular crash after a few thresholds.
However the features you use in this exercise are similar or the same as the features in the level-
set segmentation and other techniques. Thus, please go through this exercise. However, please
remember that you will be using level-set and segmentation by hand followed by “fit-circle” to
create the final model. Thus, you do not need to save anything you create in this exercise.
1. Make sure the “Current Path” in the “Branch Controls” window is set to “100: aorta.” If not,
use the “Select Current Path” button to choose path ID 101.
2. For now, make sure that aorta appears in the “Branch Controls” window.
3. Open up the “2-D Reslice Intensity Window” and the “2-D Reslice Potential Window” as
described in Exercise 2.2.2: Visualizing Segmentations.
5. Intensity Values: There are many different ways to segment an image using thresholding.
You can set a set of criteria based on the intensity values. To do this:
a. Use the slider bar in the “Branch Controls” window to choose the position along the path
where you want to segment. In this case, set the “Current Position” to “0.”
68
b. Select “threshold intensity” in the gray area on the right.
c. In the field for “Threshold Value” in the “Threshold Segmentation Control,” specify the
intensity value to include in the contour. For this example, type the number 70 in the
field.
e. To visualize the segmentation, select Display Options -> Threshold -> threshold in the
“2-D Reslice Intensity Window.” You should see an image similar to the one below (the
image may vary depending on where you started your path). The thin blue lines show all
the pixels that have an intensity value of 70.
6. Selected Threshold: SimVascular only considers the threshold contour that contains the
specified center. This contour is called the “Selected Threshold Contour.” Select Display
Options -> Threshold -> selected threshold contour in the “2-D Reslice Intensity Window.”
The bright oblong shape in the center should now be outlined with a heavier blue line. This
is the selected threshold contour and is the object that would be added to a group to be used
for the final solid model.
69
7. Center: To select a different contour, you need to change the center. The “Center” for
thresholding defaults to X = 0 and Y = 0. This position corresponds to where your path is
located (another reason for having a path that is centered inside the vessel!).
a. To see where this is, select Display Options -> Threshold -> initialization sphere in the
“2-D Reslice Intensity Window.” A green circle/sphere will appear in the window, as
shown below. The center of that circle/sphere corresponds to X = 0 and Y = 0.
If you don’t see the green circle/sphere, move your cursor to the “2-D Reslice Intensity
Window” and type the letter r (This resizes the objects so they’re displayed in the
window.)
70
b. Now, if you shift the center, the selected threshold contour will change. Say we want to
pick the contour to be the little area to the upper-left of the main lumen (see arrow). Can
you adjust the center and size of the initialization sphere so that you segment this area?
You should end up with something like this.
71
c. For specifying the center, the values of X and Y are measured from the path location. So
a shift of –8.5 in X will yield the same results each time you do the segmentation.
d. Clearly, the contour does not describe the aorta very well. Go ahead and use a threshold
of 100 instead of 70. You should get something like this:
72
8. Batch Segmentation: You need to generate a series of these segmentations along the vessel.
An automated way to do this is to do a batch segmentation.
a. Specify the path positions you want to segment under “batch list” in the “Threshold
Segmentation Control” window. If you want to segment all 300 positions, you would
type in begin – end. Generally, you don’t need that many segmentations and might just
want to type in the specific positions.
For this example, type in 0, 29, 58 in the field for “batch list” to create a segmentation at
position 0, 29, and 58, and then click “Batch Segmentation” in the “Threshold
Segmentation Control” window. You will be asked if you want to attempt three
segmentations. Click Yes.
ALTERNATIVE: You could also do these segmentations manually by moving the slider
bar in the “Branch Control” window to position 0. Select the desired thresholding
parameters. Click on “Segment Current Position.” Move the slider bar to the new
position of 29. Click on “Segment Current Position.” Repeat for position 58.
If you want to segment at a regular interval, you can use a different convention for batch
segmentation. The notation for this type of batch list is start#-end# by #, where # is an
integer number. For example, if you wanted to segment out every 5th position between
position 0 and 300, you would enter 0-300 by 5. Enter 0-300 by 5 in the “batch list” and
then click “Batch Segmentation” in the “Threshold Segmentation Control.” Again, you
73
will be asked if you want to attempt 21 segmentations. Click “Yes”. You will be asked if
you really want to attempt 21 segmentations. Click “Yes” again.
HELPFUL HINT: If you need to use different thresholding parameters to segment different
positions, it is better to use the manual method.
a. Look at the selected threshold contours by selecting Display Options -> Threshold ->
selected threshold contour in both the “2-D Reslice Intensity Window” and the “2-D
Reslice Potential Window.”
Move the slider bar in the “Branch Controls” window to position 55. It might look
something like the segmentation below. The threshold contour here isn’t very desirable,
as shown below. There could be a branch coming off at this point. Whatever the case,
though, we want a more elliptical contour.
b. Fit Circles: One way to smooth the contours is to fit circles to them. Specify the
position(s) to modify. In this case, let’s just try it with position 0. Type 55 in for the
“batch list.” Do not hit the RETURN key. If you do, it will ask if you want to do a
segmentation. Click “no.”
Now click on the “Fit Circles” button (The “Interp. to Circle” button does the same thing)
and look at the results for position 55. Do you get something like that shown below?
The shape is smoother, but it isn’t that accurate a description of the vessel lumen.
74
c. Fourier Smooth: You can also use Fourier smoothing to smooth out the contour. Let’s
see what this does for position 55. First lets get back the original segmentation
(smoothing out the circle won’t help you much). Make sure that the “Branch Controls”
slider bar is still on slice 55, and then click on “Segment Current Position” in the
“Threshold Segmentation Control” window.
Enter a value of 4 in the field for “Fourier Smooth.” Then click on the button labeled
“Fourier Smooth.” This function works similar to the Fourier smoothing used in for path
planning. A small number means that SimVascular will use fewer Fourier modes in the
smoothing process, so a smoother contour will be produced. You should get something
similar to that shown below.
75
10. Add Contours to the Group: Once you have generated the segmentations you want to use
in your model building, you need to add them to a group.
a. Look in the “Branch Controls” window and make sure the “current group” is aorta. If
not, click the “Select” button in the “Branch Controls” window and select aorta.
WARNING: If you forget to type something in “current group” and then add the
segmentations to this blank group, SimVascular will create group whose official name is
a blank space. SimVascular doesn’t handle blank spaces very well, and this mistake may
cause SimVascular to crash. Thus, always try to double-check that the “current group”
has a name.
b. Now go back to the “Threshold Segmentation Control” window and enter in the contour
positions to add to this group. For this example, type in 0-300 by 5 in the “batch list”
field.
ALTERNATIVE: You can add the segmentations one position at a time by moving the
slider bar in the “Branch Controls” window to the desired position. Then click on the “Add
Current Position to Group” button in the “Threshold Segmentation Control” window.
11. Visualizing Threshold Contours: You can visualize these selected threshold contours
within your 3D imaging data. This is helpful for determining if you have enough contours, if
the contours overlap, etc.
76
a. In the “SimVascular 3-D Graphics Window,” select Display Options -> Branch Controls
-> Selected Threshold Contour. Also turn on the in intensity probe by clicking on Display
Options->Branch Controls->Intensity Probe form the “SimVascular 3-D Graphics
Window.”
b. Now move the slider bar in the “Branch Controls” window to position 0. A blue contour
should appear in the “SimVascular 3-D Graphics Window.”
Now SLOWLY move the slider bar from 0 to 300 in the “Branch Controls” Window. The
Selected Blue contours should appear similar to below:
c. You may notice that some of the positions are skipped. This is because SimVascular
could not find a closed contour at this location. This is where the copying and pasting a
contour, or creating a contour by hand, might be useful. These concepts will be covered
in Exercise 2.2.7: Copying and Pasting Contours and Exercise 2.2.8: Modifying
Contours.
77
Exercise 2.2.4: Using Level Sets to Define a Contour
Thresholding is very dependent on the user-specified parameters and does not always result in a
closed contour. An alternate method that’s been implemented within SimVascular is the level
set method. The details of this method are described in Ken Wang’s thesis (listed in the
Introduction). The basic idea is to segment images using both intensity values and geometric
constraints. Please remember that you will be using level-set and segmentation by hand followed
by “fit-circle” to create the final model. Thus, please follow the instructions for saving the
contours for this exercise.
1. To start, make sure your “Current Path” (in the “Branch Controls” window) is still set to
“100: aorta.” Click on the “Level Set” button. You should get a window like that shown
below. Now don’t get overwhelmed! There are many options here but some of them are
familiar. Most of the time, you’ll only be concerned with a handful of these parameters.
78
2. Let’s break this down a little and point out what’s familiar. The sections on “Single Slice
Segmentation Controls” and “Batch Segmentation Controls” are similar to those in the
“Threshold Control” window we used in Exercise 2.2.3: Using Thresholding to Define a
Contour. We’ll be using the buttons in these sections to actually do the segmentations, add
the segmentations to the group, and if desired, do some smoothing.
What’s new in these sections are the options “Guess Parameters” and “Run in Parallel (using
batchGUI).”
3. The “Additional Single Slice Manipulations” section will be covered in Exercise 2.2.7:
Copying and Pasting Contours and Exercise 2.2.8: Modifying Contours. So you can just
ignore that for now.
79
4. Before we take a look at these other parameters, make sure you have your visualization
windows open. Open up the “2-D Reslice Potential Window” and the “2-D Reslice Intensity
Window,” if they’re not already open. (See Exercise 2.2.2: Visualizing Segmentations)
In addition, if it is not already there, return the slider bar in the “Branch Controls” window
back to 0.
Because we will be adding contours to what will be the final vessel that defines the aorta, the
right common iliac, and right external iliac, type Aorta_Right_Common_External for the
“current group” in the “Branch Controls” window. For more on determining right and left in
the image data, please see Section 3.1: Determining Right and Left. For more information
about identifying the common and external iliacs, please see the beginning of section 3.
De-select all options related to thresholding in these windows. Look at the options under
Display Options -> Threshold in the “2-D Reslice Potential Window.” If any of the options
(threshold, selected threshold contour, initialization sphere) have a check next to them, click
that option to de-select it. Repeat this for the “2-D Reslice Intensity Window.”
So now in the “2-D Reslice Potential Window” and the “2-D Reslice Intensity Window,” all
you should see is the imaging data. There should not be any contours.
5. Stage 1 Parameters: In the first stage of the level set method, you have an intial contour,
(what we call a seed) that you grow or shrink. How that contour changes over time depends
on 3 things: a user-specified curvature threshold value, a magnification factor or a potential
value, and the magnitude of the image gradient.
Seed (Initial Contour): To visualize the seed, go to the “2-D Reslice Intensity Window,”
and select Display Options -> Level Set -> initialization sphere.
Repeat this in the “2-D Reslice Potential Window.” You should
see a green circle/sphere appear in the windows. This is your
seed contour. If you don’t see it, move your cursor to the
window and press “r” on the keyboard.
Can you move the seed to the left? How about upwards?
80
Curvature Threshold: Curvature is the inverse of radius. If you have a circle with a
radius of 4 mm, its curvature is 0.25. A circle of radius 1 mm
has a curvature of 1. When the curvature of the contour matches
that of the user-specified threshold, which is the field for “Kthr,”
the contour stops growing.
Magnification Factor: This corresponds to the field for “Multiply Local Max” under
“Stage 1 Parameters” in the “Level Set Segmentation Control”
window. Note that there’s a similar field for the “Stage 2
Parameters,” so be careful and make sure you change the right
field.
We’ll try out some exercises so you can get a better sense of this.
Explicit Potential Value: Another way to set this threshold value is by choosing “Explicit
Potential Value” and specifying it directly. Once the potential
exceeds this value, the contour will slow down and not grow as
quickly. Just as with the magnification factor, a higher value is
less restrictive.
a. In the “2-D Reslice Intensity Window,” select Display Options -> Level Set -> evolution
so that you can watch the contour change over time. Also select Display Options ->
Level Set -> segmentation to see the final contour that is generated. Make these
selections in the “2-D Reslice Potential Window” as well.
b. Set the slice position you want to segment, for this example, lets use position 0. If it is
not already there, move the slider bar to position 0 in the “Branch Controls” window.
81
c. What is the right seed size?
Set the following parameters under “Stage 1 Parameters” in the “Level Set Segmentation
Control” window:
Center: X = 0, Y = 0
Radius: 14
Kthr: 0.4
Select Multiply Local Max.
Set field for Multiply Local Max: .33
Now click on “Segment Current Position” in the “Level Set Segmentation Control”
window, and watch what happens in the “2-D Reslice Potential Window” or the “2-D
Reslice Intensity Window.”
A red contour (the contour is red during Stage 1) appears and begins growing. And it
spills outside of the object of interest, as shown below. The seed radius was too large in
this case.
HELPFUL HINT: Make sure your seed stays inside the object of interest since the
segmentation method GROWS the contour outwards.
So, can’t you just avoid this problem by always picking a really small radius? Two
problems. One: the smaller the radius, the more time it will take to grow the contour out.
The second reason is more subtle and involves the curvature threshold, so let’s take a
look at this more closely.
82
d. What do I choose for a curvature threshold value?
Well, you want to set the curvature threshold value based on the size of the object you are
segmenting and the amount of smoothness you want in the segmented contour. If your
object can be approximated with a circle of radius 2 mm, then you want to set the
curvature threshold, Kthr, to approximately 0.5 (the inverse of 2). You can loosen up this
criterion and specify a higher curvature threshold than this, if you don’t mind a rougher
(bumpier) contour and/or you are interested in capturing some of the finer details in the
lumen shape.
The algorithm used in SimVascular grows or shrinks your initial contour depending on its
curvature relative to the user-specified curvature threshold. If the curvature of the initial
contour is larger than the user-specified curvature threshold Kthr, the contour shrinks. If
it is smaller than the user-specified curvature threshold, the contour grows.
Now let’s look at what happens when you set a really small radius for the initial contour.
Set the following parameters under “Stage 1 Parameters” in the “Level Set Segmentation
Control” window:
Center: X = 0, Y = 0
Radius: 2
Kthr: 0.4
Select Multiply Local Max.
Set field for Multiply Local Max: .33
Now click on “Segment Current Position” in the “Level Set Segmentation Control”
window, and watch what happens in the “2-D Reslice Potential Window” or the “2-D
Reslice Intensity Window.” Can you explain what happens in terms of the curvature
threshold value?
What is the curvature corresponding to our initial radius here? It’s 0.5, which is larger
than the curvature threshold (Kthr) of 0.4. So your initial contour shrinks. This makes
sense if you look purely at the numbers. 0.5 is bigger than 0.4 so shrinkage occurs. (In
terms of the corresponding radii, this doesn’t really make sense. It’s just the way the
program was written.)
So, how can we get a usable segmented contour? You could increase the user-specified
curvature threshold (Kthr) to something bigger than 0.5, the curvature of a circle with
radius of 2. Change “Kthr” to 0.6 (all other parameters remain the same) and click on
“Segment Current Position” in the “Level Set Segmentation Control” window. You
should get a segmentation like that shown below in blue.
83
You could also have done this by changing the radius. Set the parameters in the “Stage 1
Parameters” of the “Level Set Segmentation Control” window to the following:
Center: X = 0, Y = 0
Radius: 4
Kthr: 0.4
Select Multiply Local Max.
Set field for Multiply Local Max: .33
Click on “Segment Current Position” in the “Level Set Segmentation Control” window.
You will find that you end up with a segmented contour very similar, if not exactly the
same, as when you used a radius of 2 and a Kthr of 0.6. So you can see that there is some
robustness against user-defined parameters in this implementation of the level set
method.
e. What effect does this multiplication factor/explicit potential value have on the
segmentation?
Let’s try it and see. We’ll work with the multiplication factor (the field for “Multiply
Local Max By”) first. Set the parameters in the “Stage 1 Parameters” of the “Level Set
Segmentation Control” window to the following:
Center: X = 0, Y = 0
Radius: 4
Kthr: 0.4
Select Multiply Local Max
Enter different numbers—any floating number from 0 to infinity works!—into the field
next to “Multiply Local Max By.” The default is 0.33. How can you generate a contour
about the size of the initialization circle/sphere? How can you get something that grows
beyond the vessel edges?
84
If you set the field for “Multiply Local Max By” to 0.001, the final segmented contour is
about the size of the initialization circle/sphere. A multiplication factor of 0.001 results
in a very low threshold value, which means that the contour will only grow in those areas
where the potential is very, very small (corresponding to the “blackest black” regions of
the potential image). Reality is the contour’s just not going to grow much.
Now, if you set the field for “Multiply Local Max By” to 0.8, the contour leaks outside
the object of interest. You can watch it to the bitter end or press the “Halt Segmentation”
button in the “Single Slice Segmentation Controls” section of the “Level Set
Segmentation Control” window.
Notice that where it leaks first is the right side of the vessel, where the potential image
has more gray and black pixels. This area has lower potentials (white is high, black is
low), so this area will more likely remain beneath a given threshold than other parts of
the vessel. This means the contours will more likely grow more in this area, as shown
below.
85
The values for the “Explicit Potential Value” work in a similar way. Higher numbers
result in the contour growing more; lower numbers slow down the contour growth. You
can experiment with this by selecting “Explicit Potential Value” and changing the value.
For imaging data where the edges are defined fairly well, you can typically just use the
default: Select Multiply Local Max and use the factor of 0.33.
f. Now reset the values for the “Stage 1 Parameters” in the “Level Set Segmentation
Control” window to the following:
Center: X = 0, Y = 0
Radius: 4
Kthr: 0.4
Select Multiply Local Max
Set field for Multiply Local Max: .33
6. Stage 2 Parameters: You’ll notice that Stage 1 of this level set method (shown as the
growing red contour in the “2-D Reslice Potential Window” and the “2-D Reslice Intensity
Window”) results in a contour that only approaches the edge of the vessel. It doesn’t actually
grow to the vessel edges.
Why is this? The potential shows an edge as having a finite thickness, represented by the
doughnut-like structured in the middle of the “2-D Reslice Potential Window.” The red
contour, the result of the Stage 1 segmentation, stops at the inside ring of this doughnut,
86
where there’s a large change in the potential (see figure below). What our eye picks out as
the vessel edge, though, is actually somewhere in the middle of the doughnut. Stage 2 grows
the contour out to the middle of the doughnut.
It does this by first checking that the curvatures for the contour are within the user-
specified bounds: “Klow” and “Kupp.” If the curvatures are within this range, then the
speed at which the contour grows depends only on the user-specified stopping criteria
and on the potentials, or the magnitude of the image gradient.
You can experiment with the “Stage 2 Parameters” on your own. The following list
defines the parameters and provides guidelines on how to set them. In most situations,
the only parameter you will be concerned with is “Kupp.” For the most part, you will be
able to leave the stage 2 parameters as their default parameters.
87
Multiply Local This doesn’t work the same way as in stage 1. for now, leave this
Max By: as the default value.
Explicit This doesn’t work the same was as in stage 1. For now, leave this
Potential Value: as the default value.
7. Common Parameters: In general, the defaults are used for these parameters, so we won’t
experiment with them here. Thus, section 7 is completely optional. For completeness,
though, the common parameters are listed and described below. You can test them out on
your own.
Max Steps: This is the maximum number of time steps to use for a
segmentation. Even if the contour has not stopped evolving
when this number of time steps has passed, SimVascular will
stop segmenting the image at this position. You can find out
how many time steps a segmentation takes by watching the
“tkcon” window during a segmentation. This is useful in
preventing the program from getting stuck on an image that is
extremely difficult to segment.
Grid Factor: This determines the spatial resolution used in growing and
shrinking the contour.
Goodness Stop
Criteria: To determine when to stop growing or shrinking the contour, a
goodness stop criteria is used. This compares the contour
generated by the current time step to the previous time step. If
the two contours are similar enough in shape, SimVascular will
stop segmenting the image at this position. The exact measure
for determining similarity S is
where shape 1 and shape 2 are the areas based on the contours at
the current and the previous time steps.
S runs from 0 to 1. The more similar shape1 and shape2 are, the
closer S is to 1. Lowering this number will typically result in
faster, less accurate segmentations.
Check Area
Interval: This determines how often the area and the goodness stop criteria
are computed. The value entered in this field is the number of
time steps.
88
8. Adding One Level Set Contour to a Group
The segmentations that you have generated are not saved until you add them to your group.
So reset all the parameters to their default values:
Stage 1 Parameters:
Center: X = 0, Y = 0
Radius: 4.0
Kthr: 0.4
Select Multiply Local Max
Set multiplication factor (Multiply Local Max By): 0.33
Stage 2 Parameters:
Klow: 0.0
Kupp: 0.4
Select Local Max
Set multiplication factor (Multiply Local Max By): 0.1
Common Parameters:
Max Steps: 500
Grid Factor: 1.0
Goodness Stop Criteria: 0.99
Check Area Interval: 50
Stop Velocity: 0.01
Rebuild Phi After Every: 5
Make sure your slider bar in the “Branch Controls” window is set to position 0, and that your
“current group” is “Aorta_Right_Common_External”. Now go back to the “Level Set
Segmentation Control” window and click on the “Segment Current Position” button. Once
the segmentation is done, click on the “Add Current Position to Group” button.
Now that you know how to segment one position using level sets and can add it to a group,
let’s try it with a whole series of positions. There are multiple approaches for doing this.
Some users like to generate a level set segmentation for each point along the path, and then
later in the process, select a subset of those for creating their geometric model. There are
fewer user decisions to be made upfront and you will have all the possible segmentations to
use in constructing your model. However, the process will take longer than other
approaches.
A second approach involves pre-selecting the locations for the segmentations, so that only a
handful of locations get segmented. This will be faster than generating all of the segmented
contours at once. However, it requires user knowledge about which locations are important
for the modeling, and it can be especially tedious for vessels with large curvature and/or
89
radius changes. It may also require going back and segmenting other locations later in the
process.
In general, you should go with the first approach: Making more segmentations than you will
need and then selecting a subset to define the vessel.
So that we can proceed with the example, go ahead and use a level-set technique to segment
every 5th point the abdominal aorta from point 0 in your path until just before the aortic
bifurcation (where the aorta becomes the right and left common iliac). Then, Fourier smooth
each of these segmentations to five modes. As you will see in section 3.5, this is what you
will be asked to do for the AAA project.
You should end up with something that looks like this (notice that the point cloud is turned
on).
90
Now you need to go and check for a few things.
First, check to see that the contours are in the center of the “donut” in the potential
window. An example of a contour that is in the center of the potential window “donut” is
shown below.
If the contour is not exactly in the center of the donut (like the example shown below),
you can scale it using the “scale by” button on the “Level Set Segmentation Control”
window (for more details on this, see exercise 2.2.8).
Secondly, you want to check to make sure that the segmentation does not include a
branch vessel, like the example shown below. Although the level set method can
segment these, including these in your final model will cause an artificial geometry know
as a “lofting artificact.” For now, you do not need to delete these segmentation, we will
fix them using “copy and paste” in Exercise 2.2.8: Modifying Contours.
91
HELPFUL HINT: You want the spacing between locations to be sufficient to capture the
curvature and other changes in the vessel. If the vessel is relatively straight, as is the case
in this the abdominal aorta for this dataset, you can space the segmentations relatively far
apart.
92
Exercise 2.2.5: Segmenting an Image by Hand
Sometimes it is not possible to use automated techniques to segment an image. Other times,
automatic techniques work, but yield poor contours. In these situations, you may need to
segment the image manually. Please remember that you will be using level-set and segmentation
by hand followed by “fit-circle” to create the final model. In this exercise, you will be
segmenting the right iliac (on the same path as 100: aorta) by hand. Please follow the directions
for saving the contours you generate in this section.
1. In the “Branch Controls” window, click on the “By Hand” button. The window below
should appear. The “Help Info” in this window tells you how to generate contours by hand.
We will also step through it in this exercise.
2. Select the position on the path for which you need to create a contour. Click on “Select
Current Path” in the “Branch Controls” window and select path 100: aorta. Slide the slider
bar until the intensity probe is just at the beginning of the right common iliac. Make sure that
the current group is still Aorta_Right_Common_External.
3. So let’s try segmenting this image by hand. In the “Create a Contour by Hand” window, turn
“Parallel Projection” on.
4. Under “Create Contour As,” select “Level Set.” We will not be actually using a level-set
technique to segment the images, we will simply be saving them as a level-set type.
93
5. Click on the “2-D Reslice Intensity Window” to activate it (you may need to zoom in and out
to activate it). Place the cursor along the edge of the vessel (you don’t need to click any
mouse buttons, just move the mouse) and press “a” on the keyboard. Move the mouse cursor
along the edge of the vessel just slightly to the right of the first position. Press “a” on the
keyboard to add this point to your contour. A red line will appear connecting the first and
second points, similar to that shown below.
6. Continue adding points around the edge of the contour by moving the cursor and pressing the
“a” key. If you make a mistake, just press the “Shift” key and the “a” key simultaneously
and this will remove the last point that you added to the contour.
Helpful Hint: If the red line does not show up, make sure that parallel projection is turned on
by clicking on Display Options->Views->Parallel Projection from the “2-D Reslice Intensity
Window” or “2-D Reslice Potential Window” and then zoom in and out to activate the
window.
7. When you’ve finished drawing the outline of the contour, press “c” to indicate that you’re
done and that the first and last points should be joined.
WARNING: Do not try to make the last point on top of the first point; while the contour may
look fine if you do this, it will actually be quite screwed up. Thus, right before hitting “c”,
your contour should appear not quite closed, like below.
94
8. Remember that you need to add this contour to your group; otherwise, it is not saved.
Press “Add Contour To Current Group” in the “Create a Contour by Hand” window.
9. Continue to create contours by hand for every 5th contour in the right common and
external iliac until you get to the end of your path. Be sure to add each contour to the
group, and then click Commands->Group Controls->Save All Groups when you are
finished. In Exercise 2.2.4: Using Level Sets to Define a Contour you created segments
for the abdominal aorta, and in this section, you created segments for the right common
iliac and the right external iliac. Thus, you should now have something that looks similar
to the picture below.
95
10. You may have noticed that this technique is particularly handy at vessel branches,
because level-set and thresholding typically fails in this region.
96
Exercise 2.2.6: Fitting an Analytic Shape to the Image
If you want to create an analytic shape where no data exists, you may want to create an analytic
shape. Please remember that you will be using level-set and segmentation by hand followed by
“fit-circle” to create the final model. Thus, you do not need to save anything you create in this
exercise.
1. In the “Branch Controls” window, click on the “Analytic” button. The window shown below
should appear.
2. In the “Branch Controls” window, choose the path and position along the path for which you
want to generate a contour. For this example, set the “Current Path” to 100: aorta, and use
the slider bar to set the “Current Position” to the first position segmentation that you created
by hand in the last section.
3. You can choose the output format for the contour to be either a level set segmentation or a
threshold segmentation. In the “Create Analytic Contour Control” window, choose Level Set
under “Create Contour As.”
4. Circle: To make a circle, you will use the “Center” and “radius” fields under the “Circle
Parameters” section in the “Create Analytic Contour Control” window. You can change
these parameters and then press the “Make Circle” button to see the contour that is created.
Can you find a combination that produces a good segmentation for this image?
The “Center” determines the center of the circle. The X=0, Y=0 position for the center
corresponds to where the path intersects this imaging slice. Changes to X and Y and the
radius are in the same units as the imaging data. Most MRI data is in mm, so the units for this
dataset are in mm.
97
5. Ellipse: To make an ellipse, you will use the “Center” X and Y fields, and the “a” and “b”
fields under the “Ellipse Parameters” in the “Create Analytic Contour Control” window.
After you change the values for these fields, press the “Make Ellipse” button to generate the
contour.
As with the circles, the “Center” determines the center of the ellipse. The X=0, Y=0 position
for the center corresponds to where the path intersects this imaging slice. Changes to X and
Y are in the units of the image data, mm in this case.
“a” is the horizontal length of the ellipse, and “b” is the vertical length of the ellipse. These
quantities are in the same units as the imaging data, mm in this case. Unfortunately, you can
only generate ellipses along either the x- or y-axes at this point in time.
6. The “Scale by” and “Translate by” buttons under “Additional Options” will be discussed in
Exercise 2.2.8: Modifying Contours.
98
Exercise 2.2.7: Copying and Pasting Contours
Another option for creating contours is to copy and paste a contour from another location. This
allows you to extrude that shape and is useful, for instance, at the point where one vessel joins up
with another vessel.
This capability is provided in both the “Level Set Segmentation Control” window and the
“Threshold Segmentation Control” window. You can also copy and paste analytic contours and
contours generated by hand. You just need to know whether you saved the contour as a level set
or a threshold and use the appropriate window.
1. We’ll try this for the elliptical contour generated in Exercise 2.2.6: Fitting an Analytic Shape
to the Image for position 286. That contour was saved as a level set, so go to the “Branch
Controls” window and click on the “Level Set” button.
2. At the bottom of the “Level Set Segmentation Control” window, under “Additional Single
Slice Manipulations” you should see the “Copy” and the “Paste” buttons.
In the “Branch Controls” window, move the slider bar so the “Current Position” is 286. Then
go back to the “Level Set Segmentation Control” window and click on the “Copy” button.
You have just saved the contour for position 286 into memory.
99
3. Now to paste this contour to a new location, just move the slider bar in the “Branch Controls”
window to the new position. For this case, set the “Current Position” to 281. Then click on
the “Paste” button in the “Level Set Segmentation Control” window. The copied
segmentation will appear in the “2-D Reslice Intensity Window.”
100
4. Add this segmentation to your group by clicking the “Add Current Position to Group” button
in the “Level Set Segmentation Control” window. The segmentation will not show up in
your group until you do this!
101
Exercise 2.2.8: Modifying Contours
If you’re not satisfied with the segmented contour at a specific location, you can try scaling it or
moving it around (or just segment it again with different parameters). The functionality to make
these modifications can be found in the “Threshold Segmentation Control” window, the “Level
Set Segmentation Control” window, and the “Create Analytic Contour Control” window.
1. We’re just going to try out these functions for a level set contour. Click on the “Level Set”
button in the “Branch Controls” window.
2. Scaling: To make the contour larger or smaller, enter a scale factor into the field next to
“Scale by:” in the “Level Set Segmentation Control” window. Then click on the “Scale by”
button.
Scaling operates on the current contour. This means that if you apply a scale factor of 2 to
the original contour and then apply another scale factor of 2, you will end up with a contour
that is 4 times the size of the original contour, as shown below.
102
3. Translating: You can move the contour to a different location by specifying “dX” and/or
“dY” and then clicking on the “Translate by:” button. The units are the same as the imaging
data, mm in this case.
The values for “dX” and “dY” are incremental! This means that the movement occurs
relative to the current position. To see this, enter 5 in the field for “dX” in the “Level Set
Segmentation Control” window. Click on the “Translate by:” button and note where the
contour is. Click on the “Translate by:” button again and notice that the contour has shifted
another 5 units, so that total distance moved relative to the original position is 10 units.
Positive values for “dX” shift the contour to the right. Positive values for “dY” shift the
contour up.
4. Fit Circles: You may have notice that the segments you created by hand for the right
common and external iliac were a little rough. To remove some of this roughness, you could
Fourier smooth them, but you could also fit a circle to them, similar to what you did in
section 2.2.3 9b.
Go ahead and fit a circle to all the contours you made in section 2.2.5 in the right common
and external iliac. In Exercise 3.6: Construction and Naming Conventions, you will see that
you will be fitting circles to your data for all of the branch vessels (see this section for more
information). To fit a circle to the contours you already created, open up the “Level Set
Segmentation Control” window (because you created the contour as level-set). Because you
want to fit circles to all the contours in the right common and external iliac, you can fit
circles as a batch. First, you need to determine the first and last contour that lies in the right
common iliac and right external iliac. For the pathline generated for this demo, this is every
fifth segmentation starting at 135 and ending at 290, hence the command used would be 135-
290 by 5 in the “batch list” section of the “Level Set Segmentation Control” window. Next,
click the “Fit Circles” button.
103
When you made the contours, you drew them in the center of the potential donut.
Consequently, the fit circles should fall roughly in the center of the potential donut. Your
right common and external iliac should now look something like this.
5. If you wanted to add this modified contour to your current group, you would click on “Add
Current Position to Group” in the “Level Set Segmentation Control” window. But we don’t
want to save these modifications; we just want to use the original contour we had. So we can
just close this window by clicking on the “Close” button.
104
Section 2.3: Creating a Solid Model from 2-D Segmentations
In the previous section, it was shown how to create individual 2-D segmentations along a
particular vessel path. It is worthwhile to reinforce at this point the distinction between
visualizing geometry and utilizing geometry for numerical simulation. If you were to graphically
display all the segmentations that you created in the previous exercise, your mind may “connect
the dots” and create a 3-D mental image of the geometry. However, we need to create a 3-D
solid model that the computer can understand.
Fortunately for us, an ordered relationship between some of the curves is known. That is, for
each path we have an ordered set of curves defining the geometry for the given vessel. These
sets are the groups that we have used to organize the segmentations. All of the segmentations are
associated with one and only one vessel. This motivates a two-stage process to create a solid
model. First, a “lofted” solid is created for each branch. This results in a collection of solid
branches. Second, a boolean addition (union) is performed of the individual branches. The
result is then a single bounded solid region representing the blood flow domain.
In this section we will explore these two steps. In Exercise 2.3.1: Using Groups of
Segmentations to Create Solid Models, a single branch is lofted from a set of curves. In Exercise
2.3.2: Joining Vessels into One Solid Model, we will perform a boolean addition to create a
single solid model. Exercise 2.3.3: Blending Vessel Junctions shows you how to smooth out the
intersection between vessels.
105
Exercise 2.3.1: Using Groups of Segmentations to Create Solid Models
1. Let’s clean up our workspace a little. Close all windows except the “SimVascular 3-D
Graphics Window” and the “Volume Image Browser.” Turn off all visualization techniques
in the “SimVascular 3-D Graphics Window” so that all you see is the blue outline of a box.
2. The main window we will be using in this exercise is the “Group Re-Organizer” window,
shown below. Open this window by selecting Solid Modeling -> Group Control from the
“SimVascular Main Menu” window.
3. Exercise 2.2.1: Using Groups discusses how to load and save groups. In this exercise, we
will focus on using groups to construct acceptable solid models from the 2-D segmentations.
4. Types of Groups: You will be working with two different groups in this process. The
“input group” is the pool of all the 2-D segmentations that you might possibly want to use in
your solid model. You will be loading the input group on in the left-hand yellow box above.
When you make changes to your segmentation size, shape, or location you should always
make these changes to the input group. The second group is the “destination group” or
“working group” and is the list of 2-D segmentations that you decide need to be included in
constructing your solid model. You will be loading the “destination” or “working” group in
the right-hand yellow box above.
106
In this exercise, you will first construct a solid model for the aorta and right common and
external iliac from the segmentations you created in the previous section. To begin, click on
the “select” button next to the field for the “input group.” A new window, titled “Select a
Group,” will appear. In this new window, double-click on the group we’re interested in:
Aorta_Right_Common_External. In the “Group Re-Organizer” window,
Aorta_Right_Common_External will now appear under “input group” and a list of all the
slice locations that you added to the group will appear under “input group slices.” Your
windows should look something like windows shown below.
5. Now click once on 0 under “input group slices.” You will see a green contour appear in the
“SimVascular 3-D Graphics Window,” as shown below. This is the contour associated with
position 0 in the Aorta_Right_Common_External group.
107
6. Adding Segmentations to Your Working Group: To use one of the input group slices in
your solid model, double-click on that slice under the “input group slices” list. That slice
location will now appear under the “working group slices.”
Double-click on all of the slices in the “input” group. Notice that contours listed under the
“working group slices” are purple in the “SimVascular 3-D Graphics Window.”
Now click on the “Create Solid Vessel from Working Group” to see what a model created
from the slices in your working group would look like. You will get something like that
shown in red below. (To turn on the point cloud, see Exercise 1.3: Visualizing point
clouds.) This model is not acceptable. Can you tell why?
The green arrows show areas regions of the model that will create artificial geometries called
lofting artifacts. These are geometries that are created from the lofting process; these
geometries do not exist in real life. Lofting artifacts can be caused by different things; the
lofting artifacts shown are caused by including segmentations at branch points. It is important
to note that in the case of lofting artifacts, what is “correct”--a segmentation in the middle of
the potential donut for level-set, for example--in 2-D will not necessarily be “correct” in 3-D.
Note that you can also get “fold-like” lofting artifacts if you do not Fourier smooth your
segmentations enough. For more information about this type of lofting artifact, please see
Exercise 3.5: Determining which Segmentation Technique to Use.
108
The segmentation near the aortic bifurcation (slice 130 for this example) may not appear so
terrible. However, if you were to try to join Aorta_Right_Common_External with the left
common and external iliac, you will see that it will be nearly impossible to make a smooth
transition if you include this segmentation.
7. Removing Segmentations from Your Working Group: Next, you will remove the
segmentations that are causing lofting artifacts. To remove a slice location and its
corresponding segmentation from your working group, just double-click on the slice
locations you want to delete under the “working group slices” list. In this example, this is
slice 55, 65, and 130. It may be different in your vessel. You should see the numbers
disappear from the “working group slices.”
109
Slices 55
and 65 (and
slice 130,
not shown)
have been
removed.
Now, click “Refresh Vis Window” in the “Group Re-Organizer” window. You will see that
slices 55, 65, and 130 no longer appear as part of the model. To loft this new vessel, click
“Create Solid Vessel from Working Group.”
110
8. Changing the rendering resolution. Next, you will zoom in on the right external iliac and
check for lofting artifacts. Click on the model and click “p” to select the model. You might
see something like the picture below. Is this a lofting artifact?
111
The answer is no. The crease you see in the picture above result from the resolution of the
rendering. This can easily be fixed by changing the maximum facet size. Type set
gOptions(facet_max_edge_size) 1 in the tkcon window and pressing return (command shown
in picture below).
112
Next, click “Refresh Vis Window” and then “Create Solid Vessel from Working Group” in
the “Group Re-Organizer” window. Then, click on the model and click “p” to select the
model. You should see a much smoother vessel, similar to the model shown below.
11. Fixing Segmentations that Cause Lofting Artifacts Now that you have an acceptable
maximum facet size, take a close look at the model. You should have taken care of the more
113
obvious lofting artifacts. However, there may be a few less obvious problems. Zoom in on
the abdominal aorta. Near slice 50 (in this example), you may see an unnatural looking lump
(see green arrow below). If you pull up the intensity and potential window, you will see that
this segmentation is not very circular. This is because we segmented near a branch point.
Next, you will draw on the skills you learned in Exercise 2.8: Modifying Contours by
going back to the “Branch Controls” window and replacing this segmentation with one
that will not cause a lofting artifact.
First, make sure that “Branch Controls” slider is on the slice that is causing the lofting
artifact. For this example, it is slice 50. Also, make sure that
Aorta_Right_Common_External is showing in the “current group” in the “Branch
Controls” window. If a different group is showing, then your new segmentation will be
added to wrong group!
Now, draw a segmentation by hand that excludes the part of the vessel that is starting to
form a branch. This requires a little bit of artistry. Then, Fourier smooth the hand-made
contour down to 5 modes. You might end up with something like this.
114
Next, you need to add this segmentation to the group Aorta_Right_Common_External.
To do this, click “Add current Position to Group” in the “Level Set Segmentation
Control” window. Next from the “Branch Controls” window, click on Commands-
>Group Controls->Save all Groups.
If you then return to the “Group Controls” window, and click “Refresh Vis Window” you
will see that the old segmentation is still in place. This is because SimVascular does not
automatically update segmentations. To update the segmentation, you must re-select the
group Aorta_Right_Common_External in the “input group:” window from the “Group
Re-Organizer” window. Next, move the new slice 50 over to the working group by
double-clicking on “50” in the yellow “input group slices” window.
Next, click “Refresh Vis Window” and then “Create Solid Vessel from Working Group”
in the “Group Re-Organizer” window. You should get something that looks like this.
115
This looks much better than before. If you rotate the model, you may notice a similar
“lump” near slice 70 (shown below). Repeat the same slice-replacement process to
eliminate this lump. You may also choose to replace slices 55 and 65 with more circular
segmentations.
116
12. Creating a Destination Group. By now you have done quite bit of work on the vessel
defined by the aorta and right common and external iliac, and you would probably like to
save these changes by creating a destination group before you move on to the next steps.
To do this, enter a name for the destination group. Because this will eventually be the
final group of segmentations we want to use, type Aorta_Right_Common_External_Final
in the field for “destination group.” Then, click on the button “Update/Create Output
Group” in the “Group Re-Organizer” window.
You can see that a new group called Aorta_Right_Common_External_Final has been
created by clicking on the “select” button next to “destination group.” (There is also a
tmp-group-reorganizer group listed. This is associated with the working group and will
not be available for use later in the process.) Click on the “DONE” button in the “Select
a Group” window to close this window.
In the “Group Re-Organizer” window, click on the “Create Solid Vessel from Destination
Group” to create a solid model based on this new destination group that you’ve created.
117
Helpful Hint: A Shortcut for Adding Slices to Your Working Group. There are so
many slices in the input group that it would be tedious to add the slices to your working
group one at a time. A quicker way to do this is to select the right iliac as your
destination group, which will automatically load all the locations in the right iliac group
into your working group list. To make your initial destination group, just append the
group name with _final and click then “save.”
12. Deciding Where to Start the Model. You may notice that the entire aorta has a
curvature to it. While the aorta has some curvature to it, the curvature you see is mostly
due to the acquisition of the image data. For this project, you only need to include the
abdominal aorta to a few centimeters above the celiac artery. Turn on the point cloud
again in your volume image browser. Rotate the data and vessel so that you see
something like this.
The celiac artery is shown with the green arrow (shown below). You want to start our model
a few centimeters above this point. The segmentation shown with the purple arrow would be
an appropriate place to start the model. For this example, this corresponds with segmentation
45.
118
Start model here
Celiac
Why did you bother to add segmentations all the way to the top of the image data? This is
because it is much, much easier to create too many segmentations and then remove them than
to try to add on additional segmentations later. Imagine for a moment your path started at the
location of the purple arrow. This would then correspond with segmentation 0, rather than
45. Now imagine that after you have built your model, you or your advisor decide that it is
important to start your model much higher, to create more fully-developed flow, for instance.
Now you are stuck: Because the segmentations are lofted in numerical order, if you wanted
to add additional segmentations above the purpose arrow, these segmentations would have to
have a number less than zero. This means that the segmentation numbers above the purple
arrow would have to negative! (Note: There are ways of getting around the problem of a path
that is too short. They will not be addressed in this tutorial, but feel free to ask me about
them.)
Go ahead and remove the segmentations above segmentation 45 from your “destination
group.” Your new model might look something like this.
119
It is important to note that your initial and final segmentations should be as perpendicular to
the vessel as possible. An explanation as to why this is important is addressed in Exercise
3.3: Perpendicular Outlets. If this segmentation is not perpendicular, you may need to 1)
translate the segmentation or 2) modify your path so that a more perpendicular segmentation
is possible. Checking for perpendicular outlets should, in general, be the last
Click “Update/Create Output Group” and then “Save” in the “Group Re-Organizer” window
to update and save the changes you have made thus far.
13. Visualizing the Vessel Without the Segmentations. Sometimes it is easier to see lofting
artifacts if you do not see the individual segmentations. Before we do this, clear out the
“SIMVASCULAR 3-D Graphics Window” by clicking on Actor->Delete All Actors from
the “3-D Graphics Window.” All the segmentations should disappear and you should be left
with only the point cloud. From the “SIMVASCULAR Main Menu” click on Solid-
Modeling->Create Pre-Op Model. A window like this should appear.
120
We want to create a pre-op (pre-operative) solid model using our final destination group, in
this case, Aorta_Right_Common_External_Final. Move
Aorta_Right_Common_External_Final to “Groups Used to Create Preop Model” by single-
clicking on Aorta_Right_Common_External_Final in the “Available Groups.”
Note, if you have recently updated the group, be sure to click on the “refresh group list”
before you move Aorta_Right_Common_External_Final to “Groups Used to Create Preop
Model.”
Next, click on “Create Pre-Op Solid Model,” then “View Model” in the Create/Alter Branch
List. The vessel defining the aorta and right common and external iliac should appear.
14. Next, zoom in on the right external iliac. You may find that the external iliac looks lumpy.
121
Lumpy
This is because the segmentations in this region are close together and not quite the same
size. You can fix this lumpiness in one of two ways. You can either 1) remove segmentations
or 2) you can copy and paste a single contour for a given branch vessel. I recommend relying
most heavily on the 2nd option, with the following caveat: This is really only appropriate in
the branch vessels, which are relatively far from the region of interest. The 2nd option is
justifiable because shear stress autoregulation theory says that vessels will adjust their size to
maintain relatively constant levels of shear stress. Thus, as long the flow remains constant
along a given small segment of vessel, the vessel should remain about the same diameter for
the given small segment. The exception, of course, is if the branch vessels have disease such
as atherosclerosis or aneurysm. The vessel below was created by replying mostly on method
2, and a little bit of method 1. Segmentation 195 was copied and pasted for slice location 200
through 245. Please note that the x and y coordinates had to be adjusted so that the pasted
circle lay as close as possible to the potential donut. Since the resultant vessel still looked a
little lumpy, two contours were removed.
122
Method 1 illustrates the importance of having both and input
(Aorta_Right_External_Common) and destination (Aorta_Right_External_Common_Final)
group. You should always add new segmentations to your input group and then move them to
the destination group. This separation allows you to insert and remove segmentations from
your destination group easily without permanently deleting the segmentation. For example,
you might remove segmentation 215 from your output group, loft the vessel, and then decide
that the lofted vessel looked better with segmentation 215. You can easily put it back in
because segmentation 215 is still contained in your input group.
123
Exercise 2.3.2: Joining Vessels Together to Create a Model
To create a model of the human abdominal aorta, the aorta and its branch vessels will need to be
unioned together. For specific instructions on which branch vessels to include for the Human
AAA project, please see Exercise 3.1: Determining Which Branch Vessels to Include. For the
purposes of this tutorial, we will focus on adding the left common and external iliac to the
Aorta_Right_Common_External vessel that you just created. As you will see in section 3.6:
Construction and Naming Conventions, please name the left common and external iliac
Left_Common_External
Please go ahead and follow the instructions in sections 1 and 2 to create the left common and
external iliac. As with all the branch vessels, please draw the segmentations by hand, and then
use “fit-circle.” In general, you should construct your model in this manner, i.e., one branch
at a time. Thus, you should make a path for a vessel, then make the segmentations for that
vessel, and loft that vessel. When you are done, repeat this cycle with every branch vessel
until you are done with the model. You should always start with the aorta and right common
and external iliac, since the majority of the branch vessels will branch of this vessel. This method
is preferable because it allows you to choose paths and segmentations that join nicely together.
In addition, please start the path for the right external and common iliac a little ways up into the
aorta. You will see why we do this in the remainder of this exercise. Thus, when you are
finished, you might have something that looks like this.
124
When you are finished, you should have four groups, Aorta_Right_Common_External,
Aorta_Right_Common_External_Final, Left_Common_External, Left_Common_External_Final.
The next step will be to join Aorta_Right_Common_External_Final and
Left_Common_External_Final together.
1. Next you will see what will happen if you join Aorta_Right_Common_External_Final and
Left_Common_External_Final. From the “SimVascular Main Menu,” select Solid Modeling
-> Create Pre-Op Model. The “Create/Alter Branch List” window will appear, as shown
below. All the groups that you’ve created are listed under “Available Groups.” You will go
through the same process of lofting the groups that you performed in the previous section,
only this time there will be two vessels.
Creating model: To add a group from this list to the list of groups actually used in creating
the final preop model, single-click on the entry under “Available Groups.”
Helpful Hint: What if you are missing a group: If the group that you want to use is not listed
under “Available Groups,” click on the green “refresh group list” button. You may also want
to make sure you actually created the group
If you wanted to remove a group from the “Groups Used to Create Preop Model” list, you
would just click on that group name under “Groups Used To Create Preop Model.”
Now that you have listed the groups to use in creating your final preop model, click on the
button “Create Pre-Op Solid Model.” A dialog box may appear, asking if you want to create
the missing solids using defaults. If so, just click “Yes.” These missing solids will be
125
created using the number of sample points you have specified in the “Group Re-Organizer”
window. There will be no indication that the operation is done. Because we want to view
the model without the segmentations, click on Actor->Delete All Actors from the
SimVascular 3-D Graphics Window. And then click “View Model” in the “Create/Alter
Branch List” menu. You might see something like this.
From far away, this may look like a good model. However, there is something sinister occurring
at the junction of the right and left common iliac arteries. Take a look at the “Meshing Attribute
Viewer.” It should look something like this.
126
The “Meshing Attribute Viewer” tells you the ID numbers of the faces you have created. You
should one face (the wall) for each vessel, plus an outlet for each vessel, plus the model input.
Thus, for most models you should have 2*(number of vessels)+1 faces=5 faces. For the example
model, there are seven, not the five faces!
You can take a closer look by clicking on a particular “face ID”; the corresponding face name
will appear in the “surf name.” You will see that the walls are labeled wall_<name_of_group>,
for example, wall_Aorta_Right_Common_External_Final. The outlets do not have any prefix.
Thus for the outlet (and inlet) of the vessel defined by the aorta and right common and external
iliac, you will see Aorta_Right_Common_External_Final. For this example, there are two faces
names Left_Common_External_Final and two outlets named Left_Common_External_Final,
when we were expecting one of each!
Next, you will try to locate the extra wall and outlet by changing the colors of the faces. From
the “Meshing Attribute Viewer” click select the first wall_Left_Common_External_Final and
then click “Change Color.” Choose something other than red. Repeat for the second
wall_Left_Common_External_Final and for the two outlets labeled
Left_Common_External_Final. Now rotate the model and zoom in on the junction of the right
and left common iliac. You may see something like this.
127
This is the extra Left_Common_External wall! We need to get rid of this. Having a “false wall”
like this will create a region of artificially high shear stress when you run the blood flow
simulation on this model.
The extra outlet may be harder to find. If you zoom in really close, you should see it as an extra
“lip,” (shown in green) like this.
128
Including this extra “lip” will ruin the simulation. Since no boundary condition will be applied to
this outlet, all the flow will leak out here.
Thus, you need to get rid of both the extra outlet and the extra wall. Before you move on, please
zoom out so that we can address a more subtle point.
129
Right now, the intersection between the aorta and two common iliac arteries is not very
symmetric, and there is an artificial “lump,’ marked with the green arrow. In the next step,
you will get rid of the extra wall and outlet, as well as try to make this intersection more
smooth.
5. Okay, now that you know your goals, you can try to fix them. The best method to get rid of
the extra wall and outlet is to scale the contours that lay inside of the aorta to 80-95% their
original size. To begin this process, go to the “SimVascular” main menu and click on Solid-
Modeling->Create Vessel. Next, go to Commands->Group Control->Select Current Group.
Choose the input group Left_Common_External. Next, pull up the intensity and potential
windows. If the segmentations are no longer there, go to Commands->Restore Group. Now
click on Commands->Create Contours Menus->Level Set. Now move the slider bar in the
“Branch Controls” window to the initial segmentations in the group Left_Common_External.
Select the segmentations that lie inside the aorta and then shrink them to 90% using the
“Scale by” button on the “Level-Set Segmenation Control” window. When you are done, be
sure to click “Add All in List to Group” and then Commands->Group Controls->Save All
Groups form the “Branch Controls” window. Next, move on to the “Group Reorganizer” to
add your new segmentations to your output group, Left_Common_External_Final. Loft the
new vessel along with the Aorta_Right_Common_External_Final. Did you get rid of the
130
extra outlet and wall? Does the resulting model look smooth? If not, repeat the above
process.
Note: To get rid of the lump, you may need to translate, scale, or delete or even add
segmentations to the Left_Common_External_Final and Aorta_Right_Common_External
groups. Translation, scaling, and adding can be done in the “Level-Set Segmentation
Control” window. Deleting segmentations can be done from the “Group Re-organizer”
window. You may end up with something like this.
Notice that there are five faces in the “Meshing Attribute Viewer,” as expected. Hurray!
5. Saving your model. To save this solid that you’ve just created, enter a name for the file in
the field next to “Save Model” in the “Create/Alter Branch List.” For this example, enter
my_model.xmt_txt in the field. Then, click on the “Save Model” button.
131
Exercise 2.3.3: Blending the Junction of Two Vessels
If you zoom in on the intersection of the aorta and right and left common iliac arteries, you may
see that there is a fairly sharp transition between the aorta and the left common iliac. Luckily,
SimVascular provides you with a handy tool to blend the intersection of any two branches. This
exercise will show you how to this.
1. From the “SimVascular Main Menu” click on Solid Modeling->Create Blended Model. The
menu that will pop up is shown below.
2. First, using the browse button, select the solid model .xmt_txt file that you just created, then
click “Load” and “View.” Since you have not blended the model yet, you don’t yet have a
blends file or a blended solid model, so you can leaves these as is.
3. Next you need to specify the two faces you will be blending. You want to blend the
wall_Aorta_Right_Common_External_Final and wall_Left_Common_External_Final. You
will be looking for the indentifier ID (NOT the face ID) associated with these walls. You can
figure out the identifier ID in one of two ways. First, you can click on the Face ID associated
with wall_Aorta_Right_Common_External_Final and wall_Left_Common_External_Final in
the “Meshing Attribute Viewer.” The number in red is the idenfier ID.
132
If you do not feel like clicking through all of the face IDs until you find the IDs you want,
you can find the Identifier ID in a different way. You can click on the face you want in the
“SimVascular 3D Graphics Window” and hit the “p” key at the same time. This selects the
face you are clicking on. The corresponding ID will show up in the “Meshing Attribute
Viewer.” For this example, the Identifier IDs for
wall_Aorta_Right_Common_External_Final and wall_Left_Common_External_Final are 13
and 60, respectively. They may be different for your model.
4. Now that we know the IDs of the walls we want to blend together, you need to specify the
last parameter. Blending can be thought of as a process in which a ball of a specified radius
rolls around the intersection of two vessels. If the intersection of the vessel is perpendicular,
then the blending will be approximately even around the junction. However, if the vessel
intersection is at some angle smaller than 90 degrees, as is the case with the example model,
then more blending will occur in the region that forms the smallest angle. Perhaps it is best to
see this in action. To blend the model, you need to enter the following parameters into the
‘Create/Modify Meshing Script File” window: <ID of first face> <ID of second face>
<radius of blending ball>. Thus, for the model example shown below, 13 60 2 was entered
in the “Meshing Attribute Viewer.”
133
Next, click “Blend Model” and then “View.” You should get something like this (note that the
color of the blended region has been changed to make it more visible).
134
5. This blending radius looks appropriate for aorta and left and right common iliacs. Picking
which radius to use is a little bit on an art. Picking a radius that is two big will either fail to
blend the model at all, or will create unnatural looking “webbing” between two vessels.
Picking a radius that is too small will fail to fulfill the goal of the blending—to make a
transition that is smooth between vessels.
6. If you are not satisfied with the blend you just made, simply click on Actor->Delete All
Actors from the “SimVascular 3-D Graphics Window”, change the radius of your blending
ball, and then click “Blend Model” and “View Model” from the “Create/Modify Meshing
Script File.” Once you are satisfied with the blends type what you would like to call the
blended model (I suggest <patien_number>blnd, for example patient_16blnd for real
datasets) under “Blended Solid Model” in the “Create/Modify Meshing Script File,” and then
click ‘Save.”
You are now done with the model-building the demo data. Congratulations! The next
section will give you specific instructions for the AAA project. Please note that sections 1
and 2 only guided you through building and blending the aorta and the right and left
common and external iliac arteries. For real AAA datasets, you will be expected to build
and blend the intersections of the aorta in addition to seven to eight branch vessels.
135
SECTION 3: ROBUST MODEL-BUILDING AND
INSTRUCTIONS FOR THE AAA PROJECT
Now that you have learned all the techniques for segmentation and lofting, it is time to put it all
together. Model-building is part art and part science, and it is something that requires practice.
Therefore, don’t be surprised if you have to rebuild your model (or part of you model) multiple
times. Each time you build a model, the model-building process will become faster and easier. I
have had to rebuild many of my models!
Because we want to be able to collect statistical information from the AAA models, it is
important that different model-builders build each model in pretty much the same way. In
addition, it is important to build a model that is compatible with blood flow simulation: We want
the blood flow simulation to complete multiple cardiac cycles without “blowing up” (having a
humongous error).
This section gives general guidelines for building an AAA model that is both consistent and
robust. Of course there will always be exceptions, but try to follow these guidelines as best as
you can. If in doubt, don’t hesitate to ask me (Andrea) if you have a question about a particular
dataset, model, branch, or even an individual segmentation.
First, let’s get familiar with the anatomy of the abdominal aorta and its branch vessels using an
AAA model that I built (figure 1). I consider this a “successful” model, because I was able to
simulate blood flow through this model under rest and exercise conditions without having the
simulation blow-up.
136
Figure 1: The abdominal aorta (with aneurysm) and its branch vessels
137
Section 3.1: Determining Right and Left
Looking at the model above, ‘right’ and ‘left’ refer to the scan subject’s point of view, not the
model-builder’s point of view. If you were to superimpose the scan subject onto the model
above, you would be staring approximately at their belly-button. Thus, the left renal artery is the
renal artery on the scan subject’s left side. Try positioning yourself so that your blood vessels
match those in the model above (minus the aneurysm part). You should find yourself turning in
your chair 180 degrees, so that your back is facing the computer screen. This leads us to
instruction 1.
Instruction 1:
When creating groups (and thus labeling the blood vessels you are modeling), label ‘right’
and ‘left’ according to the scan subject’s right and left side.
Instruction 2a:
When the splenic, hepatic, and superior mesenteric arteries branch off of a common celiac
trunk, you should include all three in your model. Thus, in this case, your model should
include the following vessels (the same as the model shown in figure 1):
1. The splenic artery
2. The hepatic artery
3. The superior mesenteric artery (SMA)
4. The left and right renal arteries
5. The left and right external iliac arteries
6. The left and right internal iliac arteries
Usually, the celiac and the SMA branch off the aorta, like in the model shown below (figure 2).
138
Figure 2: An abdominal aorta (with aneurysm) with more typical branch vessels
In this case, in general, you do not need to include the splenic and hepatic arteries (which branch
off the celiac artery). This brings us to instruction 2b.
Instruction 2b:
If the celiac and the SMA branch off of the aorta, you do not (in general) need to include
the splenic and hepatic arteries. Thus, your model should include the following vessels (the
same as the model shown in figure 2):
1. The celiac artery
2. The superior mesenteric artery (SMA)
3. The left and right renal arteries
4. The left and right external iliac arteries
5. The left and right internal iliac arteries
139
Section 3.3: Perpendicular Outlets
Okay, let’s go back to the first model, which is the model with the large aneurysm that ran
successfully on the first try. What made this model successful, when others failed?
When we run a simulation, the Navier-Stokes equations--the equations of motion for a fluid--are
being solved. The code that solves these equations imposes a constant pressure across the outlets.
Since the pressure is more likely to be constant at any given perpendicular cross section, it is
important that the model outlets (and the inlet) are as perpendicular to the vessel wall as possible.
Though it might be hard to see from this view, all the outlets are pretty perpendicular in this
model (figure 3).
140
Figure 4: A close-up of the left renal artery. Notice that the outlet is very perpendicular to the
vessel wall.
I put a copy of this model, Patient10blnd.xmt_txt, in Z:\Tutorial_Files. You can look at this
model in SimVascular without having any of the image data, paths, or groups. Simply open up
SimVascular, then go to “Meshing” from the SimVascular Main Menu, then browse to the solid
model file from the “Create/Modify Meshing Script File” window. Next, click “Load” and then
“View”. The model should appear in an SimVascular 3-D graphics window.
Notice that the outlets appear perpendicular (or close to it) regardless of how you rotate the
model. (The model is labeled to show that it belongs to patient 10, and that is blended, hence the
“blnd” part.) This leads us to instruction 3.
Instruction 3:
The outlets and the inlet should be as perpendicular to the vessel as possible. In order to
accomplish this goal, you will probably need to make your path very straight (even if this is
not what the vessel does) near the end of the vessel.
141
Section 3.4: Where to End a Branch Vessel: Avoiding Tortuosity
and Bifurcations
What else made this model successful? You may notice that the some of the vessels are quite
tortuous (curvy), but near the outlets they are quite straight. Why is this? When constructing a
model, it is important to avoid geometry that might lead to complex flow patterns near the
outlets. Because pressure and flow are coupled, complex flow at outlets may lead to non-constant
pressure across the outlets, which may cause the simulation to blow up.
Tortuous geometry and vessel bifurcations are common causes of complex flow patterns. Thus,
to avoid complex flow patterns near the outlet please 1) make sure that the end of each branch
vessel is relatively straight, and 2) make sure that the vessel doesn’t end too near any
bifurcations.
The best way to avoid these causes of complex flow is too choose the end of your vessels wisely.
Let’s take a closer look at the right external and internal iliac arteries (figure 5). The black lines
in the picture below both represent poor places to truncate the right internal iliac. Can you tell
why? Both line A and B are very perpendicular to the outlet, which is good. However, choice A
is too close to the iliac bifurcation. Choice B is far enough away from the iliac bifurcation, but it
is too close to the bend in the internal iliac. For these reasons, I chose to build the right internal
iliac so that the vessel ended in a straight section of the vessel, far away from the iliac
bifurcation.
Figure 5: The lines A and B represent poor places to truncate the model
142
Sometimes, however, it is impossible to find a section of a vessel that is both straight and not
near a bifurcation. In these cases, it is okay to artificially extend the vessel by adding a few
centimeters to the vessels. This usually means that you will have to make your path deviate from
the vessel itself for a few centimeters. This is what I had to do for the left external iliac (figure
6). There was no good place to end the left external iliac because the only straight section of the
vessel was too near the iliac bifurcation. So, I artificially extended the external iliac by adding a
few centimeters of straight vessel to the external iliac.
Figure 6: The outlet for the left external iliac has been artificially extended to make the vessel
straight near the outlet
Instruction 4:
Construct the branch vessels so that 1) the vessels are relatively straight near the outlets
and 2) the outlets are several centimeters away from any bifurcations.
143
Section 3.5: Which Segmentation Technique to Use
In section 2, you were presented with many different segmentation techniques. Because we are
primarily interested in the blood flow in the abdominal aorta, it is important to capture this
geometry while also avoiding lofting artifacts. Some of the geometries you encounter may be
very complicated, such as in the model shown in figure 7.
Therefore, please use a level set technique to model the geometry in the abdominal aorta.
Because we would like to also avoid lofting artifacts, please Fourier smooth these segmentations
down to five modes. Check to make sure that the level-set lies in the center of the donut of the
potential window, as demonstrated in figure 8.
144
Figure 8: The level-set segmentation is in the center of the potential “donut.”
If the level-set is not in the center of the donut, you may need to scale the segmentation.
We are less interested in the flow in the branch vessels. Because using a level-set technique in
these very tortuous vessel would likely lead to lofting artifacts, please fit circles in the branch
vessels. To avoid lumpiness, you may even need to cut and paste the same circle. Remember that
these vessels are under pressure, so a circle is not an unreasonable assumption, especially when
the resolution of the branch vessels may only be a few pixels across. The exception to this rule is
if there are mini-aneurysms or atherosclerotic lesions in the branch vessels. If you see this, please
come talk to me.
Note that you can get “fold-like” lofting artifacts if you do not Fourier smooth your
segmentations enough. Below is an example of a model created with insufficient Fourier
smoothing. Can you see the “fold-like” artifacts?
145
This leads us to instruction 5.
Instruction 5:
In the abdominal aorta, please use a level-set segmentation technique to model the
geometry. Also, Fourier smooth these level-set segmentations down to five modes. Check to
see that each segmentation is in the center of the potential donut.
In the branch vessels, please use a fit-circle segmentation technique to model the geometry.
To avoid lumpiness, you may even need to cut and paste the same circle for any given
branch vessel. Check to see that the fit-circle lies approximately in the center of potential
donut.
146
Note that you can also get “fold-like” lofting artifacts if you do not Fourier smooth your
segmentations enough. Below is an example of a model created with insufficient Fourier
smoothing. Can you see the “fold-like” artifacts?
147
Section 3.6: Construction and Naming Conventions
Because many people will be building models for this project, it would be helpful if every
model-builder used the same construction and naming conventions. Here are some guidelines.
1. The aorta, right common iliac, and right external iliac should be constructed as one vessel
(figure 9).
2. The left common and external iliacs should be constructed as one vessel (figure 9).
Figure 9: The aorta, the right common, and right external iliac should be constructed as one
vessel. Likewise, the left common and left external iliac should be constructed from as one
vessel.
6. Lastly, when labeling your final group that defines each vessel, please use the naming
convention shown in figure 10 (I show this on a different model, since this person had
more conventional anatomy). Notice that there are no spaces in any of the names.
148
Figure 10: Please use the naming conventions shown above when constructed your model
Instruction 6:
The aorta, right common iliac, and right external iliac arteries should be constructed as one
vessel. The left common and left external iliac should be constructed as one vessel. Lastly,
please use the naming convention shown above for your final group names.
149
SECTION 4: GENERATING VOLUMETRIC FLOW
WAVEFORMS FROM PC-MRI DATA
Phase contrast MRI (PC-MRI) image can be processed in SimVascular to create a volumetric
waveform. These waveforms will eventually be used to assign boundary conditions to the model
you just created. The following exercises will lead you through the process.
Exercise 4.1.1: Loading and Viewing PC-MRI Data describes how to load the PC-MRI data.
The next step is to process the PC-MRI data. You need to identify what pixels are inside of the
vessel. You can do this either through segmentation algorithms or by selecting individual pixels
(see Exercise 4.1.2: Segmenting PC-MRI Data). The third step in the process is to compute and
apply an error correction equation, also referred to as a baseline correction equation. This is
explained in Exercise: 4.1.3: Applying Baseline Correction to PC-MRI Data. The fourth exercise
describes how to compute flows (see Exercise 4.1.4: Computing Volumetric Flow Rates). The
firh exercise shows you how to obtain the heart-rate from the header of PC-MRI data (see
Exercise 4.1.5: Getting the Heartrate from the Phase Contrast Data). The sixth and seventh
exercises show you how to import the volumetric flows into excel and then fourier filter them in
MATLAB, respectively (see Exercise 4.1.6: Importing and Graphing the Volumetric Flows in
Excel and Exercise 4.1.7: Fourier Filtering the Volumetric Flow in MATLAB).
Please note that the demo phase contrast dataset is 3-component (velocities in the x, y, and z-
direction). However, in this tutorial, and in general, you will only be concerned with calculating
the z-direction velocities.
The output of this section is an excel flow file with time in one column and 1) volumetric flow 2)
volumetric flow with a linear baseline correction, and 3) volumetric flow with a linear baseline
correction and fourier filter applied in the 2nd, 3rd, and 4th column, respectively. All the
volumetric flows should be in cc/s.
150
Exercise 4.1.1: Loading and Viewing PC-MRI Data
1. Loading Data: Load in the PC-MRI data you want to process by selecting File-> Load
Image Data from the “SimVascular Main Menu.” The window shown below will appear.
Click on the “Browse” button under the “Phase Contrast MR Image Data” section. The
following dialog window will appear. Choose the directory image_data/005 and click the
“OK” button. The fields for the “Directory” and the “x” and “y” minimum and maximum
values will be filled in using header information from your PC-MRI data.
Click on the “Load PCMRI Data” button in the “Load Image Data” window.
2. Viewing Data: Let’s see what the image looks like. Select Boundary Conditions -> Process
PCMRI Data from the “SimVascular Main Menu.” The window titled “PCMRI Controls”
will appear.
151
In the “PCMRI Controls” window, select Commands -> Display Windows -> Intensity
Window. You will see an image similar to that shown below.
If you wanted to see the associated potential image (potential is the magnitude of the gradient
of the image), you would select Commands -> Display Windows -> Potential Window from
the “PCMRI Controls” window. This may be useful when you are segmenting the images.
Let’s close these windows. Just select Commands -> Display Windows -> Intensity Window
and Commands -> Display Windows -> Potential Window from the “PCMRI Controls”
window.
4. Loading a Subset of the Data: When you loaded in this data, the maximum values for “x”
and “y” were 255, and the minimum values were 0. You can see this in the “Load Image
Data” window. These default values cause the entire image to be loaded in. If you know that
you are only going to process a small portion of the image, you can load in a subset of the
image. This will shorten the amount of time needed for image processing and segmentation.
We are only interested in the aorta, which is the bright area in the center of the image. So
change the minimum for “x” and “y” to 100. Set the maximum for “x” and “y” to 150. Click
the “Load PCMRI Data” button again.
Now follow the instructions in Step 3 to view this data. Do you get something like that
shown below?
152
1. Close the “Load Image Data” window by clicking on the “CANCEL” button in that
window.
2. After you load the PCMRI image data, you may want to adjust the contrast in the
PCMRI intensity and potential windows by going to Display Options->Show All
Options and then setting the “Display Image Min” and “Display Image Max” to
values that enable you to see the aorta and surrounding tissue better.
i. Min 50, Max 200 often works for the intensity window
ii. Min 0, Max 50 often works for the potential window.
You can also adjust the contrast by using the up/down keys, but this only changes the
contrast for the timestep displayed.
153
Exercise 4.1.2: Segmenting PC-MRI Data
Many of the same concepts used to segment imaging data when constructing geometric models
are applicable to segmenting PC-MRI data for boundary conditions. We will be using the ideas
of groups introduced in Exercise 2.2.1: Using Groups. The same four options described in
Section 2.2: Segmentation are available for segmenting PC-MRI images: thresholding, level
sets, analytic techniques, manual methods. In this exercise, we describe how to access these
methods when working with PC-MRI data.
1. Groups: From the “PCMRI Controls” window, select Commands -> Group Controls. The
following seven options are available: Select Current Group, New Group, Restore Group,
Delete Group, Clear All Segs, Load All Groups, Save All Groups.
Creating a new group: Recall that groups are used to organize segmentations. We want to
create a new group to save the segmentations from the PC-MRI data. First, specify the name
of the new group. pcmri-segs is the default name of the group in “current bc group” in the
“PCMRI Controls” window.
Selecting a previously created group: You can see what groups have been created by
selecting Commands -> Group Controls -> Select Current Group. Since you haven’t created
any groups yet, no groups will appear:
However, if you are working on processing phase contrast data, but need to close
SimVascular and reopen it later, you may use this command to select the group you were
working on.
Deleting a group: To delete a group, make sure that the group you want to delete is listed as
the “current bc group.” Then from the “PCMRI Controls” window, click on Commands ->
Group Controls -> Delete Group.
154
Restoring a group: To restore a group (after closing SimVascular and reopening for example,
or after switching groups), make sure that the group is loaded first (see “Load all groups”
below), then click on Commands->Restore Group. If the appropriate segmentation type is
clicked on in the intensity or potential window (see below), the contours should appear for
the group you restored in the intensity or potential window.
Clear all segs: If you want to remove all the segmentations that you have added to a group,
select Commands -> Group Controls -> Clear All Segs from the “PCMRI Controls” window.
Load all groups: If you wanted to load in saved groups from a file, you would enter the
appropriate directory name for the “bc group dir” and then select Commands -> Group
Controls -> Load All Groups.
Save all groups: To save your groups in a file, enter a directory name under “bc group dir”
and then select Commands -> Group Controls -> Save All Groups. We’ll do this once we’ve
added some segmentations to our group.
2. Segmentations: To generate the segmentations, also called contours, select Commands ->
Create Contour Menus -> Level Set from the “PCMRI Controls” window. The “Level Set
Segmentation Control” window, just like the one used in Exercise 2.2.4: Using Level Sets to
Define a Contour, will appear. The details of the different parameters are discussed in that
exercise.
For this exercise, we will use the default parameters. Make sure “batch list” in the “Level
Set Segmentation Control” window is set to begin-end, so that the level set segmentation is
applied to all time points. Click on the “Batch Segmentation” button in this window.
155
A dialog window will appear asking if you want to attempt 16 segmentations. Click “Yes.”
Another dialog window will appear asking if you really want to do the segmentation. Again,
you will click “Yes.”
You should see a list of text scrolling through the “tkcon” window, similar to that shown
below.
When the text stops scrolling in this window, the process is complete. Let’s view the
segmentations. Go to the “PCMRI Intensity Window” and select Display Options -> Level
Set -> segmentation. You will see a blue line like in the figure below. This is the level set
segmentation.
You can move the slider bar for the “Current Frame” in the “PCMRI Controls” window up
and down to view the segmentation for the different time points. Next, add these
segmentations to your current group by clicking the “Add All in List to Group” button in the
“Level Set Segmentation Control” window.
156
This demo dataset is very clean, so the level set technique will not fail. However, many times
real data is not so clean. If the level-set technique fails, then you will need to create the
segmentations by hand or by thresholding. See Section 2.2 for a review of these techniques.
The next question is: Are these segmentations acceptable? For phase contrast data, it is
important that we include all the pixels with flow and exclude the pixels without flow.
Fortunately, there is an easy way to tell if the pixels have flow. The next section will show
you how.
3. Modifying segmentations to ensure that they contain all the desired pixels.
Let’s go back to the level set segmentations we just generated. Scroll back to the
segmentation associated with timepoint 1. If you click on a pixel in the middle of the vessel
lumen to select the pixel, then click on the same pixel while holding down the “z” key, you
will see a graph of the flow in that pixel for each timepoint in the intensity window. The z
key means that we are looking for velocities in the z, or through-plane direction. Let’s do this
for a pixel in the center of the lumen. You should get something like this:
Helpful Hint: If the graph does not show up, click on Display Options->Views->Parallel
projection from the “PCMRI Intensity Window,” and then zoom in and out of the window to
activate it. This should fix the problem.
157
However, if you click on a pixel indicated below, which is outside of the segmentation, you
may get something that looks very similar:
Clearly you would want to include this pixel in your segmentation. If you go to a pixel
nearby, you find something like this:
158
C
Clearly, this is not a pixel we would want to include. Thus, how should we modify the
segmentation to include pixels like A and B, but not C? You could create the contour by
hand, but the easiest thing to do is probably scale the current level-set contour so that the
contour encompasses a slightly larger area. If you go to the level set segmentation control
window, you can scale and translate the contour using the buttons indicated. Go ahead and
scale the contour by 1.07.
159
You will see that the newer contour does a better job of including pixels with flow and
excluding the pixels without flow.
You will need to repeat this process of checking a few pixels on the other segmentations,
then save all your segmentations. When you are done, click the “CLOSE” button in the
“Level Set Segmentation Control” window.
160
Exercise 4.1.3: Applying Baseline Corrections to PC-MRI Data
Baseline correction is needed when eddy currents exist in the MR system, such that the MR
sequence measures non-zero velocities in regions that actually are not moving (they should have
a zero velocity).
The window that you will use to apply the baseline correction to the PC-MRI data is the
“Calculate Baseline Correction” shown below. You can access this window by selecting
Commands -> Baseline Correction Menu from the PCMRI Controls window. The “PCMRI
Intensity Window” and the “PCMRI Potential Window” will also appear, if they were not
already showing.
1. Create a region to use in the baseline correction calculation: First, you need to create
polygons to indicate regions that should have zero velocities. Ideally, you are selecting areas
that are spatially close to the region(s) where you want to compute the flow. Those areas
should also have relatively low intensities and surround as much of the flow region as
possible.
To create a polygon, click on the “PCMRI Intensity Window.” Move the cursor to the first
point of the polygon and press “a” on the keyboard to add this point to your polygon. Move
the cursor to the second point of the polygon and press “a” again. Continue doing this until
you have outlined the region of zero velocity. Then press “c” on the keyboard and the region
will appear in green, as shown below. This is exactly the same process used to draw a
contour manually, as described in Exercise 2.2.5: Segmenting an Image by Hand. When you
161
create the region, a label will also appear in the yellow area of the “Calculate Baseline
Correction” window.
Can you create a region similar to that shown below? Note that the region below excludes
the vena cava (which would not have zero velocity) and other nearby vessels:
If you make a mistake and need to remove a point, press “SHIFT-a.” That deletes the last
point you created in the contour. To remove a region completely, click on the region name
in the yellow listbox of the “Calculate Baseline Correction” window, and then click on the
“Delete Region” button in that window.
2. Indicate what regions to use in computing the baseline for a particular direction: You
have to decide whether a region will be used for correcting velocities in the x, y, and/or z
directions. For now, always do a correction in the z direction only. Highlight the region
name in the yellow listbox area by left-clicking on it. Then click on the appropriate on the Z’
button under the section “Perform Actions on Selected Region” in the “Calculate Baseline
Correction” window.
162
We only have three region and we want to use it for correcting the click on “region_1{}” in
the list and then click on the Z’ button under “Perform Actions on Selected Region.” Repeat
for the other other regions. The “Calculate Baseline Correction” window will appear as
shown below.
3. Compute the correction equation for a specific direction: First, you will choose whether
you want to compute the baseline correction equation for the X’, Y’, or Z’ direction. For
now, we are only interested in a baseline correction in the z-direction. Thus, click on “ Z’ ”
under the “Calculate Velocity Correction Equation” section of the “Calculate Baseline
Correction” window. Then you can choose whether you want an equation to be zeroth order
(constant), first order (linear), or second order (quadratic) by clicking on the corresponding
button. An equation for that particular direction will appear in the field underneath the
buttons. For this study, we will be using a linear baseline correction equation, thus click on
“Linear.” Then click on “linear” to produce a first-order correction equation. Do you get an
equation similar to that shown below?
163
What happens when you try to compute a constant correction equation in the x-direction?
Do you get the error message shown below? Why did that happen?
Answer: The region only is set to calculate baseline correction in the z-direction. If you
wanted to obtain a baseline correction in the x-direction, you would need to add the “ X’ ”
direction to the list of regions, then recalculate the x-direction equation.
4. Loading/Saving Baseline Correction Equations and Regions: To save the equation and
region information, enter a directory name in the field under “Load/Save Regions &
Equations.” The default is “baseline_regions.” We’ll go ahead and use the default directory
name. Then click on the “Save” button.
If you wanted to load this information in later, you would enter the directory name in the
field for “Directory Name” and then click on the “Load” button.
5. Now you have computed a baseline correction equation for the z-direction. This information
will automatically be used when you compute flows, like you do in the next exercise,
Exercise 4.1.4: Computing Volumetric Flow Rates. If you change your mind and decide you
don’t want to use any baseline correction, you need to clear the fields for “Equation Z.” (You
can just use the backspace or delete keys to do this.)
164
Exercise 4.1.4: Computing Volumetric Flow Rates
The end goal is to convert the PC-MRI data into a volumetric flow file.
1. Once you have a segmentation for every timepoint and the baseline correction as described
above, you can calculate the volumetric flow. The easier way to do this is to go to
Commands->Calculate Volumetric Flows->Batch. Since you have a segmentation for every
timepoint, you can calculate the flow for each timepoint in a batch. (If you want to
investigate the flow at just one timepoint, choose Commands->Calculate Volumetric Flows-
>Current Frame. In this case, whatever slice is being displayed currently will be the frame
where the volumetric flow is calculated.)
You will notice that as this happens, the flows are written out in the tkcon window like this:
2. Since will eventually be importing this into excel, we would like a less messy version of this
output. To get this clean version of the output, go to the SimVascular main menu and click
on Boundary Conditions->Write Output. A menu like this pop up.
165
Under filename, choose a name that accurately describes the flow, for instance,
005_with_baseline. Then, click “WRITE FLOW RESULTS.” This creates a .flow data file
that can easily be imported into excel.
3. You want to make sure that the baseline correction you applied is reasonable. To do this, you
need to compare the volumetric flow with baseline correction (which you just computed)
with the volumetric flow without baseline correction. To get rid of the baseline correction, go
back to the baseline correction window and manually erase the linear correction. Thus, your
“Baseline Correction” menu should look something like this.
166
4. Now repeat steps 1 and 2. Be sure to name the .flow file something different, like
005_no_baseline.flow. We now have two .flow files we can look at in excel.
167
Exercise 4.1.5: Getting the Heartrate from the Phase Contrast Data
1. There is just one last step to do in SimVascular. Go to the cygwin window from where
you originally started SimVascular. Scroll up until you get to something that looks like
this:
This window is from when you loaded in the phase contrast data. Notice that one of the
parameters is the heart rate in beats per minute (red arrow). Record this number in your
notes. You will be using it in the next step.
168
Exercise 4.1.6: Importing and Graphing the Volumetric Flows in Excel
1. Now we are ready to graph the two volumetric flows in excel. To do this, open up excel
and click on file->open. An “Open” window will pop up. The .flow files will not be listed
because excel does not recognize the .flow files an excel-type file. Thus, you may see
something like this.
To import the .flow files you just made, change “files of type” to “All files.” Now, the .flow
files that you made will appear in the browser window:
169
Select the first one, 005_no_baseline.flow. A Text Import Wizard window will pop up that
looks like this.
2. Next you need to define the delineations between columns. Since the columns are
separated by a fixed width, choose “Fixed width.”
170
3. Step 2 of the Text Import Wizard will appear.
Notice that the columns are now separated from each other, and the appropriate label is
above each column. Go ahead and click “next.”
171
This steps allows you to specify the data format of the columns. For .flow files, leave this as
“General” and click the click “Finish.” The .flow file will now appear in an excel spreadsheet
neatly separated by columns.
5. Repeat steps 1-4 for the 005_baseline. Copy the data from both 005_baseline into the excel
spreadsheet with 005_baseline and save the entire file as 005_Flows in excel workbook
format. You should have something like this:
6. For now, we are interested in the Flow (ml/min) column. Convert the flows from ml/min to
cc/s by dividing the ml/min column by 60. Graph the flow with baseline correction and the
flow without baseline correction (on the y axis) versus frame number (on the x-axis). In
addition, compute the average flows (with and without baseline correction) in both cc/s and
L/min. You should end up with something like this.
172
For the demo data, the baseline correction didn’t change the flows very much. This is okay.
Sometimes the baseline correction will change the flows by as much as 20%. Before you go
onto the next step, please show this graph to me. We will decide together the best flow
waveform to use for the next step.
173
Exercise 4.1.7: Fourier Filtering the Volumetric Flow in MATLAB
In this next exercise, we will go through the process of Fourier filtering in MATLAB. Fourier
theory says that any periodic function can be decomposed into a series of sine and cosine waves
of different frequencies using Fourier series (see http://en.wikipedia.org/wiki/Fourier_series for
more information). MR images are acquired in the Fourier (frequency) domain, but an MR
scanner cannot acquire an infinite number of frequencies. The number of modes that the scanner
can acquire is limited by the temporal resolution of the scanner, which in turn, is determined by a
parameter called the TR and the heart rate of the subject. Thus, this next step filters the flow
waveform down to the true number of Fourier modes.
2. In general, you will find that the 3-component data will be filtered, and the 1-component will
not (you will get a message saying that you don’t need to filter it in this case).
i. Create a flow.dat file that consists of one column with the flow values. Put this file in the
same folder as Fourier_Filter.m
ii. Open MATLAB, and then click file->open->M-file to open Fourier_Filter.m. Run the
program.
iii. You will be prompted to enter the TR. For these scans, the TR is typically 12 ms, so you
can use that for now.
iv. Next, you will be prompted to enter the heart rate. Good think you looked this up in
Exercise 4.3.5!
v. Next, you will be prompted to enter a “2” if the data is 1-component or a “4” if the data is
3-component. This, combined with the TR, enables the program to calculate the true
temporal resolution. If no Fourier filtering is need, you will get the message: “The true
temporal resolution is less than the reconstructed temporal resolution. Thus, no Fourier
filtering is needed.”
Explanation: If, for example, the true temporal resolution is 24 ms, then the scanner is
capable of capturing data that has a period of 24 seconds or longer. If the reconstructed
data shows a temporal resolution of 40 ms, then no interpolation was needed, and thus no
Fourier filtering is needed. If, however, the true temporal resolution was 48 ms, but the
data shows a temporal resolution of 40 ms, then some interpolation occurred, and Fourier
filtering is needed.
If Fourier filtering is needed, then the program will proceed and spit out a new filtered
waveform, “Filtered_Flow,” which will be saved in the same directory as
174
Fourier_Filter.m and your waveform. In addition, MATLAB will produce a plot of the
original and fourier filtered flow, similar to below. Please note that the plot shown is for a
dataset different from the demo dataset.
Import Filtered_Flow into Excel. Graph three waveforms for each dataset: 1) original
flow (no baseline correction), 2) the flow with linear baseline correction, and 3) the flow
with linear baseline correction and fourier filtering. For all flows, convert the flows from
ml/min to cc/s by dividing by 60 if the data is not already in cc/s. Also, compute the mean
flow for each waveform in L/min. You should end up something that is similar in
structure to the chart shown below. Please note that the plot shown is for a dataset
different from the demo dataset.
175
This is your final output for processing phase contrast data.
176
GLOSSARY
B-spline curve What’s a good definition for this??
Binary
segmentation A process by which image pixels are either included in or excluded from the
region of interest.
177
GLOSSARY: UNIX COMMANDS
Files
• ls --- lists your files
ls -l --- lists your files in 'long format', which contains lots of useful information, e.g. the
exact size of the file, who owns the file and who has the right to look at it, and when it
was last modified.
ls -a --- lists all files, including the ones whose filenames begin in a dot, which you do
not always want to see.
There are many more options, for example to list files by size, by date, recursively etc.
• emacs filename --- is an editor that lets you create and edit a file.
• mv filename1 filename2 --- moves a file (i.e. gives it a different name, or moves it into a
different directory)
o Example: If Sally is a file and Bob is a folder, typing “mv Sally Bob” will move
Sally into the Bob folder. Typing “mv Sally Sue” will rename the file Sally to a
file named Sue.
• cp filename1 filename2 --- copies a file
• rm filename --- removes a file. It is wise to use the option rm -i, which will ask you for
confirmation before actually deleting anything. You can make this your default by
making an alias in your .cshrc file.
• diff filename1 filename2 --- compares files, and shows where they differ
Directories
Directories, like folders on a Macintosh, are used to group files together in a hierarchical
structure.
178
REFERENCES
An excellent overview of phase contrast MRI:
1. Joachim Lotz, Christian Meier, Andreas Leppert, Michael Galanski “Cardiovascular
Flow Measurement with Phase Contrast MR Imaging: Basic Facts and Implementation”
Radiographics 2002: 22:651-671
Ghosting
2. Photocopies from book, section entitled “Appearance of Motion Induced Artifacts”
179