{"id":18595448,"url":"https://github.com/ericjang/pyn","last_synced_at":"2025-04-10T16:31:28.574Z","repository":{"id":5540791,"uuid":"6744515","full_name":"ericjang/pyN","owner":"ericjang","description":"Neuron(s)-based  library in Python using numpy and Blender Game Engine.","archived":false,"fork":false,"pushed_at":"2012-12-13T17:39:20.000Z","size":592,"stargazers_count":6,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T00:42:43.104Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericjang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license_bsd.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-18T07:11:06.000Z","updated_at":"2019-05-18T10:10:57.000Z","dependencies_parsed_at":"2022-07-08T08:11:19.524Z","dependency_job_id":null,"html_url":"https://github.com/ericjang/pyN","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericjang%2FpyN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericjang%2FpyN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericjang%2FpyN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericjang%2FpyN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericjang","download_url":"https://codeload.github.com/ericjang/pyN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248252691,"owners_count":21072701,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T01:19:46.620Z","updated_at":"2025-04-10T16:31:25.654Z","avatar_url":"https://github.com/ericjang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pyN(euron)\n===\n\npyN (pronounced 'pine') is a python module for simulating spiking neural networks.\n\n![Alt text](https://raw.github.com/ericjang/pyN/master/images/spike_freq_adapt_net.png)\n\n#Features:\n\n- Simulate single spiking neurons of various types and complexities (Izhikevich, AdEx, Hodgkin Huxley)\n- Simulate a network of aforementioned neurons.\n- Uses Matplotlib for visualization of results\n- Lightweight : uses as little memory and as much vectorizing as possible to boost performance.\n\n#Tutorial\n\n##Getting Started - Single Neuron simulation:\n\n###1. Create some populations.\nA Population is a group of neurons with the same properties.\n\n```python\nfrom pyN import *\none_neurons = IzhikevichPopulation(name='Charly the Neuron', N=1)\n```\n\n###2. Create a Network and put the Population inside it.\nThe populations parameter takes an array of Populations. You can also create an empty Network and add Populations manually, if you like.\n\n```python\nbrain = Network(populations=[one_neurons])\n```\n###[Optional]: Create some stimuli\n\nIn 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.\n\n```python\nstim = [{'start':10,'stop':100,'mV':14,'neurons':[0]}]\n```\n\n###3. Run the Network\n\n```python\nresults = 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'])\n```\n\n###4. Look at data. Profit.\n\n```python\nshow_data(results)\n```\n\n![Alt text](https://raw.github.com/ericjang/pyN/master/images/single_tonic_spiking.png)\n\n##Recurrent Networks\n\n- If you create a Population with more than one neuron in it, pyN by default recurrently connects the neurons.\n- 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\".\n\n\n##Connecting Populations\nThe brain is composed of many different types of neural populations with different properties.\n\n###Construct two separate populations with different neural properties:\n\n```python\nA = IzhikevichPopulation(name='thalamus', N=100, a=0.02, b=0.2, c=-65, d=6, v0=-70, u0=None)#tonic spiking\nB = IzhikevichPopulation(name='cortex', N=50, a=0.02, b=0.25, c=-55, d=0.05, v0=-70, u0=None)#phasic bursting\n```\n\n###Add Populations to Network and then connect them\n\n```python\nbrain = Network(populations=[A,B])\nbrain.connect(pre='thalamus', post='cortex')\nbrain.connect(pre='cortex', post='thalamus',delay=2.25,std=0.25)#corticothalamic loop longer than thalamocortical loop\n```\n\n###Create stimuli and run the network.\n\n```python\nstim = [{'start':10,'stop':200,'mV':20,'neurons':[0]},{'start':50,'stop':300,'mV':30,'neurons':[i for i in range(3)]}]\nresults = 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'])\nshow_data(results)\n```\n\nNote that if we wanted to stimulate the cortex as well, we merely pass in an additional attribute into the I_ext dictionary.\n\n```python\nI_ext = {'thalamus':stim,'cortex':another_stim}\n```\n\n###Result:\n\n![Alt text](https://raw.github.com/ericjang/pyN/master/images/thalamocortical-driving.png)\n\n\n##Spike-Timing-Dependent Plasticity\n\nIt 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 \u003ccode\u003estdp=False\u003c/code\u003e flag when running the network:\n\n```python\nbrain.simulate(stdp=False)\n```\n\nNote that it takes a fairly large number of repeated spike pairings for STDP weights to take effect.\n\n#Izhikevich Model Parameters:\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eType\u003c/td\u003e\n        \u003ctd\u003eExample\u003c/td\u003e\n        \u003ctd\u003ea\u003c/td\u003e\n        \u003ctd\u003eb\u003c/td\u003e\n        \u003ctd\u003ec\u003c/td\u003e\n        \u003ctd\u003ed\u003c/td\u003e\n        \u003ctd\u003ev0\u003c/td\u003e\n        \u003ctd\u003eu0\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eTonic Spiking\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/tonic_spiking.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.02\u003c/td\u003e\n        \u003ctd\u003e0.2\u003c/td\u003e\n        \u003ctd\u003e-65\u003c/td\u003e\n        \u003ctd\u003e6\u003c/td\u003e\n        \u003ctd\u003e-70\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003ePhasic Spiking\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/phasic_spiking.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.02\u003c/td\u003e\n        \u003ctd\u003e0.25\u003c/td\u003e\n        \u003ctd\u003e-65\u003c/td\u003e\n        \u003ctd\u003e6\u003c/td\u003e\n        \u003ctd\u003e-64\u003c/td\u003e\n        \u003ctd\u003eu0\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eTonic Bursting\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/tonic_bursting.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.02\u003c/td\u003e\n        \u003ctd\u003e0.25\u003c/td\u003e\n        \u003ctd\u003e-50\u003c/td\u003e\n        \u003ctd\u003e2\u003c/td\u003e\n        \u003ctd\u003e-70\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003ePhasic Bursting\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/phasic_bursting.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.02\u003c/td\u003e\n        \u003ctd\u003e0.25\u003c/td\u003e\n        \u003ctd\u003e-55\u003c/td\u003e\n        \u003ctd\u003e0.05\u003c/td\u003e\n        \u003ctd\u003e-70\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eMixed Mode\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/mixed_mode.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.02\u003c/td\u003e\n        \u003ctd\u003e0.2\u003c/td\u003e\n        \u003ctd\u003e-55\u003c/td\u003e\n        \u003ctd\u003e6\u003c/td\u003e\n        \u003ctd\u003e-60\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eSpike Frequency Adaptation\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/spike_freq_adapt.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.01\u003c/td\u003e\n        \u003ctd\u003e0.2\u003c/td\u003e\n        \u003ctd\u003e-65\u003c/td\u003e\n        \u003ctd\u003e8\u003c/td\u003e\n        \u003ctd\u003e-70\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eClass 1 exc.\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/class1_exc.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.02\u003c/td\u003e\n        \u003ctd\u003e-0.1\u003c/td\u003e\n        \u003ctd\u003e-55\u003c/td\u003e\n        \u003ctd\u003e6\u003c/td\u003e\n        \u003ctd\u003e-60\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eClass 2 exc.\u003c/td\u003e\n        \u003ctd\u003e!\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/class2_exc.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.2\u003c/td\u003e\n        \u003ctd\u003e0.26\u003c/td\u003e\n        \u003ctd\u003e-65\u003c/td\u003e\n        \u003ctd\u003e0\u003c/td\u003e\n        \u003ctd\u003e-64\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eSpike Latency\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/spike_latency.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.02\u003c/td\u003e\n        \u003ctd\u003e0.2\u003c/td\u003e\n        \u003ctd\u003e-65\u003c/td\u003e\n        \u003ctd\u003e6\u003c/td\u003e\n        \u003ctd\u003e-70\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eSubthresh. osc.\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/subthresh_osc.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.05\u003c/td\u003e\n        \u003ctd\u003e0.26\u003c/td\u003e\n        \u003ctd\u003e-60\u003c/td\u003e\n        \u003ctd\u003e0\u003c/td\u003e\n        \u003ctd\u003e-62\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eResonator\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/resonator.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.1\u003c/td\u003e\n        \u003ctd\u003e0.26\u003c/td\u003e\n        \u003ctd\u003e-60\u003c/td\u003e\n        \u003ctd\u003e-1\u003c/td\u003e\n        \u003ctd\u003e-62\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eIntegrator\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/integrator.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.02\u003c/td\u003e\n        \u003ctd\u003e-0.1\u003c/td\u003e\n        \u003ctd\u003e-55\u003c/td\u003e\n        \u003ctd\u003e6\u003c/td\u003e\n        \u003ctd\u003e-60\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eRebound Spike\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/rebound_spike.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.03\u003c/td\u003e\n        \u003ctd\u003e0.25\u003c/td\u003e\n        \u003ctd\u003e-60\u003c/td\u003e\n        \u003ctd\u003e4\u003c/td\u003e\n        \u003ctd\u003e-64\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eRebound Burst\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/rebound_burst.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.03\u003c/td\u003e\n        \u003ctd\u003e0.25\u003c/td\u003e\n        \u003ctd\u003e-52\u003c/td\u003e\n        \u003ctd\u003e0\u003c/td\u003e\n        \u003ctd\u003e-64\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eThresh. variability\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/thresh_variability.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.03\u003c/td\u003e\n        \u003ctd\u003e0.25\u003c/td\u003e\n        \u003ctd\u003e-60\u003c/td\u003e\n        \u003ctd\u003e4\u003c/td\u003e\n        \u003ctd\u003e-64\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eBistability\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/bistability.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.1\u003c/td\u003e\n        \u003ctd\u003e0.26\u003c/td\u003e\n        \u003ctd\u003e-60\u003c/td\u003e\n        \u003ctd\u003e0\u003c/td\u003e\n        \u003ctd\u003e-61\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eDAP\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/DAP.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e1\u003c/td\u003e\n        \u003ctd\u003e0.2\u003c/td\u003e\n        \u003ctd\u003e-60\u003c/td\u003e\n        \u003ctd\u003e-21\u003c/td\u003e\n        \u003ctd\u003e-70\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eAccomodation\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/accomodation.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.02\u003c/td\u003e\n        \u003ctd\u003e1\u003c/td\u003e\n        \u003ctd\u003e-55\u003c/td\u003e\n        \u003ctd\u003e4\u003c/td\u003e\n        \u003ctd\u003e-65\u003c/td\u003e\n        \u003ctd\u003e-16\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eInhibition induced spiking\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/inhib_induced_spiking.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e0.02\u003c/td\u003e\n        \u003ctd\u003e-1\u003c/td\u003e\n        \u003ctd\u003e-60\u003c/td\u003e\n        \u003ctd\u003e8\u003c/td\u003e\n        \u003ctd\u003e-63.8\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eInhibition induced bursting\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src='https://raw.github.com/ericjang/pyN/master/images/inhib_induced_bursting.png'\u003e\u003c/td\u003e\n        \u003ctd\u003e-0.026\u003c/td\u003e\n        \u003ctd\u003e-1\u003c/td\u003e\n        \u003ctd\u003e-45\u003c/td\u003e\n        \u003ctd\u003e-\u003c/td\u003e\n        \u003ctd\u003e-63.8\u003c/td\u003e\n        \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n#Adaptive Exponential Integrate-and-Fire Parameters:\n\n\n#Performance:\n  - 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.\n  - It takes ~10 minutes to simulate a single second of activity over 1000 Izhikevich neurons (recurrently connected to each other).\n\n#Other Notes:\n  - Do NOT create a Population with the same name as another Population or it will be overwritten when adding it to a Network.\n\n#License\n\npyN is licensed under BSD.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericjang%2Fpyn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericjang%2Fpyn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericjang%2Fpyn/lists"}