代写 CMU 18-879、代做 Python 编程语言
Instructions
CMU 18-879: Homework 1
Please read the following instructions carefully before attempting the problems:
• Submission Deadline: January 30, 2025, by 11:59 PM.
• Allowed Resources: Lecture slides and class notes. Online resources are allowed only if they are directly related to the course material and should be properly cited and declared in your submission. Please ask the instructors if you are not sure whether the resources can be used. You are not allowed to use ChatGPT or other AI-based tools for the homework.
• Submitting Your Work: Please submit your homework solutions to Grade- scope. All code written must be submitted to receive credits. Please organize your code clearly and provide instructions on how to run your code, since the course staff will manually grade your submissions.
• Collaborative Work: Collaboration is allowed; however, each student must submit an individual report detailing their own work and understanding of the problems. Please declare any assistance received, including discussions with others about the homework problems or the use of any online materials in your submissions.
• Late Submissions: Each student will be granted 6 late days in total, with a maximum of 2 late days allowed per homework.
1
18-879 Homework 1 1. Extracellular Stimulation of a Single Neuron
In the first part of the homework, you will gain hands-on experience working with a simulator for extra-cellular neural stimulation used in [1]. The handout includes the code to generate the membrane potential of a single excitatory or inhibitory neuron under the stimulation of a point electrode. For the simulation of a single neuron, you should be able to run the program on your local computer. The simulator employs the realistic morphologies and dynamics of excitatory pyramidal (Pyr) and inhibitory parvalbumin (PV) neurons.
This code forms the first testbed for this course, i.e., a simulator on which you can experiment by supplying input current and examining responses.
Running the Code Follow the README file in the simulation folder to install required packages. To perform a simulation, you should call the following function as in starter.py:
membrane_potential,t = pointElec_sim(num_electrode, amplitude,
pulse_width, period, total_time, cell_type, plot_neuron_with_electrodes)
• num electrode: The number of electrodes surrounding the neuron,
• amplitude: The amplitude of the square wave (in μA),
• pulse width: The duration of the pulse (in ms),
• period: The period of the signal (in ms),
• total time: The total length of the signal (in ms),
• cell type: The type of neuron being stimulated (‘Pyr’ or ‘PV’).
• plot neuron with electrodes: Set to True to visualize the neuron morphol- ogy and electrode locations.
• membrane potential: An ndarray of membrane potential (num electrode × num time points), in mV .
• t: The time array (in ms).
You can visualize the morphology of the neurons and the locations of the elec- trodes when you run the code. For this homework, the neuron ID of pyramidal and PV neurons were hardcoded to be 6 and 36 respectively. Please feel free to explore different cell morphologies from cell id pyr lst and cell id PV lst.
2
18-879 Homework 1
Problem 1. Time-series Analysis: Spike Detection and Firing Rate For this problem, set num electrode = 1, amplitude = 300, pulse width = 50, period = 100, total time = 400. (1) Plot the membrane potential over time. (2) Use the SciPy find peaks function with prominence = 40 to detect spikes. The prominence measures how much a signal stands out from the surrounding baseline. Calculate the firing rate (number of spikes per second). Plot the firing rate over the stimulation duration. Feel free to choose a bin size that you find appropriate. A total of 4 plots (2 plots for each neuron) should be submitted.
Problem 2. Effects of Pulse Width on Neural Response. In this task, we will modify the waveform of current injection and analyze how the neural responses change for both the pyramidal and PV neuron. For a stimulation amplitude of 300μA, modify the pulse width of the square wave input (pulse width ∈ [20, 50, 80]). (1) Plot the membrane potentials. (2) Plot the firing rate. Describe any qualitative observations. 12 plots (2 neurons × 3 pulse widths × 2 metric) should be submitted.
Problem 3. Effects of Stimulation Amplitude on Neural Response. The strength-duration curve describes electrode threshold current as function of stimulus pulse duration. For pulse width ∈ [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], calculate the corresponding minimum amplitude Amin of the square pulse that elicits a spike. You can set total time = 100, period = 100. Feel free to use any search methods (e.g. binary search) to find Amin. Plot the strength duration curve (x-axis: pulse width, y-axis: Amin).
Problem 4. Effects of Direction of Stimulation. Set num electrode = 4 to perform individual stimulations, where each uses one electrode at a time. The 4 electrodes are positioned at different locations on a sphere centered at the neuron. Set amplitude=300, pulse width=50, period=100, total time = 400. Plot the mem- brane potential for the 4 electrodes for both neurons. Please comment on the sen- sitivity of the neural responses to the direction of stimulation. A total of 8 plots should be submitted.
3
18-879 Homework 1 2. Exploring a nonlinear dynamical system
Problem 5. Consider the following two-dimensional dynamical system:
dx =αx−y−αx(x2 +y2) dt
dy =x+αy−αy(x2 +y2). dt
The system exhibits an interesting phenomenon called the “limit cycle”. In partic- ular, it has a trajectory where the state (x,y) repeats itself after some fixed time interval.
a) Demonstrate that this system has a limit cycle. Hint: you might need to convert x and y into polar coordinates.
b) Find out if the limit cycle is an “attractor state” (i.e., it is stable and attracts nearby trajectories) or “repeller state” (i.e., it is unstable and drives nearby trajec- tories away).
4
18-879 Homework 1 References
[1] Sara Caldas-Martinez et al. “Cell-specific effects of temporal interference stim- ulation on cortical function”. In: Communications Biology 7.1 (2024), p. 1076.
5