Created
July 29, 2023 08:32
-
-
Save SnowyPainter/0c0f9583207d094a58b5c86c35a7fe2a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
class Neuron: | |
def __init__(self, package): | |
self.schwannCells = 0 | |
self.Ranviers = -1 | |
self.neurotransmitter = package | |
self.Potential = -70 | |
self.i = 0 | |
@property | |
def SchwannCells(self): | |
return self.schwannCells | |
@SchwannCells.setter | |
def SchwannCells(self, value): | |
if value == 0: | |
self.Ranviers = -1 | |
else: | |
self.Ranviers = 2 + int(value) - 1 # 양끝 + 사이 | |
self.schwannCells = value | |
def Conduction(self, depolarization, repolarization, transmit): | |
print(f"{self.i+1}번째 도약 전도 - 전위 : {self.Potential}") | |
self.Potential = depolarization(self.Potential) | |
self.Potential = repolarization(self.Potential) | |
if self.i >= self.Ranviers: | |
self.i = 0 | |
transmit(self.neurotransmitter) | |
return | |
self.i += 1 | |
self.Conduction(depolarization, repolarization, transmit) | |
potential_values = [] | |
def example_depolarization(potential): | |
v = potential + 100 | |
potential_values.append(v) | |
return v | |
def example_repolarization(potential): | |
v = potential - 90 | |
potential_values.append(v) | |
return potential - 40 | |
def example_transmit(neurotransmitter): | |
pass | |
neuron = Neuron("Acetylcholine") | |
neuron.SchwannCells = 0 | |
potential_values.append(neuron.Potential) | |
for i in range(abs(neuron.Ranviers)): | |
neuron.Conduction(example_depolarization, example_repolarization, example_transmit) | |
plt.figure(figsize=(10, 6)) | |
plt.plot(range(len(potential_values)), potential_values, label="Action Potential") | |
plt.axhline(y=-70, color='orange', linestyle='--', linewidth=2, label="Resting Potential") | |
plt.xlabel("Time") | |
plt.ylabel("Potential") | |
plt.title("Action Potential and Resting Potential") | |
plt.legend() | |
plt.grid(True) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment