0% found this document useful (0 votes)
4 views

M3 4 Assignment

matlab hep

Uploaded by

yonas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

M3 4 Assignment

matlab hep

Uploaded by

yonas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Module 3/4 MATLAB Assignment

Neural Prosthetics

Processing of Invasive Neural Signals


This assignment aims to introduce students to signal processing techniques used in the
processing of neural spike data. Through completing this assignment, students will learn how to
filter raw spike data, detect neural events, and reconstruct neural activity spike trains from
multiple neurons.

You have two weeks to complete this assignment; it is due at the end of Module 4. Please start
it early!

Deliverables/scoring:

Images and code:


a. spikes_bpf.png (1 pt)
b. neo.png (1 pt)
c. spikes_aligned.png (2 pts)
d. spikes_clusters.png (2 pts)
e. neo.m (2 pts)
f. align_spikes.m (1 pt)
g. LastName_Assignment_Module3.m

Responses to the following discussion prompts:


1. In Part 1, which frequency bounds did you choose for the bandpass filter and why?
(1 pt)
2. In Part 2, what impact did applying the NEO to the data have? (1 pt)
3. In Part 3, which ‘eps’ threshold value did you choose and why? How did different eps
values change your plots of the aligned spikes, and your PCA plot? (3 pts)

Please submit a zip file containing your images, code, and a PDF of your responses.
Part 1 – Frequency-based noise removal (2 points)

Goal: Remove noise from the neural spike data using frequency-based filters.

Procedure:

1. From Canvas, download the MATLAB files found under Assignments > Module 3/4
Assignment. Open the Assignment_Module3.m file in MATLAB. Load the neural spike
data found in the file spikes.mat. Please do not rename existing variables or modify the
existing lines of code.

2. Bandpass filter the imported neural spike data by filling in the missing parameters in
Section 1. The following variables need to be defined by you:
a. fs – the sampling frequency of the neural spike data
b. fl – the desired lower bound cutoff frequency of the bandpass filter
c. fh – the desired higher bound cutoff frequency of the bandpass filter

3. Once each variable is defined, run the code in Section 1 to bandpass filter the neural
spike data and generate a plot of the pre- and post-filtered spectral content of the
recorded data. Save this plot as: spikes_bpf.png

4. Answer discussion prompt #1 on page 1.

Part 2 – Nonlinear energy operation (4 points)

Goal: Implement the nonlinear energy operator and apply it to the neural spike data.

Procedure:

1. Create a MATLAB function file neo.m in which you will implement the nonlinear energy
operator (NEO) described in lecture. Hint: pay close attention to the square brackets,
and how the first and last samples may handled differently. The desired function
template is as follows:

function neodata = neo( fdata )


% @param fdata : the input neural data [num_samples × 1]
% @return neodata : the NEO transformed data [num_samples × 1]
end

2. Once you have implemented neo.m, apply the transform to the filtered neural spike data
and generate a plot of the NEO signal by running the code in Section 2.
Save this plot as: neo.png.

3. Answer discussion prompt #2 on page 1.


Part 3 – Spike detection and alignment (4 points)

Goal: Implement a spike detection and alignment algorithm using the NEO transformation.

Procedure:

1. Looking at the plot generated in Section 2, determine an appropriate threshold to apply


to the NEO signal to detect the neural spikes. This threshold may be chosen through
guess-and-check, or you may determine the threshold using statistics of the NEO signal.
Either way, you must define the following variable:
a. eps – the threshold for the NEO signal above which a spike is decided to have
occurred

2. Once the threshold has been determined, open the align_spikes.m function in
MATLAB. This code will implement your spike detection and alignment algorithm. Your
algorithm must comply with the following processing logic:
a. Neural spikes must be detected when the NEO signal is greater than the
threshold defined by eps.
b. The neural waveform is defined as 300 microseconds before and 600
microseconds after the peak of the absolute value of the detected neural spike.
c. The recorded index of the neural spike is defined as the index in fdata where the
peak of the absolute value of the neural waveform occurs.

3. You must define the following variables in the algorithm code:


a. num_inds_before_spike – the number of samples/indices BEFORE the peak of
the absolute value of the detected neural spike
b. num_inds_after_spike – the number of samples/indices AFTER the peak of the
absolute value of the detected neural spike
c. temp_waveform – the portion of the data within the temporal window of interest

4. Run the code in Section 3 to detect spikes in the filtered neural data and generate a plot
of the detected waveforms. Save this plot as: spikes_aligned.png.

5. Answer discussion prompt #3 on page 1.


Part 4 – Spike clustering (2 points)

Goal: Use clustering of the neural waveforms to determine the number of recorded neurons.

Procedure:
1. Using the code in Section 4 of Assignment_Module3.m, perform principal component
analysis (PCA) and k-mean clustering on the detected neural waveforms to determine
how many neurons are being recorded by this single channel. The following variable
needs to be defined by you:
a. k – the expected number of neurons to find in the clustering

Determining the value of k is largely a subjective process. We suggest plotting the PCA-
transformed neural waveforms and using your best judgment to determine how many
clusters you believe you observe.

2. Once k is determined, run the code in Section 4 to a plot of the k-means clustered
neural waveforms. Save this plot as: spikes_clusters.png.

You might also like