Macintosh EKG/EEG Hardware and Software Project
Contents
- Introduction
- Important disclaimer
- Electronic hardware
- Basic data acquisition software
- EKG pages
- EEG pages
- Future work
Introduction
I am currently working on a project to create simple, low-cost,
portable, hardware and software for biophysical data acquisition and
analysis on the Macintosh. My specific application involves EKG and EEG
signals, although the system could be used for input and analysis of
other generic electrical signals. The project consists of the creation
of external data acquisition electronics, and of data acquisition and
analysis software using a concurrently developed component software system .

(Click for larger image)
Initially, the goal of the project is to create a portable 2-channel
real-time system using discrete electrodes. Next, the hardware and
software will be extended to provide multi-channel EKG input from a grid
of sensors attached over the chest, and EEG input from a 3d electrode
cap worn over the head.

(Click for larger image)
This multi-channel input will then be linked to 3d EEG analysis and
animation software. A prototype of this
software has already been developed. This software currently provides
3d interpolation and animation of time series and spectral EEG data,
showing the time- and space-varying electrical field of the brain.
Similar software will take its input from a grid of EKG sensors in order
to show the time- and space-varying electrical field of the heart.

(Click for additional images)
The overall goal of this project is:
- To create a very low-cost, portable, easy to use, EKG and EEG data
acquisition and analysis system specifically for the Macintosh.
- To use this system to produce 3d animations of the time- and
space-varying electrical fields and their spectra, of the brain and the
heart, both as a post-processing step and in real-time.
Important disclaimer
The equipment and techniques discussed at this website are not for "medical"
purposes. I make no claim whatsoever about any possible benefits to be derived
from this equipment, these analyses, nor from EKG/EEG research and analysis in
general. I am not a doctor, and am therefore not qualified to judge this work in
any legal way. These examples are simply a demonstration of the kind of
low-level biophysical signal which can be acquired by the hardware and filtered
by the software.
The hardware designs, schematics, and discussions presented at this website are
all theoretical, and should be considered as "works of fiction" for
"entertainment purposes" only. They are not meant to be used to create actual
working EKG/EEG hardware. Furthermore, under no circumstances should they be
used to create hardware that will be used on a human subject.
Electronic hardware
- Power supply.
- An EKG amplifier and filter.
- An EEG amplifier and filter.
- Measuring the frequency response of the electronics.
Currently completed EKG/EEG data acquisition electronics consist of several
external prototype amplifier/filter systems, each powered by a 9V battery. All
amps use the same DC power supply layout. Note that the external electronics of
a discrete data acquisition system must be low-pass
filtered in order to reduce aliasing (as the discretization makes it inevitable).
All amplifiers consist of one or more instrument amplifier chips, either passive
or active low-pass filtering, and optional active notch filtering to reduce AC
noise.
These amplifiers are used in AC-coupled mode (meaning a capacitor is used in
series with the signal between stages to prevent pegging at the supply rails),
with a frequency response down to about 1-2 Hz. Each amplifier is built in terms
of functional units (e.g. supply, input, filters, output), and is designed as
stages capable of gains from 2-1000, depending on the feedback resistors used.
Target amplification is from a uV or mV input range to about 1.5 V peak-to-peak output. The
output of an amplifier is connected to one channel of the stereo sound input jack
of the Macintosh, using the internal ADC chips to perform analog to digital
conversion.
Photos, schematics, and test results are provided for all amplifiers. One should
find the "rat's nest" construction of the electronics fairly amusing,
although this does not affect their operation.
Basic data acquisition software
- Data acquisition on the Macintosh.
- The Discrete Fourier Transform (I).
- Data windowing.
- "Ideal" low-pass filtering.
- The Z transform and Discrete Fourier transform (II).
- A simple digital oscilloscope application.
The data acquisition and analysis software is in component form, and consists of
a component management "shell" program and a set of dynamically linked
components. Some components which have been written specifically for this
project include data acquisition (DAQ) over the Mac sound port (using
the Mac internal ADCs), the DFT and inverse DFT, complex operations and
functions, convolution and deconvolution, and display of complex data using 1, 2,
and 3 dimensions.
EKG pages
- Acquiring 12-lead EKG data.
- Extracting and averaging multiple EKG waveforms.
- Lowpass filtering and smoothing of EKG waveforms.
- 2d plots of V1-V6 leads.
- Surface and image plots of waveform variations in V1-V6 leads.
- Acquiring a grid of 25 EKG signals.
- Creating an animation of the grid (includes 2 small QuickTime movies of the
animated grid).
- Computing magnitude and phase spectra of the grid.
- High resolution line spectra of the V(3,3) signal.
- Computing multiple spectrum records from a signal.
- Bipolar signal synthesis and visualization of the cardiac axis.
- High resolution line spectra of the 5x5 EKG grid.
- Measuring the magnitude and phase of the line spectra.
- Reconstruction of the EKG signal from a finite set of
line spectra (i.e. as a finite Fourier series).
- A new 2d frequency/phase spectrum of an EKG signal, showing the interaction of
two dynamic systems.
- A new 2d feature spectrum of an EKG signal, showing several distinct components.
- Magnitude/phase spectra of 7 independent EKG features.
- Mathematical modeling of EKG feature spectra, and synthesis of the EKG signal
as the interaction of multiple bandpass filters.
I have initially concentrated on EKG data acquisition and processing, since it is
a necessary precursor to EEG data acquisition, and it is also a worthwhile
achievement in itself. I have built an amplifier and lowpass filter tailored
specifically to EKG, and have used this amplifier to acquire EKG data using the
12 standard "leads", or electrode configurations.
My software work has also concentrated on making the component software system
more useful for acquiring and processing of EKG data. New components and changes
to existing components allow for easy and rapid acquisition, filtering, and
storage of the 12 (or more) different electrode configurations in real-time
during a single session, and the perusal, extraction, and additional filtering of
this data as a post-processing step which can be performed at leisure.
Some of the additional analysis examples I have constructed include the
extraction of single waveforms from epoched datasets, and Fourier filtering to
compensate for the magnitude and phase characteristics of the external
electronics when necessary. Multiple waveforms from a single lead are extracted
and averaged point-by-point over time, and waveforms acquired from different
leads are cross-plotted in 2d. Continuous changes in waveform shape with respect
to electrode placement are also compared and plotted as a 3d surface.
In addition to using the 12 standard leads, I have performed a simple experiment
and analysis in which I acquired a 5x5 grid of precordial EKG signals from the
chest leads alone. These signals were then averaged, synchronized, and combined
to show a low-resolution view of the whole electrical field of the chest as a
surface or image which can be animated over time. This can be done even though
the individual signals comprising this field are not acquired simultaneously. In
this experiment, I am interested in looking at variations in EKG signal shape and
spectrum, and zero locations in the Laplace transform, with respect to electrode
position. Although the first grid was very rough, this experiment does show the
potential for future study using a grid of higher resolution.
Next, a high-resolution spectrum was performed on each of the waveforms in the
5x5 grid, all of which show discrete lines. Then, the magnitudes and phases of
these line spectra are sampled in order to perform a finite Fourier series
reconstruction of one of the signals, and to show that this reconstruction
converges very slowly. Then a new kind of 2d frequency/phase spectrum, of which
the 1d Fourier transform is a subset, is performed. This new analysis suggests
that the EKG signal is the result of two different interacting dynamic systems,
each with its own visual signature and underlying characteristics. A varient of
this new analysis identifies distinct features in the EKG signal, each of which
has its own magnitude and phase spectrum independently of other features. This
suggests that an EKG signal is the result of the impulse responses of multiple
independent bandpass filters operating simultaneously. A reconstruction of the
EKG signal using simple mathematical functions fitted to these feature spectra
agrees considerably with the actual signal, and converges much faster than the
Fourier series.
EEG pages
- Acquiring simple bipolar and unipolar EEG signals.
- Spectral analyses using data windowing and combined EEG records.
- Extraction and measurement of alpha band EEG signals from unipolar occipital data.
- Application of the 2d frequency/phase and frequency/delay spectra to EEG signals.
- Initial EEG feature extraction, spectra, and synthesis.
For the above examples, I have built a new EEG amplfier and electrodes, and have
made some simple preliminary bipolar and unipolar scalp measurements. I have
been able to directly see some standard waveforms (such as alpha, spike-waves, and wickets), and
have performed some simple spectral analyses of these signals. I have also been
able to filter signals so as to extract and measure the alpha band components and
their strength relative to the overall signal. Although this is fairly basic EEG
work, it does show that the hardware and software are working correctly (as is
the wetware), and paves the way for more ambitious measurements and analyses,
such as frequency, phase, and correlation surveys of the entire head.
Finally, frequency/phase analyses such as those applied in the EKG examples
above, are applied to the EEG signals in order to observe and extract features
from these datasets as well. The next step is to use this information to model
the EEG signal in a manner similar to that used for EKG.
Future work
Here is a short list of some additional experiments I would like to perform and enhancements I would like to make to the hardware
and software:
EKG
- A second real-time EKG channel. Add another amplifier and lowpass filter to the existing
electronics in order to simultaneously acquire 2 channels (leads) of EKG. This will make it possible to
create 2d plots of different leads (e.g. V1-V6, V(1,1)-V(5,5)) in real time without the need to manually extract and
synchronize waveforms acquired at different times. This will also make it possible to accurately synchronize
all signals acquired from a grid, and to see timing differences in the waveforms.
- A higher resolution 2d grid of precordial electrode positions and EKG signals. The current grid is only
5x5 (25 signals) with a spacing of 3 inches between electrode positions. A smaller, finer, grid of more
coordinate positions is needed to get better resolution of the electrical activity centered primarily over the
heart. The next grid should probably also be moved slightly up and to the right.
- Reduction of 2d EKG signals to a set of unifying equations. Using the derived system functions of EKG signals
distributed in a 2d grid, combine and reduce the corresponding dynamic equations (e.g. difference equations) in order
to find a minimal, single set of equations which will accurately generate the shape of an EKG signal at any location in the grid.
EEG
- EEG frequency survey of the entire head. Using a single unipolar channel, perform EEG acquisition and
frequency analysis at a set of points distributed evenly across the head in spherical coordinates. This may
entail measurements at the standard "extended 10-20" electrode locations, or at arbitrary positions in a finer
grid so as to facilitate 2d derivative calculations such as the gradient and Laplacian.
- A second real-time EEG channel. Add another 2 amplifiers and lowpass filter to the existing electronics in order
to simultaneously measure EEG signals at two electrode locations over the scalp. This will allow phase differences
at specific frequencies to be plotted as a function of position. This will also allow for the mapping of functional
areas of the cortex based on cross-correlation calculations (coherence) of real-time signals.
General
- New 3d spectrum plots. The proper coordinate systems in which to visualize and compare the spectra
of discrete functions are cylindrical and toroidal. I need to create additional components to create
these and other 3d plot types. In these new plots, attention will be paid to the continuous nature of the
spectrum trace (especially in terms of phase), and to analyses of that trace such as the winding number,
the Cauchy or other integrals, and possibly Poincare maps of trace projection vs. W or phase.
- Z transform analysis of signals. I have already computed the Laplace transform (or its closest discrete
equivalent) by using the current DFT component and premultiplication of a signal by an exponential function. I
need to create an actual Z transform component which will compute this transform for a rectangular grid of
points in the Z plane.
- Identification of zeros and poles in the Laplace and Z transforms of signals. I have done some preliminary
work on finding zeros in the Laplace transform of a signal, but additional work is required. Furthermore, the
locations of corresponding poles of a signal must also be identified, so that a rational polynomial representation
of the signal's system function can be derived.
©Copyright Sky Coyote, 2000-2002.