Skip to content
Snippets Groups Projects
Commit c5761842 authored by Simon Oehrl's avatar Simon Oehrl
Browse files

Comment out unnecessary stuff

parent a507be57
No related branches found
No related tags found
No related merge requests found
......@@ -11,11 +11,10 @@ is not structured spatially.
from copy import deepcopy
from math import sqrt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
# import matplotlib.pyplot as plt
import nest
import nest.raster_plot
import nest.topology as tp
......@@ -23,6 +22,7 @@ class Brunel3D:
def __init__(self):
self.layer_dict = {}
nest.SetKernelStatus({"local_num_threads": 1})
nest.Install("streamingmodule")
# nest.SetKernelStatus({'print_time': True})
......@@ -196,70 +196,70 @@ class Brunel3D:
def simulate(self):
nest.Simulate(1000)
def plot_positions(self):
ex_pos = self.layers[0][1]['positions']
in_pos = self.layers[1][1]['positions']
fig = plt.figure()
ax = Axes3D(fig)
for c, m, positions in [('b', 'o', ex_pos), ('r', '^', in_pos)]:
ax.scatter([x for x, y, z in positions],
[y for x, y, z in positions],
[z for x, y, z in positions],
c=c, marker=m)
def get_results(self):
mm = (self.layer_dict['Multimeter'][0] + 1,)
sd = (self.layer_dict['SpikeDetector'][0] + 1,)
mm_status = nest.GetStatus(mm)[0]
sd_status = nest.GetStatus(sd)[0]
nest.raster_plot.from_device(sd, hist=True)
senders = mm_status['events']['senders']
times = mm_status['events']['times']
v_m = mm_status['events']['V_m']
v_th = mm_status['events']['V_th']
step = int(max(senders)/100 + 1) # Only plot results from some GIDs
mm_events = []
for i in range(1, max(senders) + 1, step):
if i in senders:
indices = np.argwhere(senders == i)
mm_events.append({'GID': i,
'times': [times[n] for n in indices],
'V_m': [v_m[n] for n in indices],
'V_th': [v_th[n] for n in indices]})
return {'multimeter': mm_events,
'spike_detector': nest.GetStatus(sd)[0]}
if __name__ == '__main__':
nest.ResetKernel()
print('Making specifications')
brunel = Brunel3D()
brunel.make_layer_specs()
brunel.make_connection_specs()
print('Making layers')
brunel.make_layers()
nest.topology.DumpLayerNodes([l[0] for l in brunel.layer_dict.values()][:2],
'brunel_nodes.txt')
print('Making connections')
brunel.make_connections()
brunel.simulate()
print('Getting results')
brunel.plot_positions()
results = brunel.get_results()
for value in ['V_m', 'V_th']:
plt.figure()
for n in results['multimeter'][::20]:
plt.plot(n['times'], n[value], label='{}'.format(n['GID']))
plt.legend()
plt.title(value)
plt.show()
# def plot_positions(self):
# ex_pos = self.layers[0][1]['positions']
# in_pos = self.layers[1][1]['positions']
# fig = plt.figure()
# ax = Axes3D(fig)
# for c, m, positions in [('b', 'o', ex_pos), ('r', '^', in_pos)]:
# ax.scatter([x for x, y, z in positions],
# [y for x, y, z in positions],
# [z for x, y, z in positions],
# c=c, marker=m)
# def get_results(self):
# mm = (self.layer_dict['Multimeter'][0] + 1,)
# sd = (self.layer_dict['SpikeDetector'][0] + 1,)
# mm_status = nest.GetStatus(mm)[0]
# sd_status = nest.GetStatus(sd)[0]
# nest.raster_plot.from_device(sd, hist=True)
# senders = mm_status['events']['senders']
# times = mm_status['events']['times']
# v_m = mm_status['events']['V_m']
# v_th = mm_status['events']['V_th']
# step = int(max(senders)/100 + 1) # Only plot results from some GIDs
# mm_events = []
# for i in range(1, max(senders) + 1, step):
# if i in senders:
# indices = np.argwhere(senders == i)
# mm_events.append({'GID': i,
# 'times': [times[n] for n in indices],
# 'V_m': [v_m[n] for n in indices],
# 'V_th': [v_th[n] for n in indices]})
# return {'multimeter': mm_events,
# 'spike_detector': nest.GetStatus(sd)[0]}
# if __name__ == '__main__':
# nest.ResetKernel()
# print('Making specifications')
# brunel = Brunel3D()
# brunel.make_layer_specs()
# brunel.make_connection_specs()
# print('Making layers')
# brunel.make_layers()
# nest.topology.DumpLayerNodes([l[0] for l in brunel.layer_dict.values()][:2],
# 'brunel_nodes.txt')
# print('Making connections')
# brunel.make_connections()
# brunel.simulate()
# print('Getting results')
# brunel.plot_positions()
# results = brunel.get_results()
# for value in ['V_m', 'V_th']:
# plt.figure()
# for n in results['multimeter'][::20]:
# plt.plot(n['times'], n[value], label='{}'.format(n['GID']))
# plt.legend()
# plt.title(value)
# plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment