def stimonce(self): ''' The function stimulates only once. ''' if self.load_stim_filename is not None: self.stimByteStream = np.load(self.load_stim_filename) else: stim = {} stimlist = SpikeList([],[]) for adr, rate in self.rates: stimlist[adr] = self.sg.poisson_generator(rate=rate, t_stop=self.period*1000.) stim[self.channel] = stimlist if self.seq_export: # translate logical -> physical stimEvents = self.SeqChannelAddress.exportAER(stim,isi=True) else: multi = [] # concatenate events for id, train in stimlist.spiketrains.iteritems(): for i, t in zip(np.repeat(id, len(train.spike_times)), train.spike_times): multi.append([i, t*1000]) # multiplex try: multi = np.r_[multi] multi = multi[np.argsort(multi[:, 1])] multi[:, 1] = np.concatenate([[0], np.diff(multi[:, 1])]) except IndexError: multi = [] # create events instance stimEvents = pyST.events(multi) self.stimByteStream=stimEvents.get_tmadev().tostring() self.stim_sock.send(self.stimByteStream)
def stimonce(self): ''' The function stimulates only once. ''' if self.load_stim_filename is not None: self.stimByteStream = np.load(self.load_stim_filename) else: stim = {} stimlist = SpikeList([], []) for adr, rate in self.rates: stimlist[adr] = self.sg.poisson_generator(rate=rate, t_stop=self.period * 1000.) stim[self.channel] = stimlist if self.seq_export: # translate logical -> physical stimEvents = self.SeqChannelAddress.exportAER(stim, isi=True) else: multi = [] # concatenate events for id, train in stimlist.spiketrains.iteritems(): for i, t in zip(np.repeat(id, len(train.spike_times)), train.spike_times): multi.append([i, t * 1000]) # multiplex try: multi = np.r_[multi] multi = multi[np.argsort(multi[:, 1])] multi[:, 1] = np.concatenate([[0], np.diff(multi[:, 1])]) except IndexError: multi = [] # create events instance stimEvents = pyST.events(multi) self.stimByteStream = stimEvents.get_tmadev().tostring() self.stim_sock.send(self.stimByteStream)
def run(self, stimulus=None, duration=None, context_manager=None): stimulus = pyST.events(stimulus, atype='p') stimulus_abs = stimulus.get_tmadev().astype('float') stimulus_abs[:,1] = np.cumsum(stimulus_abs[:,1])/1e6 if duration == None and len(stimulus)>0: duration = np.max(stimulus_abs[:,1])*1e3 if duration == None: duration = 1. else: duration = float(duration)/1e3 net, M_EIP, MV_EIP = self._prepare_brian_net(stimulus_abs) net.reinit(states=False) print 'running virtual IFLSWTA for {0}s'.format(duration) net.run(duration) sp = np.array(M_EIP.spikes).reshape(-1,2) sp[:,0]+=(2<<13) #slot 2 in text.xml TODO sp[:,1]*=1e6 #slot 2 in text.xml TODO return sp
def run(self, stimulus=None, duration=None, context_manager=None): stimulus_abs = pyST.events(stimulus, atype='p', isISI=True) stimulus_abs.set_abs_tm() self.evn_sin = evs_in = stimulus_abs.get_adtmev().astype('float') evs_in[:,1]*=1e-6 #brian takes seconds if duration == None and len(stimulus_abs)>0: duration = np.max(evs_in[:,1]) print duration elif duration == None: duration = 1. else: duration = float(duration)/1e3 net, M_EIP, MV_EIP = self._prepare_brian_net(evs_in) self.outs = [net, M_EIP, MV_EIP] net.reinit(states=False) print('running virtual IFLSWTA for {0}s'.format(duration)) net.run(duration) sp = np.array(M_EIP.spikes).reshape(-1,2) sp[:,0]+=(2**16) #slot 2 in text.xml. THIS IS A POSSIBLE SOURCE OF TEST ERROR sp[:,1]*=1e6 return sp
def run(self, stimulus=None, duration=None, context_manager=None): stimulus_abs = pyST.events(stimulus, atype='p', isISI=True) stimulus_abs.set_abs_tm() self.evn_sin = evs_in = stimulus_abs.get_adtmev().astype('float') evs_in[:, 1] *= 1e-6 #brian takes seconds if duration == None and len(stimulus_abs) > 0: duration = np.max(evs_in[:, 1]) print duration elif duration == None: duration = 1. else: duration = float(duration) / 1e3 net, M_EIP, MV_EIP = self._prepare_brian_net(evs_in) self.outs = [net, M_EIP, MV_EIP] net.reinit(states=False) print('running virtual IFLSWTA for {0}s'.format(duration)) net.run(duration) sp = np.array(M_EIP.spikes).reshape(-1, 2) sp[:, 0] += ( 2**16 ) #slot 2 in text.xml. THIS IS A POSSIBLE SOURCE OF TEST ERROR sp[:, 1] *= 1e6 return sp