v[:,t] += stimulation_pattern[:,t] + afferent_activation_pattern[:,t] v[:,t] = sgn(v[:,t]) #---Debugging if debugging: print '------------' print 'Unit %d selected, corresponding to %s'%(idx[t],area[idx[t]]) print 'Kernel: ',M[:,idx[t]] print 'Network activity: ', v[:,t-1] print 'Stimulation pattern: ', stimulation_pattern[idx[t],t] print 'Total input %.02f'%I[5] print 'Probability: %.02f, threshold:%.02f'%(F(I[idx[t]]),threshold[t]) print 'Acitvity %d -> %d'%(v[idx[t],t-1],v[idx[t],t]) print '--------' #--- ''' with open('pain-v.tsv','wb') as f: writer = csv.writer(f) for row_title,data_row in zip(area_names,v.T): writer.writerow([row_title] + data_row.tolist()) ''' np.savetxt('pain-v-spine-spare.tsv',v,fmt='%.04f',delimiter='\t', header='\t'.join(area_names), comments='') artist.raster_plot(v,filename='../results/pain',duration=[params['duration']['interpattern' if 'interpattern' in condition else 'pattern'] for condition in pattern_], parasite_labels=[condition if 'interpattern' not in condition else '' for condition in pattern_], axes_labels = area_names) artist.firing_rate_plot(v,filename='../results/pain_rate',duration=[params['duration']['interpattern' if 'interpattern' in condition else 'pattern'] for condition in pattern_], parasite_labels=[condition if 'interpattern' not in condition else '' for condition in pattern_])
F = lambda current: 1./(1+np.exp(-current)) debugging=False for t in range(1,total_duration): # Determine the state of unit idx[t] at time t I = afferent_activation_pattern[:,t]#*v[:,t] # Afferent activation I[idx[t]] += M[:,idx[t]].dot(v[:,t-1])+stimulation_pattern[idx[t],t] #Target inhibition #Stochastically update the state of unit idx[t] v[idx[t],t] = 1 if F(I[idx[t]]) > threshold[t] else -1 v[:,t] += stimulation_pattern[:,t] + afferent_activation_pattern[:,t] v[:,t] = sgn(v[:,t]) #---Debugging if debugging: print '------------' print 'Unit %d selected, corresponding to %s'%(idx[t],area[idx[t]]) print 'Kernel: ',M[:,idx[t]] print 'Network activity: ', v[:,t-1] print 'Stimulation pattern: ', stimulation_pattern[idx[t],t] print 'Total input %.02f'%I[5] print 'Probability: %.02f, threshold:%.02f'%(F(I[idx[t]]),threshold[t]) print 'Acitvity %d -> %d'%(v[idx[t],t-1],v[idx[t],t]) print '--------' #--- artist.raster_plot(v,duration=[params['duration']['interpattern' if 'interpattern' in condition else 'pattern'] for condition in pattern_]) # parasite_labels=[condition if 'interpattern' not in condition else '' for condition in pattern_]) artist.firing_rate_plot(v,duration=[params['duration']['interpattern' if 'interpattern' in condition else 'pattern'] for condition in pattern_], parasite_labels=[condition if 'interpattern' not in condition else '' for condition in pattern_])