Professional Documents
Culture Documents
Lecture 3
Lecture 3
Lecture 3
BME 366
(Lecture THREE)
Bio-Signals, ADC & DAC
Daniel Akwei Addo, PhD.
Casely Hayford Building (BME lab [office 1])
danieladdo@knust.edu.gh
Discrete-time signals and systems
➢ Most signals are generated naturally but a signal can also be generated artificially using a
computer.
➢ And signals can be in any number of dimensions (1D, 2D, 3D, etc).
➢ We will be mainly studying time series signals, which are 1D signals with amplitude,
pressure, intensity, etc as a function of time.
➢ Later in the course, we will study static image signals which are 2D signals.
Discrete-time signals and systems
Discrete-time signal
➢ In general, biological signals that are recorded are analogue and to process analogue signals
by digital means (like using a computer), we need to convert them to discrete-time form, i.e.
to convert them to a sequence of numbers defined at specific uniform intervals.
➢ Since most biological signals are 1D time series signals, we will focus our attention to such
signals where the independent variable is time.
➢ It is done by taking samples at specific uniform intervals of time (every value of x[n] is called
a sample) and the sampling interval is the time of one of these uniform intervals while the
sampling frequency is the number of uniform time intervals in one second normally
specified in Hz.
Discrete-time signals and systems
Aliasing
➢ To avoid aliasing and be able to reconstruct the original signal without errors, the sampling
frequency has to be more than twice of the highest frequency contained in x(t).
➢ This is known as Nyquist theorem and the minimum frequency known as Nyquist frequency
(rate).
Discrete-time signals and systems
Discrete-time signals and systems
TASK ONE: MATLAB ILLUSTRATION OF SAMPLING AND ALIASING
Discrete-time signals and systems
Discrete-time signals and systems
➢ Recreate the analog signal using a sine wave with same the frequency and sampling
frequencies but with an amplitude of 10 mm
Discrete-time signals and systems
Discrete-time signals and systems
Sequences
➢ E.g.
➢ There are several common operations that we will frequently encounter for discrete-time
systems and we will look at a few here.
Discrete-time signals and systems
Basic Discrete-time System Operations
➢ There are several common operations that we will frequently encounter for discrete-time
systems and we will look at a few here.
Discrete-time signals and systems
Basic Discrete-time System Operations
➢ There are several common operations that we will frequently encounter for discrete-time
systems and we will look at a few here.
Discrete-time signals and systems
Basic Discrete-time System Operations
➢ There are several common operations that we will frequently encounter for discrete-time
systems and we will look at a few here.
Discrete-time signals and systems
Basic Discrete-time System Operations
➢ There are several common operations that we will frequently encounter for discrete-time
systems and we will look at a few here.
Discrete-time signals and systems
Basic Discrete-time System Operations
➢ There are several common operations that we will frequently encounter for discrete-time
systems and we will look at a few here.
Discrete-time signals and systems
Basic Discrete-time System Operations
Discrete-time signals and systems
Basic Discrete-time System Operations
Discrete-time signals and systems
Basic Discrete-time System Operations
Discrete-time signals and systems
Basic Discrete-time System Operations
Discrete-time signals and systems
Basic Discrete-time System Operations
Discrete-time signals and systems
Basic Discrete-time System Operations
Discrete-time signals and systems
Basic Discrete-time System Operations
Discrete-time signals and systems
Basic Discrete-time System Operations
Discrete-time signals and systems
Basic Discrete-time System Operations
Discrete-time signals and systems
Signal Generation and noise contamination using MATLAB SIMULINK
➢ Open the Signal model by typing
ex_gstut3
➢ At the MATLAB® command prompt. This model contains a Scope block that displays the
original sine wave and the sine wave with white noise added
Discrete-time signals and systems
Signal Generation and contamination using MATLAB SIMULINK
➢ This process maps inputs in a different range of values to a different common value.
➢ To specify a partition in the MATLAB® environment, list the distinct endpoints of the
different ranges in a vector.
Quantization with MATLAB
➢ A codebook tells the quantizer which common value to assign to inputs that fall into each
range of the partition.
➢ Represent a codebook as a vector whose length is the same as the number of partition
intervals.
➢ The code below shows how the quantiz function uses partition and codebook to map a real
vector, samp, to a new vector, quantized, whose entries are either -1, 0.5, 2, or 3.
➢ samp = [-2.4, -1, -.2, 0, .2, 1, 1.2, 1.9, 2, 2.9, 3, 3.5, 5];
➢ partition = [0,1,3];
➢ [index,quantized] = quantiz(samp,partition,codebook);
➢ quantized
Quantization with MATLAB
Scalar Quantization Example 1
The output is below.
quantized =
Columns 1 through 6
Columns 7 through 12
Column 13
3.0000
Quantization with MATLAB
Scalar Quantization Example 2
➢ After quantizing a sampled sine wave, it plots the original and quantized signals.
➢ The plot contrasts the x's that make up the sine curve with the dots that make up the
quantized signal.
➢ plot(t,sig,'x',t,quants,'.’)
➢ The lloyds function optimizes the partition and codebook according to the Lloyd
algorithm.
➢ The code below optimizes the partition and codebook for one period of a sinusoidal
signal, starting from a rough initial guess.
➢ Then it uses these parameters to quantize the original signal using the initial guess
parameters as well as the optimized parameters.
➢ The output shows that the mean square distortion after quantizing is much less for the
optimized parameters.
➢ The quantiz function automatically computes the mean square distortion and returns it
as the third output parameter.
Quantization with MATLAB
% Start with the setup from 2nd example in "Quantizing a Signal."
t = [0:.1:2*pi];
sig = sin(t);
partition = [-1:.2:1];
codebook = [-1.2:.2:1];
% Now optimize, using codebook as an initial guess.
[partition2,codebook2] = lloyds(sig,codebook);
[index,quants,distor] = quantiz(sig,partition,codebook);
[index2,quant2,distor2] = quantiz(sig,partition2,codebook2);
% Compare mean square distortions from initial and optimized
[distor, distor2] % parameters.
➢ Better to create the partition and codebook using characteristics of the signal.
➢ Try this:
Ts=0.0001;
t=0:.00001:20*Ts;
sig=sin(2000*pi*t)+cos(2000*pi*t);
maxsig=max(sig); %signal max
interv=2*maxsig/(2^3-1); %interval length for 8 levels resolution
u=maxsig+interv;
partition = [-maxsig:interv:maxsig];
codebook = [-maxsig:interv:u];
[index,quants] = quantiz(sig,partition,codebook); % Quantize.
plot(t,sig,'-',t,quants,'-');
legend('Original signal','Quantized signal');
Quantization with MATLAB
Ts=0.0001;
t=0:.00001:20*Ts;
sig=sin(2000*pi*t)+cos(2000*pi*t);
maxsig=max(sig); %signal max
interv=2*maxsig/(2^3-1); %interval length for 8 levels resolution
u=maxsig+interv;
partition = [-maxsig:interv:maxsig];
codebook = [-maxsig:interv:u];
[index,quants] = quantiz(sig,partition,codebook); % Quantize.
plot(t,sig,'-',t,quants,'-');
legend('Original signal','Quantized signal');
➢ Increase the resolution to 16, 32, 64 and 128 levels and determine the distortion for each
resolution.
➢ For the 8 levels resolution, apply Lloyds optimization algorithm and assess the effect on the
quantization noise.