<jupyter_start><jupyter_text>Hindmarsh-Rose ModelThe Hindmarsh-Rose model is described by three coupled first order differential equation (ODE):$$\frac{dx}{dt} = y - ax^3 + bx^2 + I - z\\  \frac{dy}{dt} = c - dx^2 - y\\\frac{dt}{dt} = r(s(x-x_{1}) - z)\\$$where $x$ is the membranne potential, $y$ the recovery variable and $z$, a slow current which gradually hyperpolarizes the neuron. $a$, $b$, $c$, $d$, $r$ ans $s$ are positive constants and $x_1$ being the resting potential.<jupyter_code># Add temporary path to code
import sys
sys.path.append("../")

# Import the module with the Hindmarsh-Rose model
from neural_models import HindmarshRose

# Create the model
model = HindmarshRose(a=1, b=3, c=1, d=5, r=0.001, s=1, x1=-1)

# Print the model parameters
print(model)

# Run the model
model.run(X0=[0, 0, 0], current=0.4, t=100)
%matplotlib inline
import matplotlib.pyplot as plt

# Plot the results
f, ([ax1, ax2, ax3]) = plt.subplots(1, 3, figsize=(13, 3), tight_layout=True)

# Plot x(t)
ax1.plot(model.tvec, model.x, color='royalblue')
ax1.set_title("x", fontsize=15)
ax1.set_xlabel("time [ms]", fontsize=12)
ax1.set_ylabel("x(t)", fontsize=12)
ax1.grid(alpha=0.3)

# Plot y(t)
ax2.plot(model.tvec, model.y, color='lightcoral')
ax2.set_title("y", fontsize=15)
ax2.set_xlabel("time [ms]", fontsize=12)
ax2.set_ylabel("y(t)", fontsize=12)
ax2.grid(alpha=0.3)

# Plot z(t)
ax3.plot(model.tvec, model.z, color='goldenrod')
ax3.set_title("z", fontsize=15)
ax3.set_xlabel("time [ms]", fontsize=12)
ax3.set_ylabel("z(t)", fontsize=12)
ax3.grid(alpha=0.3)
plt.show()<jupyter_output><empty_output><jupyter_text>We can create bursts by increasing $s$ and the time of the simulation.<jupyter_code># Burst Generation

# Create the model
model = HindmarshRose(a=1, b=3, c=1, d=5, x1=-1, r=0.001, s=4)

# Run the model
model.run(X0=[0, 0, 0], current=0.4, t=1000)
# Plot the results
f, ([ax1, ax2, ax3]) = plt.subplots(1, 3, figsize=(13, 3), tight_layout=True)

# Plot x(t)
ax1.plot(model.tvec, model.x, color='royalblue')
ax1.set_title("x", fontsize=15)
ax1.set_xlabel("time [ms]", fontsize=12)
ax1.set_ylabel("x(t)", fontsize=12)
ax1.grid(alpha=0.3)

# Plot y(t)
ax2.plot(model.tvec, model.y, color='lightcoral')
ax2.set_title("y", fontsize=15)
ax2.set_xlabel("time [ms]", fontsize=12)
ax2.set_ylabel("y(t)", fontsize=12)
ax2.grid(alpha=0.3)

# Plot z(t)
ax3.plot(model.tvec, model.z, color='goldenrod')
ax3.set_title("z", fontsize=15)
ax3.set_xlabel("time [ms]", fontsize=12)
ax3.set_ylabel("z(t)", fontsize=12)
ax3.grid(alpha=0.3)
plt.show()
# Plot the phase plane
f, ([ax1, ax2]) = plt.subplots(1, 2, figsize=(13, 3), tight_layout=True)

# Plot y over x
ax1.plot(model.x, model.y, color='royalblue')
ax1.set_xlabel("x", fontsize=12)
ax1.set_ylabel("y", fontsize=12)
ax1.grid(alpha=0.3)

# Plot z over x
ax2.plot(model.x, model.z, color='royalblue')
ax2.set_xlabel("x", fontsize=12)
ax2.set_ylabel("z", fontsize=12)
ax2.grid(alpha=0.3)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19119623655913978, 'fraction_numerical': 0.05611559139784946, 'mean_word_length': 5.859447004608295, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '481640', 'license': 'MIT', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1287, 'n_words': 283, 'path': 'notebooks/hindmarsh_rose.ipynb', 'repo_name': 'sgalella/NeuralModels', 'size': '2976'}