Skip to content
/ pyN Public
forked from ericjang/pyN

Neuron(s)-based library in Python using numpy and Blender Game Engine.

License

Notifications You must be signed in to change notification settings

dunovank/pyN

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyN(euron)

pyN (pronounced 'pine') is a python module for simulating spiking neural networks.

Alt text

#Features:

  • Simulate single spiking neurons of various types and complexities (Izhikevich, AdEx, Hodgkin Huxley)
  • Simulate a network of aforementioned neurons.
  • Uses Matplotlib for visualization of results
  • Lightweight : uses as little memory and as much vectorizing as possible to boost performance.

#Tutorial

##Getting Started - Single Neuron simulation:

###1. Create some populations. A Population is a group of neurons with the same properties.

from pyN import *
one_neurons = IzhikevichPopulation(name='Charly the Neuron', N=1)

###2. Create a Network and put the Population inside it. The populations parameter takes an array of Populations. You can also create an empty Network and add Populations manually, if you like.

brain = Network(populations=[one_neurons])

###[Optional]: Create some stimuli

In order for the neuron to do anything interesting, we need to present it with some externally "injected" current. This is defined by specifying a dictionary of the time interval for a certain voltage to be applied, and which neurons to apply it to. Voltages can stack on top of each other.

stim = [{'start':10,'stop':100,'mV':14,'neurons':[0]}]

###3. Run the Network

results = brain.simulate(experiment_name='Single Neuron exhibiting tonic spiking',T=100,dt=0.25,I_ext={'Charly the Neuron':stim}, save_data='../data/', properties_to_save=['v','u','psc','I_ext'])

###4. Look at data. Profit.

show_data(results)

Alt text

##Recurrent Networks

  • If you create a Population with more than one neuron in it, pyN by default recurrently connects the neurons.
  • Note that in the absense of Hebbian Learning / Spike Adaptation, large networks will exhibit over-saturation of spiking behavior. If the entire network becomes active, it will become unrealistically "epileptic".

##Connecting Populations The brain is composed of many different types of neural populations with different properties.

###Construct two separate populations with different neural properties:

A = IzhikevichPopulation(name='thalamus', N=100, a=0.02, b=0.2, c=-65, d=6, v0=-70, u0=None)#tonic spiking
B = IzhikevichPopulation(name='cortex', N=50, a=0.02, b=0.25, c=-55, d=0.05, v0=-70, u0=None)#phasic bursting

###Add Populations to Network and then connect them

brain = Network(populations=[A,B])
brain.connect(pre='thalamus', post='cortex')
brain.connect(pre='cortex', post='thalamus',delay=2.25,std=0.25)#corticothalamic loop longer than thalamocortical loop

###Create stimuli and run the network.

stim = [{'start':10,'stop':200,'mV':20,'neurons':[0]},{'start':50,'stop':300,'mV':30,'neurons':[i for i in range(3)]}]
results = brain.simulate(experiment_name='Reentrant Thalamocortical Circuit',T=600,dt=0.25, integration_time=30, I_ext={'thalamus':stim}, save_data='../data/', properties_to_save=['v','u','psc','I_ext'])
show_data(results)

Note that if we wanted to stimulate the cortex as well, we merely pass in an additional attribute into the I_ext dictionary.

I_ext = {'thalamus':stim,'cortex':another_stim}

###Result:

Alt text

##Spike-Timing-Dependent Plasticity

It has been proposed that STDP mechanisms act as a biologically plausible substrate to Hebbian Learning. STDP is active by default, but to disable it (for performance reasons, etc.), you can set the stdp=False flag when running the network:

brain.simulate(stdp=False)

Note that it takes a fairly large number of repeated spike pairings for STDP weights to take effect.

#Izhikevich Model Parameters:

Type Example a b c d v0 u0
Tonic Spiking 0.02 0.2 -65 6 -70
Phasic Spiking 0.02 0.25 -65 6 -64 u0
Tonic Bursting 0.02 0.25 -50 2 -70
Phasic Bursting 0.02 0.25 -55 0.05 -70
Mixed Mode 0.02 0.2 -55 6 -60
Spike Frequency Adaptation 0.01 0.2 -65 8 -70
Class 1 exc. 0.02 -0.1 -55 6 -60
Class 2 exc. ! 0.2 0.26 -65 0 -64
Spike Latency 0.02 0.2 -65 6 -70
Subthresh. osc. 0.05 0.26 -60 0 -62
Resonator 0.1 0.26 -60 -1 -62
Integrator 0.02 -0.1 -55 6 -60
Rebound Spike 0.03 0.25 -60 4 -64
Rebound Burst 0.03 0.25 -52 0 -64
Thresh. variability 0.03 0.25 -60 4 -64
Bistability 0.1 0.26 -60 0 -61
DAP 1 0.2 -60 -21 -70
Accomodation 0.02 1 -55 4 -65 -16
Inhibition induced spiking 0.02 -1 -60 8 -63.8
Inhibition induced bursting -0.026 -1 -45 - -63.8

#Adaptive Exponential Integrate-and-Fire Parameters:

#Performance:

  • Although pyN is biologically realistic and matrix calculations are vectorized, it is still dreadfully slow due to numerical integration techniques used when convolving spike deltas with exponential decay currents.
  • It takes ~10 minutes to simulate a single second of activity over 1000 Izhikevich neurons (recurrently connected to each other).

#Other Notes:

  • Do NOT create a Population with the same name as another Population or it will be overwritten when adding it to a Network.

#License

pyN is licensed under BSD.

About

Neuron(s)-based library in Python using numpy and Blender Game Engine.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%