In [1]:
import pyNN.neuron as p
p.setup(timestep=0.1, quit_on_end=False)
In [2]:
FileNames_byPeak = ('data/by_peak_SNR/bootstrap_joe093-3-C3-MO.mat',
'data/by_peak_SNR/bootstrap_joe145-4-C3-MO.mat',
'data/by_peak_SNR/bootstrap_joe112-5-C3-MO.mat',
'data/by_peak_SNR/bootstrap_joe112-6-C3-MO.mat',
'data/by_peak_SNR/bootstrap_joe108-7-C3-MO.mat')
'''
5 neurons selected by peak SNR
time offset: 'Movement Onset' at time 0
'''
Out[2]:
In [3]:
import scipy.io
''' 6 neurons selected by average SNR
** DATA FORMAT **
one file - one neuron
Example:
data/TS_by_avg_SNRbootstrap_joe115-2-C1-TS.mat
monkey: joe
session: 115
neuron: 2
condition: C1
TS: trial start
Each file stores 6 directions
Within each direction there are 35 trials
* TEMPORAL STRUCTURE *
trial start (t=0ms)
cue (t=500ms)
go (t=1500ms)
movement onset (MO)
movemenr end (ME)
'''
# Load Data
FileNames = ('data/TS_by_avg_SNRbootstrap_joe115-2-C1-TS.mat',
'data/TS_by_avg_SNRbootstrap_joe115-3-C1-TS.mat',
'data/TS_by_avg_SNRbootstrap_joe149-4-C1-TS.mat',
'data/TS_by_avg_SNRbootstrap_joe096-5-C1-TS.mat',
'data/TS_by_avg_SNRbootstrap_joe110-5-C1-TS.mat',
'data/TS_by_avg_SNRbootstrap_joe113-6-C1-TS.mat')
# Data is a list with an item for every neuron
data = [scipy.io.loadmat(filename, squeeze_me = True)['GDFcell'].tolist() for filename in FileNames]
In [4]:
# Parameters
N = 6 #number of neurons in input population
Ntrials = 35 #1-25 Training, 26-35 Testing
Ndirections = 6
# Select Data
direction = 1
trial = 1
In [5]:
spikes_one_direction = [dat[direction] for dat in data]
# Spike Times is a list with an item for every neuron
# The items are list of spiketimes for selected direction and trial
spike_times = [spikes[spikes[:,0] == trial][:,1] for spikes in spikes_one_direction]
In [6]:
# Define Population
inpop = p.Population(N, cellclass=p.SpikeSourceArray)
L1 = p.Population(N, cellclass=p.IF_cond_exp)
L1.record()
L1.record_v()
# Load Spike times into the input population
for neuron,times in zip(inpop,spike_times):
neuron.spike_times = sort(times)
In [7]:
inpop[0].spike_times
Out[7]:
In [160]:
# connections
prj = p.Projection(inpop, L1, target="excitatory", method=p.OneToOneConnector())
prj.setWeights(0.1)
In [161]:
# run sim
p.reset()
p.run(2000)
Out[161]:
In [162]:
# get recordings
vL1dat = L1.get_v()
time = vL1dat[:,1].reshape(N,-1)[0]
VL1 = vL1dat[:,2].reshape(N,-1).T
L1_spikes = L1.getSpikes()
In [163]:
# plot
subplot(2,1,1)
plot(time, VL1)
ylabel('post1: V[mV]')
subplot(2,1,2)
plot(L1_spikes[:,1], L1_spikes[:,0],'.')
Out[163]: