Module 5-7 MATLAB Assignment
Neural Prosthetics
Neural Stimulation Modeling (40 Points)
In this assignment you will model different aspects of neural stimulation:
• The external voltage and activation function resulting from a cathodic stimulation electrode
• Current steering from a tripolar electrode system
• The effect of electrode distance on neural activation
• The effect of neuron size on neural activation
You will also discuss how current steering functions, how it can be utilized in a practical application, and
which aspects of stimulation (electrode distance or neuron size) play a bigger role in neural activation.
Please do not rename existing variables or modify the existing lines of code.
You have 3 weeks to complete this assignment. It is due at the end of module 7.
Images and code:
a. Part1a.png - External Voltage vs. Axon Position (2 pts)
b. Part1b.png - Activation Functions vs. Axon Position (2 pts)
c. Part2a-1.png - Tripolar External Voltage Components vs. Axon Position (3 pts)
d. Part2a-2.png - Tripolar External Voltage Steering vs. Axon Position (3 pts)
e. Part2a-3.png - Tripolar Activation Function Steering vs. Axon Position (3 pts)
f. Part3.png - Activation Threshold vs. Electrode Distance (5 pts)
g. Part4.png - Activation Threshold vs. Fiber Diameter (5 pts)
h. LastName_Assignment_Module567.m
Responses to the following discussion prompts:
1. In part 1a, at which axon position is the external voltage most negative? Why is this? (1 pt)
2. In part 1b, explain the shape of the curve and what the peaks/troughs correspond to. (2 pts)
3. In part 2a, what is the parameter alpha (a) doing? By inspecting the resulting activation functions,
how does AP generation change as alpha changes? (5 pts)
4. Researchers developed a motor neuroprosthesis that allowed people with spinal cord injury to stand
upright. To do this, they used a multi-contact nerve cuff electrode to stimulate the femoral nerve,
which innervates the quadriceps. When all four muscles of the quadriceps (the rectus femoris, vastus
lateralis, vastus medialis, and vastus intermedius) are simultaneously activated, it quickly leads to
fatigue and minimizes the time a person can stand for. To avoid this, in the study "Sum of phase-
shifted sinusoids stimulation prolongs paralyzed muscle output" (Gelenitis 2020), researchers used
phase-shifted sinusoids to stimulate just one quadriceps muscle group at a time. How could the
tripolar current steering system designed in Part 2a be used to decrease muscle fatigue? (5 pts)
5. In part 3, what is the relationship between electrode distance and activation threshold? (2 pts)
6. In part 4, what is the relationship between neuron size and activation threshold? (2 pts)
Please submit a zip file containing your images, code, and a PDF of your responses.
1
Note: In this assignment, units matter a lot! The simulation variables are in very specific units, so
make sure to conform to them.
Part 1a – External Voltage (3 Points)
Goal: Model the external voltage generated by an electrode along a neuron’s axon. Your electrode is
injecting 0.5 mA of cathodic (negative) current, at a distance of 1 mm. The neuron has 101 nodes which
are 0.5 mm apart and the electrode is closest to the center node. The resistivity of the environment is
0.3 kOhm/cm.
Procedure:
1. Open the “Assignment_M567_Fall23.m” code.
2. Implement the external voltage equation from Module 5B-C slide 8 in line 23.
3. Plot the external voltage vs. position along the axon and save it as Part1a.png
4. Answer discussion prompt #1 on page 1.
Part 1b – Activation Function (4 Points)
Goal: Model the activation function generated by an electrode along a neuron’s axon.
Procedure:
1. Implement the activation function equation from Module 5B-C slide 6 using the external voltage
calculated in Part 1a.
2. Plot the activation function vs. position along the axon and save it as Part1b.png
3. Answer discussion prompt #2 on page 1.
Part 2a – Multipolar Stimulation (19 Points)
Goal: Model the external voltage and activation function generated by a tripolar electrode system along
a neuron’s axon. In this case, there are three electrodes that are 1 mm away from the closest node on
the axon. Electrode 1 is closest to the center (0th) node and injects 0.5 mA of cathodic current. Electrode
2 is closest to node 10 and injects a*0.5 mA of anodic current. Electrode 3 is closest to node -10 and
injects (1-a)*0.5 mA of anodic current. The rest of the stimulation parameters are the same as Part 1.
Note: This tripolar electrode stimulation setup is inspired by the paper “Electric field focusing and shifting
technique in deep brain stimulation using a dynamic tripolar current source” (Valente 2010).
Procedure:
1. Calculate the external voltages from each electrode when a = 0.1 (ve1, ve2, ve3). Calculate the
overall external voltage which is the sum of the individual external voltages (vtot_0p1). Plot all 4
of these external voltages vs. position along the axon, and save it as Part2a-1.png
2
2. Do the same calculations (external voltages) as Part 2a-1 for a = 0.5 and a = 0.9. Plot the 3
overall external voltages for a = 0.1, 0.5, 0.9 (vtot_0p1, vtot_0p5, vtot_0p9) vs. position along
the axon, and save it as Part2a-2.png
3. Calculate the activation function for all 3 overall external voltages. Plot the activation functions
for a = 0.1, 0.5, 0.9 (d2vdx2_tot_0p1, d2vdx2_tot_0p5, d2vdx2_tot_0p9) vs. position along the
axon, and save it as Part2a-3.png
4. Answer discussion prompts #3 and #4 on page 1.
Part 3 – Activation threshold vs. electrode distance (7 Points)
Goal: Explore how neural activation from electrical stimulation changes as electrode distance varies.
Procedure:
1. Download rattayHH.m from Canvas and put it in the same folder as the assignment code.
a. Usage: rattayHH(electrode_dist, fiber_diam, pulse_amp) is a function that implements the
Hodgkin Huxley model (for AP initiation and propagation) and the Rattay Model (for
external electrical stimulation). It simulates a stimulation pulse with the given electrode
distance (cm), fiber diameter (cm), and pulse amplitude (mA). It returns whether an AP
was generated (ap_gen) with a 1 (AP generated) or 0 (AP not generated).
b. Extra Info: The Vnt output returns the membrane voltage of all the nodes at all points in
simulated time but will not be necessary for this assignment. The simulation is 7 ms long
with 1 µs time steps (for 7000 total time steps). The pulse is 100 µs long and starts at 0.5
ms. 101 nodes are simulated with a node gap of 1 mm so the axon is 10 cm long.
2. The fiber diameter is fixed at 10 µm. You are given seven electrode distances in the code (from
0.5 to 2 mm). Using the rattayHH function, for each electrode distance, determine the cathodic
current threshold (i.e. the lowest current that generates an AP). For each distance, get within 10
µA of the threshold.
a. Hint: All thresholds are smaller than 1 mA
3. Plot the activation threshold vs. electrode distance and save it as Part3.png
4. Answer discussion prompt #5 on page 1.
Part 4 – Activation threshold vs. fiber diameter (7 Points)
Goal: Explore how neural activation from electrical stimulation changes as fiber diameter varies.
Procedure:
1. The electrode distance is fixed at 1 mm. You are given 11 fiber diameters in the code (from 1 µm
to 10 µm). Using the rattayHH function to help, for each fiber diameter, determine the cathodic
current threshold (i.e. the lowest current that generates an AP). For each diameter, get within 5
µA of the threshold.
a. Hint: All thresholds are smaller than 0.5 mA
2. Plot the activation threshold vs. fiber diameter and save it as Part4.png
3. Answer discussion prompt #6 on page 1.