Professional Documents
Culture Documents
© 2006-07 P. Schimpf 3
Biomedical Applications
Cardiology
– optimal electrode design to minimize burning from edge
effects
– implanted defibrillation: where should the electrodes be
placed to optimize efficacy?
– diagnosis: are there regions on the heart that are not
generating a neural signal (infarct)?
Neurology
– what neural regions are involved in performing task X?
– locating the foci of seizure activity
– detecting silent seizures
– brain to computer interfacing
Impedance Imaging
– visualizing changes in electrical impedance, which
correlates to tissue structure
© 2006-07 P. Schimpf 4
Volume Conduction
Both artificial and biologic sources introduce
current into the tissue
– in most biomedical applications, inductive and capacitive effects
are negligible, and the conduction is purely resistive
– voltage and current are thus governed by the Poisson equation:
V (1)
– in two dimensions, with isotropic conductivity, this expands to:
2V 2V
2 2 ( 2)
x y
– V, σ, and are all functions of position (x,y)
– V is voltage (V), σ is conductivity (Siemens/m), and ρ represents
current source density (A/m2 in two dimensions)
© 2006-07 P. Schimpf 5
The Finite Element Method
Ni x, y a1 a2 x a3 y ( 4)
© 2006-07 P. Schimpf 6
The Finite Element Method
The end result of using linear basis functions is
a faceted approximation to the true solution
– the approx. improves as the elements are made smaller
– we should use small elements where the voltage is rapidly
changing
– an adaptive mesh solver shrinks the elements in such
regions automatically
V (1)
2V 2V 2V
2 2 2 ( 2)
x y z
– V, σ, and are now functions of (x,y,z), and represents volume
current source density (A/m3)
– note that equation (1) remains unchanged, which is one of the
advantages of the Divergence () and Gradient () operators
© 2006-07 P. Schimpf 8
Moving to 3D
Note that our linear basis in 2D had 3 degrees
of freedom (DOFs)
– DOFs are the parameters that fit the linear basis functions
to the voltage (a1, a2, a3)
– the number of DOFs for a linear basis is the same as the
number of vertices (or nodes) of the simplest element shape
(a triangle in 2D)
Ni x, y, z a1 a2 x a3 y a4 z ( 4)
© 2006-07 P. Schimpf 9
Image Based Elements
When modeling a biological domain, it is
convenient to define elements as collections of
medical image pixels
– pixels are classified according to tissue type, and each
tissue type is assumed to have a particular conductivity
– in 3D, we use a set of images, and pixels become voxels
– the pixels are usually square, but the space between images
is often not the same as the pixel size, thus our elements
will be brick-shaped (rectangular parallelipiped)
– such elements have 8 nodes, and thus 8 DOFs:
Ni x, y, z a1 a2 x a3 y a4 z a5 xy a6 yz a7 xz a8 xyz ( 4)
– this is more DOFs than a linear basis, but not enough to
provide a full quadratic basis (Can you determine what the
missing quadratic terms are? Can you see the cubic term?)
– it is thus called a super-linear element
© 2006-07 P. Schimpf 10
Image Based Elements
pixels/voxels in the medical images are classified
according to tissue type, and each tissue type is
assumed to have a particular conductivity
element boundaries are defined as collections of voxels
Typical FE programs draw the mesh as a wire-frame of
the elements. In this case it is convenient to just color
the groups of pixels that comprise an element, and
ensure that neighboring elements use different colors.
Ka f (7 )
– the details of this transformation are beyond our scope
© 2006-07 P. Schimpf 12
Forward Modeling
– Define a head model from classified medical images (provided)
– Simulate the electroencephalogram (EEG) for 3 different source
configurations:
1) a single dipolar source in the prefrontal cortex
2) a single dipolar source in the cingulate cortex
3) both of the above sources simultaneously
– Verify the 3rd solution is the sum of the first two
– We'll cover the simulation of the first source configuration here -
the other two are similar
– Suggested directory AnyDi
structure:
HeEx
adMo
eEx
rci
e
d
*.cls
exe sin rci
ima ege
xe so .ma
rci lu
tutoeria
xe l.rs
rci
(you nta
eegpts.sl
fro may also find it l
lf.ma convenient to put a copy of
cingul
t
roi.ma
bo plotsamples.m
th.tx t in all 3
plo co
tsadirectories)
mpa mp
© 2006-07 P. Schimpf 13
Define the Domain
Use a text editor to view the file image.map
– this is a list of the correspondence between image files and z coordinates
– note that it specifies model images in a subdirectory called HeadModel
Run GalerWin and select Edit /
Domain Definition
– press the Import button, browse to
your tutorial directory, and select the
file image.map
– notice that the image dimensions (128
x 128) are deduced from the file size
You must define the dimensions
of the pixels in whatever units you
prefer to work with
– let's work with meters
– the pixel dimensions in these images
are 2 mm x 2 mm and the spacing
between images is 3.2 mm
– enter the appropriate values (in
meters) and press the OK button
© 2006-07 P. Schimpf 14
Define the Domain
You should now see a grayscale
rendering of the first slice
– each pixel is a byte code representing a
particular tissue type, and the solver
defaults to simply interpreting that byte
value as a gray scale – we'll change that
shortly
– these images are pretty small, so select
View / Zoom 400%
– select View / Current Z Slice, enter 25, and
press OK
– move the mouse around in the window
and notice the updates of the voxel
coordinates and tissue class number in
the status bar
select File / Save
– and save this project as Exercise1to3 \ Exercise1.gal
– you can now load that file to continue your work at a later time
– the .gal project files save the definitions of the problem, but not solutions
© 2006-07 P. Schimpf 15
Editing Material Properties
Select Edit / Material Properties
– this is where we assign a conductivity
and a color to each tissue class
– try selecting some material numbers –
you'll see that the assigned material color
defaults to grayscale
– the conductivity is in the units you
choose, but should be consistent with the
other units – we'll use Siemens / m
– use a text editor to view the file tutorial.rst
– for historical reasons, the import and
export of conductivities uses the inverse,
which is resistivity, with units (in this
case) of -m
– press Import and select the file tutorial.rst
– you should now see some conductivities and tissue descriptions in the
window, but the colors are still grayscale
– to edit a tissue description, double-click the tissue in the scroll window
– we'll assign some colors to these tissues next
© 2006-07 P. Schimpf 16
Editing Material Properties
Select tissue #90, Scalp, and move the color scrollbars to
give it the color black. Color the EEG electrodes (#91)
red, the Reference electrode (#94) green, and cortex
voxels (#93) magenta.
feel free to color other
tissues as well, but this
is purely for visual
asthetics and does not
effect the model solution
(see next slide for more
tissue colors used here)
press the Close button
you should now see
a colored image of
the domain
select File / Save
© 2006-07 P. Schimpf 17
Suggested Tissue Colors
tissue # name Color Red Green Blue
40 blood red 255 0 0
45 hard bone gray 128 128 128
50 soft bone light gray 196 196 196
55 gray matter lavender 204 128 204
60 white matter olive 196 228 128
65 cerebellum brown 196 128 64
70 CSF cyan 0 204 204
75 eye lt lavender 228 196 196
80 fat yellow 255 228 112
85 muscle blue 32 32 180
93 cortex magenta 255 0 255
95 soft tissue lt green 128 204 128
209 air white 255 255 255
© 2006-07 P. Schimpf 18
Material Properties
Some things to note:
– "eeg electrodes" have been given their own tissue number
(91) so that they can be viewed on the image
• this also makes it convenient to sample the field solution at
those points, but it is not necessary to define a tissue class
at sample points
• note that their conductivity is the same as "scalp" (90)
– one particular electrode has class 94 "reference electrode"
• we'll define a 0 voltage boundary condition here later
• again, this is not necessary, but it makes the reference
electrode easy to see in the image set
– a subset of the gray matter voxels (#55) have been
classified as "cortex" (#93), which you've colored magenta
• note that the conductivities are the same
• these "cortex" voxels mark possible source sites when we
discuss inverse problems later on
© 2006-07 P. Schimpf 19
Defining Boundary Conditions
Boundary Conditions (BCs) come in two types:
– Fixed or Dirichlet: represent fixed voltages at any site in the domain
• used to simulate voltage sources or reference points
• in this case, we need only specify a 0 voltage at the location of the
reference electrode
• note that these can be internal, even though they are called "boundary
conditions" – fixing the voltage at internal points in the domain
essentially removes that region from the model, creating an internal
boundary
– Natural, or Neumann: specify values for the normal component of
current density at boundary points (A/m2 in 3D)
• they are satisfied only approximately in the eventual solution
• Neumann BCs are rare in this application (we'll have none), except that
any boundary point that has NO boundary condition explicitly specified
automatically gets a 0 normal current boundary condition. This says
that current does not escape from the modeled domain.
• with some pre-calculation, non-zero Natural BCs take the same form
as Fixed BCs – with this S/W that is the only way to enter them
© 2006-07 P. Schimpf 20
Defining Boundary Conditions
On slice 25, right-click the green pixel and select Set
Boundary Conditions
– Fixed BCs are actually applied at nodes of the mesh, and nodes
occur at the vertices of elements
– Because you've selected a voxel, the pop-up allows you to enter
BCs at any of the vertices of that voxel. The terminology asks that
you think of your screen view as looking down onto the top of the
modeled object (this may be disorienting, but calling the first image
"top" instead of "left" makes sense with axial medical images,
which are more common for
modeling than the saggital
images used here)
– One BC would be sufficient to
establish a voltage reference,
but since the entire voxel
represents our knowledge of
the location of the reference
point, check all the vertices
© 2006-07 P. Schimpf 21
Defining Boundary Conditions
Press OK and select Edit / Boundary Conditions
– this screen lists all fixed boundary conditions
– it also allows you to specify fixed boundary conditions in two
other ways:
• Over a range of coordinates, in which case the boundary
condition is applied to all nodes falling within the box defined by
those two coordinates
• Over a material class, in
which case the boundary
conditions is applied to all
nodes falling on a voxel of
the specified class
– note that we could have
specified these 8 reference
BCs on this screen using
the coordinate range:
(116, 60, 25) to (117, 61, 26)
– or using Material class 94
© 2006-07 P. Schimpf 22
Specifying Current Sources
right-click on a cortex
voxel (class 93) in the
frontal cortex and select
Set Sources
© 2006-07 P. Schimpf 23
Specifying Current Sources
This pop-up is similar to the pop-up for boundary
conditions
– you can specify a total current for each node
– specify 625 uA at each of the "top" nodes, and -625 uA at each of
the "bottom" nodes
– this simulates a dipolar source centered in the voxel, oriented in
the z direction (ear to ear), with a moment of 8 uA-m
– this is 2.5 mA total for each
side, times a 3.2 mm separation
(the voxel size in the z
dimension)
Optional Exercise
1a1 3a2 19 a1* 19 3a2
– try this method for this
rearrangement of the 3a1 1a2 25 a2* 25 3a1
same problem:
© 2006-07 P. Schimpf 29
Iterative Solvers
This control allows the user to
choose from two iterative
solver algorithms
– Many FE programs wouldn't allow
such choices. They were included
here because this code was developed for research work.
– Select "Both" and leave the other parameters at defaults
SOR = Successive Over-relaxation
– this algorithm is similar to the relaxation approach in the
preceding example, with some refinements
– updates are used as soon as available (i.e. a2* in the
preceding example would use a1* instead of a1)
– the RHS calculations are multiplied by a “relaxation factor”
to speed convergence
JCG = Jacobi Conjugate Gradient
– this is an advanced iterative algorithm that is beyond the
scope of this tutorial
© 2006-07 P. Schimpf 30
Solving
Select Action / Solve
– a pop-up window shows status of the solution in progress,
including the number of elements & nodes in the mesh
Press Dismiss and select View / Field Solution
– look at the solution on z slices 15-35
– notice how the energy of the sources
"piles up" at the skull boundary
© 2006-07 P. Schimpf 31
Looking at the Mesh
© 2006-07 P. Schimpf 32
Forcing a Uniform Mesh
Select Edit / Adaptation Controls
– In order to test the principle of superposition, we'll now solve
two more problems: a different dipole source followed by both
dipole sources
– we'll then compare the solution
for both to the sum of the
individual solutions
– the comparison will come out
best if we ensure the mesh for
all three problems is the same
– the easiest way to do this is to
force a uniform mesh of single
voxel elements
– modify the adaptation controls
as shown here:
– Elements from size 1 downto 1
– Exact match of border on
– Repeat at most 0 times
© 2006-07 P. Schimpf 33
Solve Again
Select Action / Solve
Press Dismiss and select View / Field Solution
– look at the solution on z slices 15-35
– notice the sharper resolution of energy piling up against
both the skull and other local
tissues (looking at slice 34 here)
© 2006-07 P. Schimpf 34
Extracting EEG Samples
Select Edit / Solution Points
– press Import and select the file
eegpts.sln
– we could also enter the class for
EEG electrodes (91) in the box
titled "Solutions for a specific
material class"
– eegpts.sln defines the same
samples in the order we'll need
for inverse work later on
© 2006-07 P. Schimpf 36
Exercises 2 and 3
© 2006-07 P. Schimpf 38
Exercise 3
?
= +
© 2006-07 P. Schimpf 42
A Simple Inverse Algorithm
One solution to Problem 2 is to assume that there
are fewer sources than measurements
– i.e., many of the entries in the s vector will be zero
– this leads to a useful solution in many applications
The simplest extreme – assume 1 source
– iterate through each triplet of columns in the lead-field, find the
best fit of those 3 columns to the EEG measurement, which gives
the best fitting orientation of that particular source site, and
calculate the residual
– the column triplet giving the smallest residual represents the best
fitting single source
– at each iteration, we now have an overdetermined problem to
solve, because there are 3 columns (the 3 ordinal orientations of a
particular source) and m rows (the number of EEG measurements)
– we shouldn't expect to find an exact solution (residual=0), unless
there truly is only a single source, on our grid spacing, the model
is perfect, and there is no noise present
© 2006-07 P. Schimpf 43
Overdetermined Pseudoinverse
The least squares strategy is to minimize the
norm of the residual:
Li si v Li si v
2 T
Ri 2
siT LTi Li si 2 siT LTi v vT v
2 LTi Li si 2 LTi v 0
2
Ri
s 2
LTi Li si LTi v
si Li Li Li v
T 1 T
© 2006-07 P. Schimpf 49