plt.figure() plt.plot(1e3 * stc.times, stc.data[pick_vertex, :].T * 1e9, 'ro-') plt.xlabel('time (ms)') plt.ylabel('%s value (nAM)' % method) plt.xlim((0, 150)) plt.axhline(0) plt.show() ############################################################################### # Now, let us try to simulate the same with MNE-neuron import os.path as op import hnn_core from hnn_core import simulate_dipole, read_params, Network hnn_core_root = op.dirname(hnn_core.__file__) params_fname = op.join(hnn_core_root, 'param', 'N20.json') params = read_params(params_fname) net = Network(params) dpl = simulate_dipole(net, n_trials=1) import matplotlib.pyplot as plt fig, axes = plt.subplots(2, 1, sharex=True, figsize=(6, 6)) dpl[0].plot(ax=axes[0], show=False) net.plot_input(ax=axes[1]) net.spikes.plot()
net.plot_cells() ############################################################################### # Now let's simulate the dipole, running 2 trials with the Joblib backend. # To run them in parallel we could set n_jobs to equal the number of trials. from hnn_core import JoblibBackend with JoblibBackend(n_jobs=1): dpls = simulate_dipole(net, n_trials=2) ############################################################################### # and then plot it import matplotlib.pyplot as plt fig, axes = plt.subplots(2, 1, sharex=True, figsize=(6, 6)) plot_dipole(dpls, ax=axes[0], layer='agg', show=False) net.plot_input(ax=axes[1]) ############################################################################### # Also, we can plot the spikes and write them to txt files. # Note that we can use formatting syntax to specify the filename pattern # with which each trial will be written. To read spikes back in, we can use # wildcard expressions. net.spikes.plot() with tempfile.TemporaryDirectory() as tmp_dir_name: net.spikes.write(op.join(tmp_dir_name, 'spk_%d.txt')) spikes = read_spikes(op.join(tmp_dir_name, 'spk_*.txt')) spikes.plot() ############################################################################### # Now, let us try to make the exogenous driving inputs to the cells # synchronous and see what happens