digital signal processing, Assignments of Digital Systems Design

my project to do a lab to establish criteria

Typology: Assignments

2021/2022

Uploaded on 12/01/2024

jeffares-1
jeffares-1 🇺🇸

2 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECGR4124/5124 Digital Signal Processing
Projects will NOT be accepted late. It is due at the beginning of class.
Project 1
Matched Filters: Applications of Cross-Correlation
One possible application of cross-correlation is the detection of a signal embedded within noise. The
signal can be estimated by cross-correlating a template signal with the input signal. The template signal,
h[n]
, is considered to be known
a-priori
. Detection is accomplished by time-reversing the template and
convolving it with the input signal. Maxima observed in the output signal indicate lag indices where the
template and the shape of interest in the noisy signal are aligned.
h[n]
is referred to as a
matched lter
, i.e.,
a lter which is custom-designed to detect the presence of a specic structure within the input signal, recall
from class that
x[n]? h[n] = rxh[n]
.
ECGR 4124/5124 Task 1
This task has students detect the phase and period of a sinusoid embedded within a noisy signal. To
do so, we generate a sinusoidal with known frequency but unknown phase and corrupt this sinusoid with
additive random noise (steps (a,b)). We then compute a zero phase template of the sinusoid consisting of
K
samples using the known frequency of the sinusoid (step (c)). We then attempt to detect the presence of
the unknown sinusoid by cross-correlating the template and the noisy signal (step (d)) by detecting peaks,
i.e., local maxima in the output signal from the cross-correlation.
1. Generate a sinusoidal sequence
x[n] = cos( π
15 n+φ) 1 n200
and
φ= 0
.
2. Corrupt this signal with additive uniformly distributed noise
e[n]
of amplitude
±15
with distribution
U[0.5,0.5]
. For a length
N
sequence, you can generate the noise with the following MATLAB
code:
noisevals = 30*(rand(N,1)-0.5);
3. Compute matched lters of varying length
hK[n] = cos( π
15 n)
where
0n<K
and
K= 10,20,40,80
.
4. Compute the cross-correlation of the noisy signal,
x[n] + e
, and
h[n]
.
ECGR 4124/5124 Task 1 (30 pts)
To Turn in:
You are responsible for turning in the following objects IN THE ORDER LISTED BELOW.
Deductions
will be made for reports which are messy and dicult to comprehend.
Using your MATLAB
program for steps 1-4 provide the following:
1. (5pts) Turn in your MATLAB code for computing steps 1-4. NO MATLAB CODE IMPLIES NO
CREDIT FOR ANY OF YOUR SOLUTIONS. These points are awarded for code that is clearly
written and follows the guidelines of the project.
2. (5pts) Using subplot(), plot the cross-correlation signals for each value of
K
as a 4x1 (4-row,1-column)
matrix of plots.
3. (5pts) Use the location of peaks in the output to estimate the period of the noisy sinusoidal input
x[n]
.
State the estimated value of the sinusoid period.
4. (5pts) Provide a 1-paragraph explanation of how the variable
K
impacts the estimation of the period.
5. (5pts) If the noise amplitude were increased, how would you change
h[n]
to get a better estimate?
6. (5pts) Is it also possible to estimate the phase of the function if
φ6= 0
? If so, give an idea of how you
would do this?
Hint :
From the program above, let
φ=π
or
φ=π
2
and observe how the value of the indices of your
peaks change.
1
pf3
pf4

Partial preview of the text

Download digital signal processing and more Assignments Digital Systems Design in PDF only on Docsity!

ECGR4124/5124 Digital Signal Processing

Projects will NOT be accepted late. It is due at the beginning of class.

Project 1

Matched Filters: Applications of Cross-Correlation

One possible application of cross-correlation is the detection of a signal embedded within noise. The signal can be estimated by cross-correlating a template signal with the input signal. The template signal, h[n], is considered to be known a-priori. Detection is accomplished by time-reversing the template and convolving it with the input signal. Maxima observed in the output signal indicate lag indices where the template and the shape of interest in the noisy signal are aligned. h[n] is referred to as a matched lter, i.e., a lter which is custom-designed to detect the presence of a specic structure within the input signal, recall from class that x[n]? h[−n] = rxh[n]. ECGR 4124/5124 Task 1 This task has students detect the phase and period of a sinusoid embedded within a noisy signal. To do so, we generate a sinusoidal with known frequency but unknown phase and corrupt this sinusoid with additive random noise (steps (a,b)). We then compute a zero phase template of the sinusoid consisting of K samples using the known frequency of the sinusoid (step (c)). We then attempt to detect the presence of the unknown sinusoid by cross-correlating the template and the noisy signal (step (d)) by detecting peaks, i.e., local maxima in the output signal from the cross-correlation.

  1. Generate a sinusoidal sequence x[n] = cos( 15 π n + φ) 1 ≤ n ≤ 200 and φ = 0.
  2. Corrupt this signal with additive uniformly distributed noise e[n] of amplitude ± 15 with distribution U ∼ [− 0. 5 , 0 .5]. For a length N sequence, you can generate the noise with the following MATLAB code: noisevals = 30*(rand(N,1)-0.5);
  3. Compute matched lters of varying length hK [n] = cos( 15 π n) where 0 ≤ n < K and K = 10, 20 , 40 , 80.
  4. Compute the cross-correlation of the noisy signal, x[n] + e, and h[n].

ECGR 4124/5124 Task 1 (30 pts) To Turn in: You are responsible for turning in the following objects IN THE ORDER LISTED BELOW. Deductions will be made for reports which are messy and dicult to comprehend. Using your MATLAB program for steps 1-4 provide the following:

  1. (5pts) Turn in your MATLAB code for computing steps 1-4. NO MATLAB CODE IMPLIES NO CREDIT FOR ANY OF YOUR SOLUTIONS. These points are awarded for code that is clearly written and follows the guidelines of the project.
  2. (5pts) Using subplot(), plot the cross-correlation signals for each value of K as a 4x1 (4-row,1-column) matrix of plots.
  3. (5pts) Use the location of peaks in the output to estimate the period of the noisy sinusoidal input x[n]. State the estimated value of the sinusoid period.
  4. (5pts) Provide a 1-paragraph explanation of how the variable K impacts the estimation of the period.
  5. (5pts) If the noise amplitude were increased, how would you change h[n] to get a better estimate?
  6. (5pts) Is it also possible to estimate the phase of the function if φ 6 = 0? If so, give an idea of how you would do this? Hint : From the program above, let φ = π or φ = π 2 and observe how the value of the indices of your peaks change.

ECGR 4124/5124 Task 2 This task has students detect the frequency of a sinusoid embedded within a noisy signal. To do so, we generate a set of candidate sinusoidal functions, each representing our guess for the unknown frequency. We then cross-correlate these functions with the input signal and then use the magnitude of the peaks in the output as a score for the presence of each frequency in the input signal. Let our signal be a sinusoid x(t) containing an unknown frequency that lies in the range from 1 Hz to 2 Hz. This signal is sampled at a rate of 30 samples per second by an analog-to-digital converter to create a digital signal x[n]. In this circumstance we will proceed as follows:

  1. Hypothesize a sinusoidal sequence having frequencies ranging from f = [1Hz, 2 Hz] in increments of 0.2 Hz. Create a digital lter h[n] to cross-correlate with the input x[n].
  2. Adjust values of your lter coecients so that the sum of the lter coecients is equal to 0. This can be accomplished by sampling the sinusoid symmetrically about the origin since the sine function is odd symmetric, i.e., sin(x) = − sin(−x). Note that since sin(0) = 0 the sample h[0] has no contribution to either your lter or the output value.
  3. For each sequence, cross-correlate your signal with the input signal.
  4. Observe the output signal and nd the cross-correlation signal having largest peak response. This frequency is then the best guess for the unknown frequency in the input signal.

ECGR 4124/5124 Task 2 (40pts) To Turn In: Turn in your MATLAB code. NO MATLAB CODE IMPLIES NO CREDIT FOR ANY OF YOUR SOLUTIONS.

  1. (10pts) On one plot show your 6 lters hi[n] representing your hypothesized frequencies. Let your lters be 100 samples long (or 101 samples if you count the sample h[0] = 0).
  2. (10pts) Using the data le provided, provide a single plot showing the 'valid' part, i.e., non-transient part, of your cross-correlations for each of your lters from (1) with the data le containing the unknown frequency. Hint: Use conv(A,B,'valid').
  3. (10pts) Indicate which lter has a frequency closest to the unknown frequency present in the data le. Clearly state the frequency indicated as your best guess from the outputs of (2).
  4. (10pts) Rene your best guess answer for the unknown frequency by changing your MATLAB code. Indicate your improved guess (dierent than that from (3)). Explain how you arrived at your improved solution.

ECGR 4124/5124 Task 3 We now will take your best guess from Task 2 to process video image data as if each image pixel were a single time-domain function. For example, let a hypothetical camera take 10x10 pixel videos. Each image will have 100 pixels and each time a new image is captured the pixel value represents a digital sample from the analog world. Let xi[n] denote the signal for image pixel i at sample index n. For our 10x10 images this creates 100 signals x 1 [n] (the top left corner pixel) to x 100 [n] (the bottom right corner pixel). We will then assume that a signal having your best guess frequency exists within every one of these 100 signals and we want to magnify the presence of this normally undetectable signal. To do so we proceed as follows:

  1. Read in the video data le and convert it to a list of signals, if the image has N columns and M rows we convert this into a list of NM signals x 1 [n], x 2 [n],... xN M [n].
  2. Cross-correlate your lter with each of the input signals creating output signals y 1 [n], y 2 [n],... yN M [n].

At this point we could try and look at each of these signals for the unknown frequency but for even small images this is too much data to analyze. Instead we will try re-incorporate the magnied frequency into the original video and view the video to see the output.

(i) Write a function to compute the coecients of a template with 41 values by sampling Tg at the same frequency as x[n], i.e., n = [0,... , 40]. Using a MATLAB function call to construct each Gaussian pulse, a function template has been provided in the le: construct_pulse.m. Assemble the template function, t[n], by summing the Ng constructed Gaussian pulses. Plot the resulting template function using stem() in MATLAB. Convert this template into a digital lter by time reversing the template. Plot the lter coecients of your matched lter, h[n], in a second plot.

(ii-iii) Detect the pulse signals within the data signal and generate a list containing the sample lag indices of the detected pulses. Use these indices to estimate the period of the noise-perturbed signal, N̂. (Hint : N > 5 samples). The detection and estimation scheme which one may use is as follows :

  1. Find the maximum correlation value.
  2. Find all sample indices where the signal value, i.e., nd all n such that y[n] ≥ 0. 8 max(y[n]) where y[n] = x[n]∗h[−n]. These are indices of correlation values ≥ 80% of the maximum observed correlation value. We consider the resulting set of indices, K = {k 1 , k 2 , ...}, as possible lag indices where the template and the embedded pulse signal have aligned.
  3. Compute the period estimates for each of the resulting index pairs by subtracting neighboring indices from K. Here we assume that indices with large correlation values indicate the presence of the template in the signal. Dierences between these indices indicates the period of the unknown signal (in samples).
  4. Use the hint to discard some invalid values for N.
  5. Find the fundamental period from the remaining values, i.e., the smallest value.
  6. Take all values within 30% of the fundamental period. Use their mean value as the estimate of the period, N̂.
  7. Use N̂ and the sample rate to compute the heart rate of your patient in beats per minute.

Feel free to design your own detection scheme. Any reasonable estimation scheme is acceptable.

(iv) Vary the length of your computed matched lter by taking the rst Nk values from the templatet[n] where Nk = [4, 10 , 41]. Run your program from (ii-iii). Take your period estimates from step 6 and compute the standard deviation of the period estimates as a function of the length of the template. Make a comment on your observations.

Input les are available for download at the ECGR4124/5124 website.

ECGR 5124 Task 4 (100 pts) To turn in: You are responsible for turning in the following objects IN THE ORDER AS LISTED BELOW. Deduc- tions will be made for reports which are messy and dicult to comprehend. Turn in your MATLAB code. NO MATLAB CODE IMPLIES NO CREDIT FOR ANY OF YOUR SOLUTIONS.

  1. (30pts) Plot of your matched lter and template from (i).
  2. (30pts) Period estimates and plots as requested in (ii),(iii),(iv) and related comments and observations. Make sure to provide the estimated heart rate in beats per minute.
  3. (20pts) Plot of the standard deviation of the period as a function of the template length from (iv) and the associated mean estimates of the period for dierent length templates.
  4. (20pts) Your programs to solve (i)-(iv).