Similar to the single SAC example you can simulate, trace the voltage at the soma and plot it:
simulation.simulate()
results = simulation.trace_voltages_at_soma()
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8,5))
for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]:
plt.plot(results[0]['0'][i]['t'], results[0]['0'][i]['v'], ls='-', c='r', label='Expanding stimulus',linewidth=3)
plt.show()
Note that here voltages are traced in all 13 cells:
You can use the code below to generate the following synapse activity video, visualized over the SAC plexus:
Note that the following code is not a native RSME code and that it might require the installation of video codecs in accordance with your operating system.
import seaborn as sns
import pandas as pd
from matplotlib import animation, rc
from IPython.display import HTML
from neuron import h
import matplotlib as mpl
xs = []
ys = []
sps = []
for cell in simulation.synapse_dict['light']['0']:
for i in range(len(simulation.synapse_dict['light']['0'][cell]['x'])):
x = simulation.synapse_dict['light']['0'][cell]['x'][i]
y = simulation.synapse_dict['light']['0'][cell]['y'][i]
syn = simulation.synapse_dict['light']['0'][cell]['BC_syn'][i]
spike_times = simulation.simulation['spikes']['0'][cell][i]
for sp_time in spike_times:
xs.append(x)
ys.append(y)
sps.append(sp_time)
mpl.rcParams['animation.embed_limit']= 100
df = pd.DataFrame({'x':xs,'y':ys,'sps':sps})
df.index = df.sps
df = df.sort_index()
fig = figure(figsize=(9,9))
ax1 = subplot(1,1,1)
color = sns.color_palette("Paired",14)
for cell in simulation.simulation['cells']['0']['instances']:
for sec in simulation.simulation['cells']['0']['instances'][cell]['section_dict']['section_list']:
xs2 =[]
ys2 =[]
for i in range(int(sec.n3d())):
xs2.append(sec.x3d(i))
ys2.append(sec.y3d(i))
plot(xs2, ys2,color=color[cell-1])
plt.axis('equal')
old_sps =scatter([0],[0],marker='o')
def show_spikes(dt):
global time, old_sps
title(f't = {time} ms')
sps = df.loc[time:time+dt]
old_sps.remove()
scs = scatter(sps.x,sps.y,marker='o', color='k')
old_sps = scs
time +=dt
return []
time = 0
anim = animation.FuncAnimation(fig, show_spikes, frames=[1] + [4]*200)
Writer = animation.writers['ffmpeg']
writer = Writer(fps=15, metadata=dict(artist='NBEL'), bitrate=1800)
anim.save('plexus_SAC_stimulus.mp4', writer=writer)
HTML(anim.to_jshtml())