diff --git a/doc/tutorials/sequences/sequences.ipynb b/doc/tutorials/sequences/sequences.ipynb index edcca73a9..4a81e65c4 100644 --- a/doc/tutorials/sequences/sequences.ipynb +++ b/doc/tutorials/sequences/sequences.ipynb @@ -25,6 +25,14 @@ "execution_count": 1, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/charl/.local/lib/python3.11/site-packages/matplotlib/projections/__init__.py:63: UserWarning: Unable to import Axes3D. This may be due to multiple versions of Matplotlib being installed (e.g. as a system package and as a pip package). As a result, the 3D projection is not available.\n", + " warnings.warn(\"Unable to import Axes3D. This may be due to multiple versions of \"\n" + ] + }, { "name": "stdout", "output_type": "stream", @@ -33,8 +41,8 @@ " -- N E S T --\n", " Copyright (C) 2004 The NEST Initiative\n", "\n", - " Version: 3.6.0-post0.dev0\n", - " Built: Feb 5 2024 05:39:31\n", + " Version: 3.5.0-rc1\n", + " Built: Feb 21 2024 09:04:08\n", "\n", " This program is provided AS IS and comes with\n", " NO WARRANTY. See the file LICENSE for details.\n", @@ -45,14 +53,6 @@ " Type 'nest.help()' to find out more about NEST.\n", "\n" ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/charl/.local/lib/python3.11/site-packages/matplotlib/projections/__init__.py:63: UserWarning: Unable to import Axes3D. This may be due to multiple versions of Matplotlib being installed (e.g. as a system package and as a pip package). As a result, the 3D projection is not available.\n", - " warnings.warn(\"Unable to import Axes3D. This may be due to multiple versions of \"\n" - ] } ], "source": [ @@ -78,7 +78,6 @@ "# plt.rcParams['text.usetex'] = False\n", "\n", "\n", - "\n", "import matplotlib.pyplot as plt\n", "import nest\n", "import numpy as np\n", @@ -86,6 +85,14 @@ "import random\n", "import re\n", "\n", + "import parameters as para\n", + "\n", + "import shtm\n", + "import shtm.model\n", + "import shtm.helper\n", + "import copy\n", + "import time\n", + "\n", "from pynestml.codegeneration.nest_code_generator_utils import NESTCodeGeneratorUtils\n", "from pynestml.codegeneration.nest_tools import NESTTools" ] @@ -103,441 +110,41 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Automatic pdb calling has been turned ON\n", - "[1,GLOBAL, INFO]: List of files that will be processed:\n", - "[2,GLOBAL, INFO]: /home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron.nestml\n", - "[3,GLOBAL, INFO]: Target platform code will be generated in directory: '/home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target'\n", - "[4,GLOBAL, INFO]: Target platform code will be installed in directory: '/tmp/nestml_target_5b0k1g20'\n", - "\n", - " -- N E S T --\n", - " Copyright (C) 2004 The NEST Initiative\n", - "\n", - " Version: 3.6.0-post0.dev0\n", - " Built: Feb 5 2024 05:39:31\n", - "\n", - " This program is provided AS IS and comes with\n", - " NO WARRANTY. See the file LICENSE for details.\n", - "\n", - " Problems or suggestions?\n", - " Visit https://www.nest-simulator.org\n", - "\n", - " Type 'nest.help()' to find out more about NEST.\n", - "\n", - "[5,GLOBAL, INFO]: The NEST Simulator version was automatically detected as: master\n", - "[6,GLOBAL, INFO]: Given template root path is not an absolute path. Creating the absolute path with default templates directory '/home/charl/julich/nestml-fork-clopath_synapse/nestml/pynestml/codegeneration/resources_nest/point_neuron'\n", - "[7,GLOBAL, INFO]: Given template root path is not an absolute path. Creating the absolute path with default templates directory '/home/charl/julich/nestml-fork-clopath_synapse/nestml/pynestml/codegeneration/resources_nest/point_neuron'\n", - "[8,GLOBAL, INFO]: Given template root path is not an absolute path. Creating the absolute path with default templates directory '/home/charl/julich/nestml-fork-clopath_synapse/nestml/pynestml/codegeneration/resources_nest/point_neuron'\n", - "[9,GLOBAL, INFO]: The NEST Simulator installation path was automatically detected as: /home/charl/julich/nest-simulator-install\n", - "[10,GLOBAL, INFO]: Start processing '/home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron.nestml'!\n", - "[11,iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml, DEBUG, [1:0;93:0]]: Start building symbol table!\n", - "[12,iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml, INFO, [23:15;23:26]]: Implicit magnitude conversion from mV / ms to pA / pF with factor 1.0 \n", - "[13,iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml, DEBUG, [1:0;93:0]]: Start building symbol table!\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:Analysing input:\n", - "INFO:{\n", - " \"dynamics\": [\n", - " {\n", - " \"expression\": \"V_m' = (-(V_m - E_L)) / tau_m + (I_kernel1__X__I_1 * 1.0 + (I_kernel2__X__I_2 * 1.0) + I_kernel3__X__I_3 * 1.0 + I_e) / C_m\",\n", - " \"initial_values\": {\n", - " \"V_m\": \"0\"\n", - " }\n", - " },\n", - " {\n", - " \"expression\": \"dAP_trace' = (-dAP_trace) / tau_h\",\n", - " \"initial_values\": {\n", - " \"dAP_trace\": \"0\"\n", - " }\n", - " },\n", - " {\n", - " \"expression\": \"I_kernel1__X__I_1 = exp(-1 / tau_syn1 * t)\",\n", - " \"initial_values\": {}\n", - " },\n", - " {\n", - " \"expression\": \"I_kernel2__X__I_2 = (e / tau_syn2) * t * exp(-t / tau_syn2)\",\n", - " \"initial_values\": {}\n", - " },\n", - " {\n", - " \"expression\": \"I_kernel3__X__I_3 = exp(-1 / tau_syn3 * t)\",\n", - " \"initial_values\": {}\n", - " }\n", - " ],\n", - " \"options\": {\n", - " \"output_timestep_symbol\": \"__h\"\n", - " },\n", - " \"parameters\": {\n", - " \"C_m\": \"250\",\n", - " \"E_L\": \"0\",\n", - " \"I_e\": \"0\",\n", - " \"I_p\": \"250\",\n", - " \"V_reset\": \"0\",\n", - " \"V_th\": \"25\",\n", - " \"dAP_timeout_ticks\": \"steps(tau_dAP)\",\n", - " \"ref_timeout_ticks\": \"steps(t_ref)\",\n", - " \"t_ref\": \"10\",\n", - " \"tau_dAP\": \"60\",\n", - " \"tau_h\": \"400\",\n", - " \"tau_m\": \"20\",\n", - " \"tau_syn1\": \"10\",\n", - " \"tau_syn2\": \"10\",\n", - " \"tau_syn3\": \"10\",\n", - " \"theta_dAP\": \"60\"\n", - " }\n", - "}\n", - "INFO:Processing global options...\n", - "INFO:Processing input shapes...\n", - "INFO:\n", - "Processing differential-equation form shape V_m with defining expression = \"(-(V_m - E_L)) / tau_m + (I_kernel1__X__I_1 * 1.0 + (I_kernel2__X__I_2 * 1.0) + I_kernel3__X__I_3 * 1.0 + I_e) / C_m\"\n", - "DEBUG:Splitting expression (E_L - V_m)/tau_m + (I_e + 1.0*I_kernel1__X__I_1 + 1.0*I_kernel2__X__I_2 + 1.0*I_kernel3__X__I_3)/C_m (symbols [V_m])\n", - "DEBUG:\tlinear factors: Matrix([[-1/tau_m]])\n", - "DEBUG:\tinhomogeneous term: E_L/tau_m + I_e/C_m\n", - "DEBUG:\tnonlinear term: 1.0*I_kernel1__X__I_1/C_m + 1.0*I_kernel2__X__I_2/C_m + 1.0*I_kernel3__X__I_3/C_m\n", - "DEBUG:Created Shape with symbol V_m, derivative_factors = [-1/tau_m], inhom_term = E_L/tau_m + I_e/C_m, nonlin_term = 1.0*I_kernel1__X__I_1/C_m + 1.0*I_kernel2__X__I_2/C_m + 1.0*I_kernel3__X__I_3/C_m\n", - "INFO:\tReturning shape: Shape \"V_m\" of order 1\n", - "INFO:Shape V_m: reconstituting expression E_L/tau_m - V_m/tau_m + I_e/C_m + 1.0*I_kernel1__X__I_1/C_m + 1.0*I_kernel2__X__I_2/C_m + 1.0*I_kernel3__X__I_3/C_m\n", - "INFO:\n", - "Processing differential-equation form shape dAP_trace with defining expression = \"(-dAP_trace) / tau_h\"\n", - "DEBUG:Splitting expression -dAP_trace/tau_h (symbols [dAP_trace])\n", - "DEBUG:\tlinear factors: Matrix([[-1/tau_h]])\n", - "DEBUG:\tinhomogeneous term: 0.0\n", - "DEBUG:\tnonlinear term: 0.0\n", - "DEBUG:Created Shape with symbol dAP_trace, derivative_factors = [-1/tau_h], inhom_term = 0.0, nonlin_term = 0.0\n", - "INFO:\tReturning shape: Shape \"dAP_trace\" of order 1\n", - "INFO:Shape dAP_trace: reconstituting expression -dAP_trace/tau_h\n", - "INFO:\n", - "Processing function-of-time shape \"I_kernel1__X__I_1\" with defining expression = \"exp(-t/tau_syn1)\"\n", - "DEBUG:Found t: 0\n", - "DEBUG:\tFinding ode for order 1...\n", - "DEBUG:Shape satisfies ODE of order = 1\n", - "DEBUG:Created Shape with symbol I_kernel1__X__I_1, derivative_factors = [-1/tau_syn1], inhom_term = 0.0, nonlin_term = 0.0\n", - "INFO:Shape I_kernel1__X__I_1: reconstituting expression -I_kernel1__X__I_1/tau_syn1\n", - "INFO:\n", - "Processing function-of-time shape \"I_kernel2__X__I_2\" with defining expression = \"e*t*exp(-t/tau_syn2)/tau_syn2\"\n", - "DEBUG:Found t: 1\n", - "DEBUG:\tFinding ode for order 1...\n", - "DEBUG:\tFinding ode for order 2...\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[14,GLOBAL, INFO]: Analysing/transforming model 'iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml'\n", - "[15,iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml, INFO, [1:0;93:0]]: Starts processing of the model 'iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml'\n" + "Automatic pdb calling has been turned ON\n" ] }, { - "name": "stderr", - "output_type": "stream", - "text": [ - "DEBUG:\tchecking whether shape definition is satisfied...\n", - "DEBUG:Shape satisfies ODE of order = 2\n", - "DEBUG:Created Shape with symbol I_kernel2__X__I_2, derivative_factors = Matrix([[-1/tau_syn2**2], [-2/tau_syn2]]), inhom_term = 0.0, nonlin_term = 0.0\n", - "INFO:Shape I_kernel2__X__I_2: reconstituting expression -I_kernel2__X__I_2/tau_syn2**2 - 2*I_kernel2__X__I_2__d/tau_syn2\n", - "INFO:\n", - "Processing function-of-time shape \"I_kernel3__X__I_3\" with defining expression = \"exp(-t/tau_syn3)\"\n", - "DEBUG:Found t: 0\n", - "DEBUG:\tFinding ode for order 1...\n", - "DEBUG:Shape satisfies ODE of order = 1\n", - "DEBUG:Created Shape with symbol I_kernel3__X__I_3, derivative_factors = [-1/tau_syn3], inhom_term = 0.0, nonlin_term = 0.0\n", - "INFO:Shape I_kernel3__X__I_3: reconstituting expression -I_kernel3__X__I_3/tau_syn3\n", - "INFO:All known variables: [V_m, dAP_trace, I_kernel1__X__I_1, I_kernel2__X__I_2, I_kernel2__X__I_2', I_kernel3__X__I_3], all parameters used in ODEs: {C_m, tau_syn1, tau_syn2, tau_syn3, tau_m, E_L, tau_h, I_e}\n", - "INFO:\n", - "Processing differential-equation form shape V_m with defining expression = \"(-(V_m - E_L)) / tau_m + (I_kernel1__X__I_1 * 1.0 + (I_kernel2__X__I_2 * 1.0) + I_kernel3__X__I_3 * 1.0 + I_e) / C_m\"\n", - "DEBUG:Splitting expression (E_L - V_m)/tau_m + (I_e + 1.0*I_kernel1__X__I_1 + 1.0*I_kernel2__X__I_2 + 1.0*I_kernel3__X__I_3)/C_m (symbols [V_m, dAP_trace, I_kernel1__X__I_1, I_kernel2__X__I_2, I_kernel2__X__I_2__d, I_kernel3__X__I_3, V_m])\n", - "DEBUG:\tlinear factors: Matrix([[-1/tau_m], [0], [1.0/C_m], [1.0/C_m], [0], [1.0/C_m], [0]])\n", - "DEBUG:\tinhomogeneous term: E_L/tau_m + I_e/C_m\n", - "DEBUG:\tnonlinear term: 0.0\n", - "DEBUG:Created Shape with symbol V_m, derivative_factors = [-1/tau_m], inhom_term = E_L/tau_m + I_e/C_m, nonlin_term = 1.0*I_kernel1__X__I_1/C_m + 1.0*I_kernel2__X__I_2/C_m + 1.0*I_kernel3__X__I_3/C_m\n", - "INFO:\tReturning shape: Shape \"V_m\" of order 1\n", - "INFO:\n", - "Processing differential-equation form shape dAP_trace with defining expression = \"(-dAP_trace) / tau_h\"\n", - "DEBUG:Splitting expression -dAP_trace/tau_h (symbols [V_m, dAP_trace, I_kernel1__X__I_1, I_kernel2__X__I_2, I_kernel2__X__I_2__d, I_kernel3__X__I_3, V_m, dAP_trace])\n", - "DEBUG:\tlinear factors: Matrix([[0], [-1/tau_h], [0], [0], [0], [0], [0], [0]])\n", - "DEBUG:\tinhomogeneous term: 0.0\n", - "DEBUG:\tnonlinear term: 0.0\n", - "DEBUG:Created Shape with symbol dAP_trace, derivative_factors = [-1/tau_h], inhom_term = 0.0, nonlin_term = 0\n", - "INFO:\tReturning shape: Shape \"dAP_trace\" of order 1\n", - "INFO:\n", - "Processing function-of-time shape \"I_kernel1__X__I_1\" with defining expression = \"exp(-t/tau_syn1)\"\n", - "DEBUG:Found t: 0\n", - "DEBUG:\tFinding ode for order 1...\n", - "DEBUG:Shape satisfies ODE of order = 1\n", - "DEBUG:Created Shape with symbol I_kernel1__X__I_1, derivative_factors = [-1/tau_syn1], inhom_term = 0.0, nonlin_term = 0.0\n", - "INFO:\n", - "Processing function-of-time shape \"I_kernel2__X__I_2\" with defining expression = \"e*t*exp(-t/tau_syn2)/tau_syn2\"\n", - "DEBUG:Found t: 1\n", - "DEBUG:\tFinding ode for order 1...\n", - "DEBUG:\tFinding ode for order 2...\n", - "DEBUG:\tchecking whether shape definition is satisfied...\n", - "DEBUG:Shape satisfies ODE of order = 2\n", - "DEBUG:Created Shape with symbol I_kernel2__X__I_2, derivative_factors = Matrix([[-1/tau_syn2**2], [-2/tau_syn2]]), inhom_term = 0.0, nonlin_term = 0.0\n", - "INFO:\n", - "Processing function-of-time shape \"I_kernel3__X__I_3\" with defining expression = \"exp(-t/tau_syn3)\"\n", - "DEBUG:Found t: 0\n", - "DEBUG:\tFinding ode for order 1...\n", - "DEBUG:Shape satisfies ODE of order = 1\n", - "DEBUG:Created Shape with symbol I_kernel3__X__I_3, derivative_factors = [-1/tau_syn3], inhom_term = 0.0, nonlin_term = 0.0\n", - "INFO:Shape V_m: reconstituting expression E_L/tau_m - V_m/tau_m + I_e/C_m + 1.0*I_kernel1__X__I_1/C_m + 1.0*I_kernel2__X__I_2/C_m + 1.0*I_kernel3__X__I_3/C_m\n", - "DEBUG:Splitting expression E_L/tau_m - V_m/tau_m + I_e/C_m + 1.0*I_kernel1__X__I_1/C_m + 1.0*I_kernel2__X__I_2/C_m + 1.0*I_kernel3__X__I_3/C_m (symbols Matrix([[V_m], [dAP_trace], [I_kernel1__X__I_1], [I_kernel2__X__I_2], [I_kernel2__X__I_2__d], [I_kernel3__X__I_3]]))\n", - "DEBUG:\tlinear factors: Matrix([[-1/tau_m], [0], [1.0/C_m], [1.0/C_m], [0], [1.0/C_m]])\n", - "DEBUG:\tinhomogeneous term: E_L/tau_m + I_e/C_m\n", - "DEBUG:\tnonlinear term: 0.0\n", - "INFO:Shape dAP_trace: reconstituting expression -dAP_trace/tau_h\n", - "DEBUG:Splitting expression -dAP_trace/tau_h (symbols Matrix([[V_m], [dAP_trace], [I_kernel1__X__I_1], [I_kernel2__X__I_2], [I_kernel2__X__I_2__d], [I_kernel3__X__I_3]]))\n", - "DEBUG:\tlinear factors: Matrix([[0], [-1/tau_h], [0], [0], [0], [0]])\n", - "DEBUG:\tinhomogeneous term: 0.0\n", - "DEBUG:\tnonlinear term: 0.0\n", - "INFO:Shape I_kernel1__X__I_1: reconstituting expression -I_kernel1__X__I_1/tau_syn1\n", - "DEBUG:Splitting expression -I_kernel1__X__I_1/tau_syn1 (symbols Matrix([[V_m], [dAP_trace], [I_kernel1__X__I_1], [I_kernel2__X__I_2], [I_kernel2__X__I_2__d], [I_kernel3__X__I_3]]))\n", - "DEBUG:\tlinear factors: Matrix([[0], [0], [-1/tau_syn1], [0], [0], [0]])\n", - "DEBUG:\tinhomogeneous term: 0.0\n", - "DEBUG:\tnonlinear term: 0.0\n", - "INFO:Shape I_kernel2__X__I_2: reconstituting expression -I_kernel2__X__I_2/tau_syn2**2 - 2*I_kernel2__X__I_2__d/tau_syn2\n", - "DEBUG:Splitting expression -I_kernel2__X__I_2/tau_syn2**2 - 2*I_kernel2__X__I_2__d/tau_syn2 (symbols Matrix([[V_m], [dAP_trace], [I_kernel1__X__I_1], [I_kernel2__X__I_2], [I_kernel2__X__I_2__d], [I_kernel3__X__I_3]]))\n", - "DEBUG:\tlinear factors: Matrix([[0], [0], [0], [-1/tau_syn2**2], [-2/tau_syn2], [0]])\n", - "DEBUG:\tinhomogeneous term: 0.0\n", - "DEBUG:\tnonlinear term: 0.0\n", - "INFO:Shape I_kernel3__X__I_3: reconstituting expression -I_kernel3__X__I_3/tau_syn3\n", - "DEBUG:Splitting expression -I_kernel3__X__I_3/tau_syn3 (symbols Matrix([[V_m], [dAP_trace], [I_kernel1__X__I_1], [I_kernel2__X__I_2], [I_kernel2__X__I_2__d], [I_kernel3__X__I_3]]))\n", - "DEBUG:\tlinear factors: Matrix([[0], [0], [0], [0], [0], [-1/tau_syn3]])\n", - "DEBUG:\tinhomogeneous term: 0.0\n", - "DEBUG:\tnonlinear term: 0.0\n", - "DEBUG:Initializing system of shapes with x = Matrix([[V_m], [dAP_trace], [I_kernel1__X__I_1], [I_kernel2__X__I_2], [I_kernel2__X__I_2__d], [I_kernel3__X__I_3]]), A = Matrix([[-1/tau_m, 0, 1.0/C_m, 1.0/C_m, 0, 1.0/C_m], [0, -1/tau_h, 0, 0, 0, 0], [0, 0, -1/tau_syn1, 0, 0, 0], [0, 0, 0, 0, 1.00000000000000, 0], [0, 0, 0, -1/tau_syn2**2, -2/tau_syn2, 0], [0, 0, 0, 0, 0, -1/tau_syn3]]), b = Matrix([[E_L/tau_m + I_e/C_m], [0.0], [0.0], [0], [0.0], [0.0]]), c = Matrix([[0.0], [0.0], [0.0], [0], [0.0], [0.0]])\n", - "INFO:Finding analytically solvable equations...\n", - "INFO:Saving dependency graph plot to /tmp/ode_dependency_graph.dot\n", - "DEBUG:os.makedirs('/tmp')\n", - "DEBUG:write lines to '/tmp/ode_dependency_graph.dot'\n", - "DEBUG:run [PosixPath('dot'), '-Kdot', '-Tpdf', '-O', 'ode_dependency_graph.dot']\n", - "INFO:Shape V_m: reconstituting expression E_L/tau_m - V_m/tau_m + I_e/C_m + 1.0*I_kernel1__X__I_1/C_m + 1.0*I_kernel2__X__I_2/C_m + 1.0*I_kernel3__X__I_3/C_m\n", - "DEBUG:Splitting expression E_L/tau_m - V_m/tau_m + I_e/C_m + 1.0*I_kernel1__X__I_1/C_m + 1.0*I_kernel2__X__I_2/C_m + 1.0*I_kernel3__X__I_3/C_m (symbols [V_m, dAP_trace, I_kernel1__X__I_1, I_kernel2__X__I_2, I_kernel2__X__I_2__d, I_kernel3__X__I_3])\n", - "DEBUG:\tlinear factors: Matrix([[-1/tau_m], [0], [1.0/C_m], [1.0/C_m], [0], [1.0/C_m]])\n", - "DEBUG:\tinhomogeneous term: E_L/tau_m + I_e/C_m\n", - "DEBUG:\tnonlinear term: 0.0\n", - "INFO:Shape dAP_trace: reconstituting expression -dAP_trace/tau_h\n", - "DEBUG:Splitting expression -dAP_trace/tau_h (symbols [V_m, dAP_trace, I_kernel1__X__I_1, I_kernel2__X__I_2, I_kernel2__X__I_2__d, I_kernel3__X__I_3])\n", - "DEBUG:\tlinear factors: Matrix([[0], [-1/tau_h], [0], [0], [0], [0]])\n", - "DEBUG:\tinhomogeneous term: 0.0\n", - "DEBUG:\tnonlinear term: 0.0\n", - "INFO:Shape I_kernel1__X__I_1: reconstituting expression -I_kernel1__X__I_1/tau_syn1\n", - "DEBUG:Splitting expression -I_kernel1__X__I_1/tau_syn1 (symbols [V_m, dAP_trace, I_kernel1__X__I_1, I_kernel2__X__I_2, I_kernel2__X__I_2__d, I_kernel3__X__I_3])\n", - "DEBUG:\tlinear factors: Matrix([[0], [0], [-1/tau_syn1], [0], [0], [0]])\n", - "DEBUG:\tinhomogeneous term: 0.0\n", - "DEBUG:\tnonlinear term: 0.0\n", - "INFO:Shape I_kernel2__X__I_2: reconstituting expression -I_kernel2__X__I_2/tau_syn2**2 - 2*I_kernel2__X__I_2__d/tau_syn2\n", - "DEBUG:Splitting expression -I_kernel2__X__I_2/tau_syn2**2 - 2*I_kernel2__X__I_2__d/tau_syn2 (symbols [V_m, dAP_trace, I_kernel1__X__I_1, I_kernel2__X__I_2, I_kernel2__X__I_2__d, I_kernel3__X__I_3])\n", - "DEBUG:\tlinear factors: Matrix([[0], [0], [0], [-1/tau_syn2**2], [-2/tau_syn2], [0]])\n", - "DEBUG:\tinhomogeneous term: 0.0\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "DEBUG:\tnonlinear term: 0.0\n", - "INFO:Shape I_kernel3__X__I_3: reconstituting expression -I_kernel3__X__I_3/tau_syn3\n", - "DEBUG:Splitting expression -I_kernel3__X__I_3/tau_syn3 (symbols [V_m, dAP_trace, I_kernel1__X__I_1, I_kernel2__X__I_2, I_kernel2__X__I_2__d, I_kernel3__X__I_3])\n", - "DEBUG:\tlinear factors: Matrix([[0], [0], [0], [0], [0], [-1/tau_syn3]])\n", - "DEBUG:\tinhomogeneous term: 0.0\n", - "DEBUG:\tnonlinear term: 0.0\n", - "INFO:Saving dependency graph plot to /tmp/ode_dependency_graph_analytically_solvable_before_propagated.dot\n", - "DEBUG:os.makedirs('/tmp')\n", - "DEBUG:write lines to '/tmp/ode_dependency_graph_analytically_solvable_before_propagated.dot'\n", - "DEBUG:run [PosixPath('dot'), '-Kdot', '-Tpdf', '-O', 'ode_dependency_graph_analytically_solvable_before_propagated.dot']\n", - "INFO:Saving dependency graph plot to /tmp/ode_dependency_graph_analytically_solvable.dot\n", - "DEBUG:os.makedirs('/tmp')\n", - "DEBUG:write lines to '/tmp/ode_dependency_graph_analytically_solvable.dot'\n", - "DEBUG:run [PosixPath('dot'), '-Kdot', '-Tpdf', '-O', 'ode_dependency_graph_analytically_solvable.dot']\n", - "INFO:Generating propagators for the following symbols: V_m, dAP_trace, I_kernel1__X__I_1, I_kernel2__X__I_2, I_kernel2__X__I_2__d, I_kernel3__X__I_3\n", - "DEBUG:Initializing system of shapes with x = Matrix([[V_m], [dAP_trace], [I_kernel1__X__I_1], [I_kernel2__X__I_2], [I_kernel2__X__I_2__d], [I_kernel3__X__I_3]]), A = Matrix([[-1/tau_m, 0, 1.0/C_m, 1.0/C_m, 0, 1.0/C_m], [0, -1/tau_h, 0, 0, 0, 0], [0, 0, -1/tau_syn1, 0, 0, 0], [0, 0, 0, 0, 1.00000000000000, 0], [0, 0, 0, -1/tau_syn2**2, -2/tau_syn2, 0], [0, 0, 0, 0, 0, -1/tau_syn3]]), b = Matrix([[E_L/tau_m + I_e/C_m], [0.0], [0.0], [0], [0.0], [0.0]]), c = Matrix([[0], [0], [0], [0], [0], [0]])\n", - "WARNING:Under certain conditions, the propagator matrix is singular (contains infinities).\n", - "WARNING:List of all conditions that result in a singular propagator:\n", - "WARNING:\ttau_m = tau_syn1\n", - "WARNING:\ttau_m = tau_syn2\n", - "WARNING:\ttau_m = tau_syn3\n", - "DEBUG:System of equations:\n", - "DEBUG:x = Matrix([[V_m], [dAP_trace], [I_kernel1__X__I_1], [I_kernel2__X__I_2], [I_kernel2__X__I_2__d], [I_kernel3__X__I_3]])\n", - "DEBUG:A = Matrix([\n", - "[-1/tau_m, 0, 1.0/C_m, 1.0/C_m, 0, 1.0/C_m],\n", - "[ 0, -1/tau_h, 0, 0, 0, 0],\n", - "[ 0, 0, -1/tau_syn1, 0, 0, 0],\n", - "[ 0, 0, 0, 0, 1.0, 0],\n", - "[ 0, 0, 0, -1/tau_syn2**2, -2/tau_syn2, 0],\n", - "[ 0, 0, 0, 0, 0, -1/tau_syn3]])\n", - "DEBUG:b = Matrix([[E_L/tau_m + I_e/C_m], [0.0], [0.0], [0], [0.0], [0.0]])\n", - "DEBUG:c = Matrix([[0], [0], [0], [0], [0], [0]])\n", - "INFO:update_expr[V_m] = -E_L*__P__V_m__V_m + E_L + I_kernel1__X__I_1*__P__V_m__I_kernel1__X__I_1 + I_kernel2__X__I_2*__P__V_m__I_kernel2__X__I_2 + I_kernel2__X__I_2__d*__P__V_m__I_kernel2__X__I_2__d + I_kernel3__X__I_3*__P__V_m__I_kernel3__X__I_3 + V_m*__P__V_m__V_m - I_e*__P__V_m__V_m*tau_m/C_m + I_e*tau_m/C_m\n", - "INFO:update_expr[dAP_trace] = __P__dAP_trace__dAP_trace*dAP_trace\n", - "INFO:update_expr[I_kernel1__X__I_1] = I_kernel1__X__I_1*__P__I_kernel1__X__I_1__I_kernel1__X__I_1\n", - "INFO:update_expr[I_kernel2__X__I_2] = I_kernel2__X__I_2*__P__I_kernel2__X__I_2__I_kernel2__X__I_2 + I_kernel2__X__I_2__d*__P__I_kernel2__X__I_2__I_kernel2__X__I_2__d\n", - "INFO:update_expr[I_kernel2__X__I_2__d] = I_kernel2__X__I_2*__P__I_kernel2__X__I_2__d__I_kernel2__X__I_2 + I_kernel2__X__I_2__d*__P__I_kernel2__X__I_2__d__I_kernel2__X__I_2__d\n", - "INFO:update_expr[I_kernel3__X__I_3] = I_kernel3__X__I_3*__P__I_kernel3__X__I_3__I_kernel3__X__I_3\n", - "WARNING:Not preserving expression for variable \"V_m\" as it is solved by propagator solver\n", - "WARNING:Not preserving expression for variable \"dAP_trace\" as it is solved by propagator solver\n", - "INFO:In ode-toolbox: returning outdict = \n", - "INFO:[\n", - " {\n", - " \"initial_values\": {\n", - " \"I_kernel1__X__I_1\": \"1\",\n", - " \"I_kernel2__X__I_2\": \"0\",\n", - " \"I_kernel2__X__I_2__d\": \"e/tau_syn2\",\n", - " \"I_kernel3__X__I_3\": \"1\",\n", - " \"V_m\": \"0\",\n", - " \"dAP_trace\": \"0\"\n", - " },\n", - " \"parameters\": {\n", - " \"C_m\": \"250.000000000000\",\n", - " \"E_L\": \"0\",\n", - " \"I_e\": \"0\",\n", - " \"tau_h\": \"400.000000000000\",\n", - " \"tau_m\": \"20.0000000000000\",\n", - " \"tau_syn1\": \"10.0000000000000\",\n", - " \"tau_syn2\": \"10.0000000000000\",\n", - " \"tau_syn3\": \"10.0000000000000\"\n", - " },\n", - " \"propagators\": {\n", - " \"__P__I_kernel1__X__I_1__I_kernel1__X__I_1\": \"1.0*exp(-__h/tau_syn1)\",\n", - " \"__P__I_kernel2__X__I_2__I_kernel2__X__I_2\": \"1.0*(__h + tau_syn2)*exp(-__h/tau_syn2)/tau_syn2\",\n", - " \"__P__I_kernel2__X__I_2__I_kernel2__X__I_2__d\": \"1.0*__h*exp(-__h/tau_syn2)\",\n", - " \"__P__I_kernel2__X__I_2__d__I_kernel2__X__I_2\": \"-1.0*__h*exp(-__h/tau_syn2)/tau_syn2**2\",\n", - " \"__P__I_kernel2__X__I_2__d__I_kernel2__X__I_2__d\": \"1.0*(-__h + tau_syn2)*exp(-__h/tau_syn2)/tau_syn2\",\n", - " \"__P__I_kernel3__X__I_3__I_kernel3__X__I_3\": \"1.0*exp(-__h/tau_syn3)\",\n", - " \"__P__V_m__I_kernel1__X__I_1\": \"1.0*tau_m*tau_syn1*(-exp(__h/tau_m) + exp(__h/tau_syn1))*exp(-__h*(tau_m + tau_syn1)/(tau_m*tau_syn1))/(C_m*(tau_m - tau_syn1))\",\n", - " \"__P__V_m__I_kernel2__X__I_2\": \"1.0*(-__h*tau_m*(tau_m - tau_syn2)*exp(__h*(tau_m + tau_syn2)/(tau_m*tau_syn2)) - tau_m*tau_syn2*(2*tau_m - tau_syn2)*exp(__h*(tau_m + tau_syn2)/(tau_m*tau_syn2)) + tau_syn2*(tau_m*(tau_m - tau_syn2) + tau_m*(2*tau_m - tau_syn2) + (-2*tau_m + tau_syn2)*(tau_m - tau_syn2) + (tau_m - tau_syn2)**2)*exp(2*__h/tau_syn2))*exp(__h*(-2*tau_m - tau_syn2)/(tau_m*tau_syn2))/(C_m*(tau_m - tau_syn2)**2)\",\n", - " \"__P__V_m__I_kernel2__X__I_2__d\": \"-1.0*tau_m*tau_syn2*(__h*tau_m*exp(__h/tau_m) - __h*tau_syn2*exp(__h/tau_m) + tau_m*tau_syn2*exp(__h/tau_m) - tau_m*tau_syn2*exp(__h/tau_syn2))*exp(-__h/tau_syn2 - __h/tau_m)/(C_m*(1.0*tau_m**2 - 2.0*tau_m*tau_syn2 + 1.0*tau_syn2**2))\",\n", - " \"__P__V_m__I_kernel3__X__I_3\": \"1.0*tau_m*tau_syn3*(-exp(__h/tau_m) + exp(__h/tau_syn3))*exp(-__h*(tau_m + tau_syn3)/(tau_m*tau_syn3))/(C_m*(tau_m - tau_syn3))\",\n", - " \"__P__V_m__V_m\": \"1.0*exp(-__h/tau_m)\",\n", - " \"__P__dAP_trace__dAP_trace\": \"1.0*exp(-__h/tau_h)\"\n", - " },\n", - " \"solver\": \"analytical\",\n", - " \"state_variables\": [\n", - " \"V_m\",\n", - " \"dAP_trace\",\n", - " \"I_kernel1__X__I_1\",\n", - " \"I_kernel2__X__I_2\",\n", - " \"I_kernel2__X__I_2__d\",\n", - " \"I_kernel3__X__I_3\"\n", - " ],\n", - " \"update_expressions\": {\n", - " \"I_kernel1__X__I_1\": \"I_kernel1__X__I_1*__P__I_kernel1__X__I_1__I_kernel1__X__I_1\",\n", - " \"I_kernel2__X__I_2\": \"I_kernel2__X__I_2*__P__I_kernel2__X__I_2__I_kernel2__X__I_2 + I_kernel2__X__I_2__d*__P__I_kernel2__X__I_2__I_kernel2__X__I_2__d\",\n", - " \"I_kernel2__X__I_2__d\": \"I_kernel2__X__I_2*__P__I_kernel2__X__I_2__d__I_kernel2__X__I_2 + I_kernel2__X__I_2__d*__P__I_kernel2__X__I_2__d__I_kernel2__X__I_2__d\",\n", - " \"I_kernel3__X__I_3\": \"I_kernel3__X__I_3*__P__I_kernel3__X__I_3__I_kernel3__X__I_3\",\n", - " \"V_m\": \"-E_L*__P__V_m__V_m + E_L + I_kernel1__X__I_1*__P__V_m__I_kernel1__X__I_1 + I_kernel2__X__I_2*__P__V_m__I_kernel2__X__I_2 + I_kernel2__X__I_2__d*__P__V_m__I_kernel2__X__I_2__d + I_kernel3__X__I_3*__P__V_m__I_kernel3__X__I_3 + V_m*__P__V_m__V_m - I_e*__P__V_m__V_m*tau_m/C_m + I_e*tau_m/C_m\",\n", - " \"dAP_trace\": \"__P__dAP_trace__dAP_trace*dAP_trace\"\n", - " }\n", - " }\n", - "]\n" + "ename": "NESTErrors.DynamicModuleManagementError", + "evalue": "DynamicModuleManagementError in SLI function Install: Module 'nestml_98cfb66389b04bd6af313317a8b164a5_module' could not be opened.\nThe dynamic loader returned the following error: 'file not found'.\n\nPlease check LD_LIBRARY_PATH (OSX: DYLD_LIBRARY_PATH)!", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNESTErrors.DynamicModuleManagementError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn [2], line 46\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[38;5;124;03m\"\"\"# JUST THE NEURON MODEL\u001b[39;00m\n\u001b[1;32m 40\u001b[0m \u001b[38;5;124;03mmodule_name, neuron_model_name = \\\u001b[39;00m\n\u001b[1;32m 41\u001b[0m \u001b[38;5;124;03m NESTCodeGeneratorUtils.generate_code_for(\"../../../doc/tutorials/sequences/iaf_psc_exp_nonlineardendrite_neuron.nestml\",\u001b[39;00m\n\u001b[1;32m 42\u001b[0m \u001b[38;5;124;03m logging_level=\"DEBUG\")\"\"\"\u001b[39;00m\n\u001b[1;32m 45\u001b[0m \u001b[38;5;66;03m# load dynamic library (NEST extension module) into NEST kernel\u001b[39;00m\n\u001b[0;32m---> 46\u001b[0m \u001b[43mnest\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mInstall\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodule_name\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/julich/nest-simulator-install/lib/python3.11/site-packages/nest/ll_api.py:217\u001b[0m, in \u001b[0;36mstack_checker..stack_checker_func\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 214\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(f)\n\u001b[1;32m 215\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mstack_checker_func\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 216\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m get_debug():\n\u001b[0;32m--> 217\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 218\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 219\u001b[0m sr(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcount\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "File \u001b[0;32m~/julich/nest-simulator-install/lib/python3.11/site-packages/nest/lib/hl_api_simulation.py:330\u001b[0m, in \u001b[0;36mInstall\u001b[0;34m(module_name)\u001b[0m\n\u001b[1;32m 303\u001b[0m \u001b[38;5;129m@check_stack\u001b[39m\n\u001b[1;32m 304\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mInstall\u001b[39m(module_name):\n\u001b[1;32m 305\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Load a dynamically linked NEST module.\u001b[39;00m\n\u001b[1;32m 306\u001b[0m \n\u001b[1;32m 307\u001b[0m \u001b[38;5;124;03m Parameters\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 327\u001b[0m \n\u001b[1;32m 328\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 330\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43msr\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m(\u001b[39;49m\u001b[38;5;132;43;01m%s\u001b[39;49;00m\u001b[38;5;124;43m) Install\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m%\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mmodule_name\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/julich/nest-simulator-install/lib/python3.11/site-packages/nest/ll_api.py:104\u001b[0m, in \u001b[0;36mcatching_sli_run\u001b[0;34m(cmd)\u001b[0m\n\u001b[1;32m 101\u001b[0m engine\u001b[38;5;241m.\u001b[39mrun(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mclear\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 103\u001b[0m exceptionCls \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mgetattr\u001b[39m(kernel\u001b[38;5;241m.\u001b[39mNESTErrors, errorname)\n\u001b[0;32m--> 104\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m exceptionCls(commandname, message)\n", + "\u001b[0;31mNESTErrors.DynamicModuleManagementError\u001b[0m: DynamicModuleManagementError in SLI function Install: Module 'nestml_98cfb66389b04bd6af313317a8b164a5_module' could not be opened.\nThe dynamic loader returned the following error: 'file not found'.\n\nPlease check LD_LIBRARY_PATH (OSX: DYLD_LIBRARY_PATH)!" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "[16,iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml, DEBUG, [1:0;93:0]]: Start building symbol table!\n", - "[17,iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml, INFO, [69:29;69:29]]: Implicit casting from (compatible) type 'pA' to 'real'.\n", - "[18,iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml, INFO, [72:29;72:31]]: Implicit casting from (compatible) type 'pA' to 'real'.\n", - "[19,iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml, INFO, [77:25;77:25]]: Implicit casting from (compatible) type 'pA' to 'real'.\n", - "[20,iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml, INFO, [86:25;86:27]]: Implicit casting from (compatible) type 'pA' to 'real'.\n", - "[21,iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml, INFO, [93:21;93:23]]: Implicit casting from (compatible) type 'pA' to 'real'.\n", - "[22,GLOBAL, INFO]: Rendering template /home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target/iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml.cpp\n", - "[23,GLOBAL, INFO]: Rendering template /home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target/iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml.h\n", - "[24,iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml, INFO, [1:0;93:0]]: Successfully generated code for the model: 'iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml' in: '/home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target' !\n", - "[25,GLOBAL, INFO]: Rendering template /home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target/nestml_2817e88e01de42069addea0bb3524aa3_module.cpp\n", - "[26,GLOBAL, INFO]: Rendering template /home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target/nestml_2817e88e01de42069addea0bb3524aa3_module.h\n", - "[27,GLOBAL, INFO]: Rendering template /home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target/CMakeLists.txt\n", - "[28,GLOBAL, INFO]: Successfully generated NEST module code in '/home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target' !\n", - "CMake Warning (dev) at CMakeLists.txt:93 (project):\n", - " cmake_minimum_required() should be called prior to this top-level project()\n", - " call. Please see the cmake-commands(7) manual for usage documentation of\n", - " both commands.\n", - "This warning is for project developers. Use -Wno-dev to suppress it.\n", - "\n", - "-- The CXX compiler identification is GNU 12.3.0\n", - "-- Detecting CXX compiler ABI info\n", - "-- Detecting CXX compiler ABI info - done\n", - "-- Check for working CXX compiler: /usr/bin/c++ - skipped\n", - "-- Detecting CXX compile features\n", - "-- Detecting CXX compile features - done\n", - "\n", - "-------------------------------------------------------\n", - "nestml_2817e88e01de42069addea0bb3524aa3_module Configuration Summary\n", - "-------------------------------------------------------\n", - "\n", - "C++ compiler : /usr/bin/c++\n", - "Build static libs : OFF\n", - "C++ compiler flags : \n", - "NEST compiler flags : -std=c++11 -Wall -fopenmp -O2 -fdiagnostics-color=auto -g\n", - "NEST include dirs : -I/home/charl/julich/nest-simulator-install/include/nest -I/usr/include -I/usr/include -I/usr/include\n", - "NEST libraries flags : -L/home/charl/julich/nest-simulator-install/lib/nest -lnest -lsli -fopenmp /usr/lib/x86_64-linux-gnu/libltdl.so /usr/lib/x86_64-linux-gnu/libgsl.so /usr/lib/x86_64-linux-gnu/libgslcblas.so\n", - "\n", - "-------------------------------------------------------\n", - "\n", - "You can now build and install 'nestml_2817e88e01de42069addea0bb3524aa3_module' using\n", - " make\n", - " make install\n", - "\n", - "The library file libnestml_2817e88e01de42069addea0bb3524aa3_module.so will be installed to\n", - " /tmp/nestml_target_5b0k1g20\n", - "The module can be loaded into NEST using\n", - " (nestml_2817e88e01de42069addea0bb3524aa3_module) Install (in SLI)\n", - " nest.Install(nestml_2817e88e01de42069addea0bb3524aa3_module) (in PyNEST)\n", - "\n", - "CMake Warning (dev) in CMakeLists.txt:\n", - " No cmake_minimum_required command is present. A line of code such as\n", - "\n", - " cmake_minimum_required(VERSION 3.26)\n", - "\n", - " should be added at the top of the file. The version specified may be lower\n", - " if you wish to support older CMake versions for this project. For more\n", - " information run \"cmake --help-policy CMP0000\".\n", - "This warning is for project developers. Use -Wno-dev to suppress it.\n", - "\n", - "-- Configuring done (0.1s)\n", - "-- Generating done (0.0s)\n", - "-- Build files have been written to: /home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target\n", - "[ 33%] Building CXX object CMakeFiles/nestml_2817e88e01de42069addea0bb3524aa3_module_module.dir/nestml_2817e88e01de42069addea0bb3524aa3_module.o\n", - "[ 66%] Building CXX object CMakeFiles/nestml_2817e88e01de42069addea0bb3524aa3_module_module.dir/iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml.o\n", - "/home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target/iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml.cpp: In member function ‘void iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::init_state_internal_()’:\n", - "/home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target/iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml.cpp:219:16: warning: unused variable ‘__resolution’ [-Wunused-variable]\n", - " 219 | const double __resolution = nest::Time::get_resolution().get_ms(); // do not remove, this is necessary for the resolution() function\n", - " | ^~~~~~~~~~~~\n", - "/home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target/iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml.cpp: In member function ‘virtual void iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::update(const nest::Time&, long int, long int)’:\n", - "/home/charl/julich/nestml-fork-clopath_synapse/nestml/doc/tutorials/sequences/target/iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml.cpp:355:24: warning: comparison of integer expressions of different signedness: ‘long int’ and ‘const size_t’ {aka ‘const long unsigned int’} [-Wsign-compare]\n", - " 355 | for (long i = 0; i < NUM_SPIKE_RECEPTORS; ++i)\n", - " | ~~^~~~~~~~~~~~~~~~~~~~~\n", - "[100%] Linking CXX shared module nestml_2817e88e01de42069addea0bb3524aa3_module.so\n", - "[100%] Built target nestml_2817e88e01de42069addea0bb3524aa3_module_module\n", - "[100%] Built target nestml_2817e88e01de42069addea0bb3524aa3_module_module\n", - "Install the project...\n", - "-- Install configuration: \"\"\n", - "-- Installing: /tmp/nestml_target_5b0k1g20/nestml_2817e88e01de42069addea0bb3524aa3_module.so\n", - "iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml()\n", - "iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::init_state_internal_()\n", - "iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::pre_run_hook()\n", - "iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::recompute_internal_variables()\n", - "\t --> END OF iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::recompute_internal_variables()\n", - "iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::recompute_internal_variables()\n", - "\t --> END OF iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::recompute_internal_variables()\n", - "iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::pre_run_hook()\n", - "iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::recompute_internal_variables()\n", - "\t --> END OF iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::recompute_internal_variables()\n", - "iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml(copy constr)\n", - "\t--> END OF iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml::iaf_psc_exp_nonlineardendrite2817e88e01de42069addea0bb3524aa3_neuron_nestml(copy constr)\n", - "\n", - "Feb 06 07:38:38 Install [Info]: \n", - " loaded module nestml_2817e88e01de42069addea0bb3524aa3_module\n" + "> \u001b[0;32m/home/charl/julich/nest-simulator-install/lib/python3.11/site-packages/nest/ll_api.py\u001b[0m(104)\u001b[0;36mcatching_sli_run\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32m 102 \u001b[0;31m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0m\u001b[0;32m 103 \u001b[0;31m \u001b[0mexceptionCls\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkernel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mNESTErrors\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0merrorname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0m\u001b[0;32m--> 104 \u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mexceptionCls\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcommandname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmessage\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0m\u001b[0;32m 105 \u001b[0;31m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0m\u001b[0;32m 106 \u001b[0;31m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0m\n" ] } ], @@ -566,7 +173,6 @@ "#nest.Install(\"nestml_jit_module\")\n", "\n", "# generate and build code\n", - "\"\"\"\n", "\n", "module_name, neuron_model_name, synapse_model_name = \\\n", " NESTCodeGeneratorUtils.generate_code_for(\"../../../doc/tutorials/sequences/iaf_psc_exp_nonlineardendrite_neuron.nestml\",\n", @@ -575,9 +181,10 @@ " post_ports=[\"post_spikes\", [\"dAP_trace\", \"dAP_trace\"]])\n", "\"\"\"\n", "\n", - "module_name = \"nestml_d76233a4d30f455c84b5b585e84208a2_module\"\n", - "neuron_model_name = \"iaf_psc_exp_nonlineardendrited76233a4d30f455c84b5b585e84208a2_neuron_nestml__with_stdspd76233a4d30f455c84b5b585e84208a2_synapse_nestml\"\n", - "synapse_model_name = \"stdspd76233a4d30f455c84b5b585e84208a2_synapse_nestml__with_iaf_psc_exp_nonlineardendrited76233a4d30f455c84b5b585e84208a2_neuron_nestml\"\n", + "module_name = \"nestml_98cfb66389b04bd6af313317a8b164a5_module\"\n", + "neuron_model_name = \"iaf_psc_exp_nonlineardendrite98cfb66389b04bd6af313317a8b164a5_neuron_nestml__with_stdsp98cfb66389b04bd6af313317a8b164a5_synapse_nestml\"\n", + "synapse_model_name = \"stdsp98cfb66389b04bd6af313317a8b164a5_synapse_nestml__with_iaf_psc_exp_nonlineardendrite98cfb66389b04bd6af313317a8b164a5_neuron_nestml\"\n", + "\"\"\"\n", "\n", "\n", "\"\"\"# JUST THE NEURON MODEL\n", @@ -597,29 +204,73 @@ "Now, the NESTML model is ready to be used in a simulation." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Helper functions" + ] + }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "import parameters as para\n", - "import numpy as np\n", + "def psp_max_2_psc_max(psp_max, tau_m, tau_s, R_m):\n", + " \"\"\"Compute the PSC amplitude (pA) injected to get a certain PSP maximum (mV) for LIF with exponential PSCs\n", "\n", - "p = para.ParameterSpace({})\n", + " Parameters\n", + " ----------\n", + " psp_max: float\n", + " Maximum postsynaptic pontential\n", + " tau_m: float\n", + " Membrane time constant (ms).\n", + " tau_s: float\n", + " Synaptic time constant (ms).\n", + " R_m: float\n", + " Membrane resistance (Gohm).\n", "\n", + " Returns\n", + " -------\n", + " float\n", + " PSC amplitude (pA).\n", + " \"\"\"\n", + "\n", + " return psp_max / (\n", + " R_m * tau_s / (tau_s - tau_m) * (\n", + " (tau_m / tau_s) ** (-tau_m / (tau_m - tau_s)) -\n", + " (tau_m / tau_s) ** (-tau_s / (tau_m - tau_s))\n", + " )\n", + " )\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "DELAY = 0.1\n", "\n", - "p['dt'] = 0.1 # simulation time resolution (ms)\n", - "p['print_simulation_progress'] = False # print the time progress.\n", - "p['n_threads'] = 4 # number of threads per MPI process \n", + "p = para.ParameterSpace({})\n", + "\n", + "\n", "\n", "\n", - "# data path dict\n", - "p['data_path'] = {}\n", - "p['data_path']['data_root_path'] = 'data'\n", - "p['data_path']['project_name'] = 'sequence_learning_performance'\n", - "p['data_path']['parameterspace_label'] = 'effect_dAP_firing_times'\n", + "\n", + "\n", + "\n", + "\n", + "p['dt'] = 0.1 # simulation time resolution (ms)\n", + "p['print_simulation_progress'] = False # print the time progress.\n", "\n", "# neuron parameters of the excitatory neurons\n", "p['soma_model'] = neuron_model_name\n", @@ -646,6 +297,8 @@ "p['fixed_somatic_delay'] = 2 # this is an approximate time of how long it takes the soma to fire\n", " # upon receiving an external stimulus \n", "\n", + " \n", + "\n", "# neuron parameters for the inhibitory neuron\n", "p['inhibit_model'] = 'iaf_psc_exp'\n", "p['inhibit_params'] = {}\n", @@ -660,31 +313,75 @@ "p['inhibit_params']['tau_syn_ex'] = .5 # synaptic time constant of an excitatory input (ms) \n", "p['inhibit_params']['tau_syn_in'] = 1.65 # synaptic time constant of an inhibitory input (ms)\n", "\n", + " \n", + " \n", + " \n", "# synaptic parameters\n", "p['J_EX_psp'] = 1.1 * p['soma_params']['V_th'] # somatic PSP as a response to an external input\n", "p['J_IE_psp'] = 1.2 * p['inhibit_params']['V_th'] # inhibitory PSP as a response to an input from E neuron\n", "p['J_EI_psp'] = -2 * p['soma_params']['V_th'] # somatic PSP as a response to an inhibitory input\n", "p['convergence'] = 5\n", - "p['pattern_size'] = 20\n", + "\n", + "\n", + "\n", + "\n", + "# parameters for setting up the network \n", + "p['M'] = 6 # number of subpopulations\n", + "p['n_E'] = 150 # number of excitatory neurons per subpopulation\n", + "p['n_I'] = 1 # number of inhibitory neurons per subpopulation\n", + "p['L'] = 1 # number of subpopulations that represents one sequence element\n", + "p['pattern_size'] = 20 # sparse set of active neurons per subpopulation\n", + "\n", + "# connection details\n", + "p['rule'] = 'fixed_indegree' \n", + "p['connection_prob'] = 0.2\n", + "\n", + "# neuron parameters of the excitatory neurons\n", + "p['soma_model'] = neuron_model_name\n", + "p['soma_params'] = {}\n", + "p['soma_params']['C_m'] = 250. # membrane capacitance (pF)\n", + "p['soma_params']['E_L'] = 0. # resting membrane potential (mV)\n", + "# p['soma_params']['I_e'] = 0. # external DC currents (pA)\n", + "p['soma_params']['V_m'] = 0. # initial potential (mV)\n", + "p['soma_params']['V_reset'] = 0. # reset potential (mV)\n", + "p['soma_params']['V_th'] = 20. # spike threshold (mV)\n", + "p['soma_params']['t_ref'] = 10. # refractory period\n", + "p['soma_params']['tau_m'] = 10. # membrane time constant (ms)\n", + "p['soma_params']['tau_syn1'] = 2. # synaptic time constant: external input (receptor 1)\n", + "p['soma_params']['tau_syn2'] = 5. # synaptic time constant: dendrtic input (receptor 2)\n", + "p['soma_params']['tau_syn3'] = 1. # synaptic time constant: inhibitory input (receptor 3)\n", + "# dendritic action potential\n", + "p['soma_params']['I_p'] = 200. # current clamp value for I_dAP during a dendritic action potenti\n", + "p['soma_params']['tau_dAP'] = 60. # time window over which the dendritic current clamp is active\n", + "p['soma_params']['theta_dAP'] = 59. # current threshold for a dendritic action potential\n", + "p['fixed_somatic_delay'] = 2 # this is an approximate time of how long it takes the soma to fire\n", + " # upon receiving an external stimulus \n", + "\n", + "# synaptic parameters\n", + "p['J_EX_psp'] = 1.1 * p['soma_params']['V_th'] # somatic PSP as a response to an external input\n", + "p['J_EI_psp'] = -2 * p['soma_params']['V_th'] # somatic PSP as a response to an inhibitory input\n", + "p['convergence'] = 5\n", "\n", "# parameters for ee synapses (stdsp)\n", "p['syn_dict_ee'] = {}\n", - "p['p_min'] = 0.\n", - "p['p_max'] = 8.\n", - "p['calibration'] = 40.\n", + "p['permanence_min'] = 0.\n", + "p['permanence_max'] = 8.\n", + "p['calibration'] = 0.\n", "p['syn_dict_ee']['weight'] = 0.01 # synaptic weight\n", "p['syn_dict_ee']['synapse_model'] = synapse_model_name # synapse model\n", "p['syn_dict_ee']['permanence_threshold'] = 10. # synapse maturity threshold\n", "p['syn_dict_ee']['tau_pre_trace'] = 20. # plasticity time constant (potentiation)\n", "p['syn_dict_ee']['delay'] = 2. # dendritic delay \n", "p['syn_dict_ee']['receptor_type'] = 2 # receptor corresponding to the dendritic input\n", - "p['syn_dict_ee']['lambda_plus'] = 0.05 #0.1 # potentiation rate\n", - "p['syn_dict_ee']['zt'] = 1. # target dAP trace [pA]\n", - "p['syn_dict_ee']['lambda_h'] = 0.01 # homeostasis rate\n", + "p['syn_dict_ee']['lambda_plus'] = 0.08 # potentiation rate\n", + "p['syn_dict_ee']['zt'] = 1. # target dAP trace\n", + "p['syn_dict_ee']['lambda_h'] = 0.014 # homeostasis rate\n", "p['syn_dict_ee']['Wmax'] = 1.1 * p['soma_params']['theta_dAP'] / p['convergence'] # Maximum allowed weight\n", "p['syn_dict_ee']['permanence_max'] = 20. # Maximum allowed permanence\n", "p['syn_dict_ee']['permanence_min'] = 1. # Minimum allowed permanence\n", - "p['syn_dict_ee']['lambda_minus'] = 0.004\n", + "p['syn_dict_ee']['lambda_minus'] = 0.0015 # depression rate\n", + "p['syn_dict_ee']['dt_min'] = -4. # minimum time lag of the STDP window\n", + "p['inh_factor'] = 7.\n", "\n", "# parameters of EX synapses (external to soma of E neurons)\n", "p['conn_dict_ex'] = {}\n", @@ -698,7 +395,7 @@ "p['syn_dict_edx'] = {}\n", "p['syn_dict_edx']['receptor_type'] = 2 # receptor corresponding to the dendritic input\n", "p['syn_dict_edx']['delay'] = DELAY # dendritic delay\n", - "p['syn_dict_edx']['weight'] = 10.4 * p['soma_params']['theta_dAP']\n", + "p['syn_dict_edx']['weight'] = 1.4 * p['soma_params']['theta_dAP']\n", "p['conn_dict_edx']['rule'] = 'fixed_outdegree' # connection rule\n", "p['conn_dict_edx']['outdegree'] = p['pattern_size'] + 1 # outdegree\n", "\n", @@ -719,47 +416,54 @@ "p['conn_dict_ei']['rule'] = 'fixed_indegree' # connection rule\n", "p['conn_dict_ei']['indegree'] = 20 # indegree\n", "\n", + "# stimulus parameters\n", + "p['DeltaT'] = 40. # inter-stimulus interval\n", + "p['excitation_start'] = 30. # time at which the external stimulation begins\n", + "p['time_dend_to_somatic'] = 20. # time between the dAP activation and the somatic activation (only used if sparse_first_char is True) \n", + "p['DeltaT_cue'] = 80. # inter-cue interval during replay\n", "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "def psp_max_2_psc_max(psp_max, tau_m, tau_s, R_m):\n", - " \"\"\"Compute the PSC amplitude (pA) injected to get a certain PSP maximum (mV) for LIF with exponential PSCs\n", - "\n", - " Parameters\n", - " ----------\n", - " psp_max: float\n", - " Maximum postsynaptic pontential\n", - " tau_m: float\n", - " Membrane time constant (ms).\n", - " tau_s: float\n", - " Synaptic time constant (ms).\n", - " R_m: float\n", - " Membrane resistance (Gohm).\n", - "\n", - " Returns\n", - " -------\n", - " float\n", - " PSC amplitude (pA).\n", - " \"\"\"\n", - "\n", - " return psp_max / (\n", - " R_m * tau_s / (tau_s - tau_m) * (\n", - " (tau_m / tau_s) ** (-tau_m / (tau_m - tau_s)) -\n", - " (tau_m / tau_s) ** (-tau_s / (tau_m - tau_s))\n", - " )\n", - " )\n" + "# simulation parameters \n", + "p['dt'] = 0.1 # simulation time resolution (ms)\n", + "p['overwrite_files'] = True # if True, data will be overwritten,\n", + " # if False, a NESTError is raised if the files already exist\n", + "p['seed'] = para.ParameterRange([1,2,3,4,5]) # seed for NEST\n", + "p['print_simulation_progress'] = False # print the time progress.\n", + "p['pad_time'] = 5.\n", + "p['idend_recording_interval'] = 10 * p['dt'] # dendritic current recording resolution\n", + "p['idend_record_time'] = 8. # time interval after the external stimulation at which the dendritic current is recorded\n", + "p['evaluate_performance'] = True # if turned on, we monitor the dendritic current at a certain time steps\n", + " # during the simulation. This then is used for the prediction performance assessment\n", + "p['evaluate_replay'] = False \n", + "p['record_idend_last_episode'] = True # used for debugging, if turned on we record the dendritic current of all neurons\n", + " # this can consume too much memory\n", + "p['store_connections'] = True \n", + "p['load_connections'] = False\n", + "p['sparse_first_char'] = False # if turned on, the dAP of a subset of neurons in the subpopulation representing \n", + " # first sequence elements is activated externally \n", + "p['active_weight_recorder'] = False # if turned on, the weights are recorded every presynaptic spike\n", + "\n", + "# task parameters\n", + "p['task'] = {}\n", + "p['task']['task_name'] = 'hard_coded' # name of the task\n", + "p['task']['task_type'] = 1 # this chooses between three hard coded sequence sets (see ./utils.py)\n", + "p['task']['vocab_size'] = 6 # vocabulary size\n", + "p['task']['seed'] = 111 # seed number\n", + "p['task']['store_training_data'] = True # if turned on, the sequence set is stored in directory defined in dict data_path\n", + "if p['task']['task_name'] != 'hard_coded':\n", + " p['task']['num_sequences'] = 2 # number of sequences per sequence set\n", + " p['task']['num_sub_seq'] = 2 # if task_name == 'high_order', \n", + " # it sets the number of sequences with same shared subsequence\n", + " p['task']['length_sequence'] = 6 # number of elements per sequence\n", + " p['task']['replace'] = False # random choice of characters with replacement\n", + "\n", + "# setup the training loop \n", + "p['learning_episodes'] = 3#85 # total number of training episodes ('repetitions of the sequence sets')\n", + "p['episodes_to_testing'] = 1 # number of episodes after which we measure the prediction perfomance" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -783,6 +487,632 @@ "dendrite_excitation_time = 3." ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# experiments/sequence_learning_and_prediction/local_simulation.py\n", + "\n", + "def generate_sequences(params, fname):\n", + " \"\"\"Generate sequence of elements using three methods:\n", + " 1. randomly drawn elements from a vocabulary\n", + " 2. sequences with transition matrix\n", + " 3. higher order sequences: sequences with shared subsequences\n", + " 4. hard coded sequences\n", + "\n", + " Parameters\n", + " ----------\n", + " params : dict\n", + " dictionary contains task parameters\n", + " fname : str\n", + "\n", + " Returns\n", + " -------\n", + " sequences: list\n", + " test_sequences: list\n", + " vocabulary: list\n", + " \"\"\"\n", + "\n", + " task_name = params['task_name']\n", + " task_type = params['task_type']\n", + " \n", + " # set of characters used to build the sequences\n", + " vocabulary = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',\n", + " 'U', 'V', 'W', 'X', 'Y', 'Z'][:params['vocab_size']]\n", + " sequences = []\n", + "\n", + " # create high order sequences, characters are drawn without replacement\n", + " if task_name == \"high_order\":\n", + "\n", + " if (params['num_sequences'] % params['num_sub_seq'] != 0):\n", + " raise ZeroDivisionError(\n", + " 'for high order sequences number of sequences needs (\"num_sequences\") to be divisible by num_sub_seq')\n", + "\n", + " num_sequences_high_order = int(params['num_sequences'] / params['num_sub_seq'])\n", + " for i in range(num_sequences_high_order):\n", + " characters_sub_seq = copy.copy(vocabulary)\n", + " sub_seq = random.sample(characters_sub_seq, params[\"length_sequence\"] - 2)\n", + " for char in sub_seq:\n", + " characters_sub_seq.remove(char)\n", + "\n", + " for j in range(params['num_sub_seq']):\n", + " # remove the characters that were chosen for the end and the start of the sequence\n", + " # this is to avoid sequences with adjacent letters of the same kind\n", + " # we will add this feature to the code asap \n", + " end_char = random.sample(characters_sub_seq, 1)\n", + " characters_sub_seq.remove(end_char[0])\n", + "\n", + " start_char = random.sample(characters_sub_seq, 1)\n", + " characters_sub_seq.remove(start_char[0])\n", + "\n", + " sequence = start_char + sub_seq + end_char\n", + " sequences.append(sequence)\n", + "\n", + " # randomly shuffled characters\n", + " elif task_name == \"random\":\n", + " sequences = [random.sample(vocabulary, length_seq) for _ in range(params['num_sequences'])]\n", + "\n", + " # create sequences using matrix transition \n", + " elif task_name == \"structure\":\n", + " matrix_transition = defaultdict(list)\n", + " for char in vocabulary:\n", + " x = np.random.choice(2, len(vocabulary), p=[0.2, 0.8])\n", + " matrix_transition[char] = x / sum(x)\n", + "\n", + " for _ in range(params['num_sequences']):\n", + " sequence = random.sample(vocabulary, 1)\n", + " last_char = sequence[-1]\n", + " for _ in range(length_seq - 1):\n", + " sequence += np.random.choice(vocabulary, 1, p=matrix_transition[last_char])[0]\n", + " last_char = sequence[-1]\n", + "\n", + " sequences += [sequence]\n", + " else:\n", + "\n", + " # hard coded sequences \n", + " if task_type == 1:\n", + " sequences = [['A', 'D', 'B', 'E'], ['F', 'D', 'B', 'C']]\n", + " elif task_type == 2:\n", + " sequences = [['E', 'N', 'D', 'I', 'J'], ['L', 'N', 'D', 'I', 'K'], ['G', 'J', 'M', 'C', 'N'], \n", + " ['F', 'J', 'M', 'C', 'I'], ['B', 'C', 'K', 'H', 'I'], ['A', 'C', 'K', 'H', 'F']]\n", + " elif task_type == 3:\n", + " sequences = [['E', 'N', 'D', 'I', 'J'], ['L', 'N', 'D', 'I', 'K'], ['G', 'J', 'M', 'E', 'N'], \n", + " ['F', 'J', 'M', 'E', 'I'], ['B', 'C', 'K', 'B', 'I'], ['A', 'C', 'K', 'B', 'F']]\n", + " else:\n", + " sequences = [['A', 'D', 'B', 'G', 'H', 'E'], ['F', 'D', 'B', 'G', 'H', 'C']]\n", + "\n", + " # test sequences used to measure the accuracy \n", + " test_sequences = sequences\n", + "\n", + " fname = 'training_data'\n", + " fname_voc = 'vocabulary'\n", + " print(\"\\nSave training data to %s\" % (fname))\n", + " np.save('%s' % ( fname), sequences)\n", + " np.save('%s' % ( fname_voc), vocabulary)\n", + "\n", + " return sequences, test_sequences, vocabulary\n", + "\n", + "model_instance = None\n", + "def generate_reference_data():\n", + " global model_instance\n", + " #############################################################\n", + " # get network and training parameters \n", + " # ===========================================================\n", + " global p\n", + " PS = copy.deepcopy(p)\n", + "\n", + " # parameter-set id from command line (submission script)\n", + " PL = shtm.helper.parameter_set_list(PS) \n", + " params = PL[0]\n", + "\n", + " # start time \n", + " time_start = time.time()\n", + "\n", + " # ###############################################################\n", + " # specify sequences\n", + " # ===============================================================\n", + " sequences, _, vocabulary = generate_sequences(params['task'], PL[0]['label'])\n", + "\n", + " # ###############################################################\n", + " # create network\n", + " # ===============================================================\n", + " model_instance = shtm.model.Model(params, sequences, vocabulary)\n", + " time_model = time.time()\n", + "\n", + " model_instance.create()\n", + " time_create = time.time()\n", + "\n", + " # ###############################################################\n", + " # connect the netwok\n", + " # ===============================================================\n", + " model_instance.connect()\n", + " time_connect = time.time()\n", + " \n", + " # store connections before learning\n", + " if params['store_connections']:\n", + " model_instance.save_connections(fname='ee_connections_before')\n", + "\n", + " # ###############################################################\n", + " # simulate the network\n", + " # ===============================================================\n", + " model_instance.simulate()\n", + " time_simulate = time.time()\n", + "\n", + " # store connections after learning\n", + " if params['store_connections']:\n", + " model_instance.save_connections(fname='ee_connections')\n", + "\n", + " print(\n", + " '\\nTimes of Rank {}:\\n'.format(\n", + " nest.Rank()) +\n", + " ' Total time: {:.3f} s\\n'.format(\n", + " time_simulate -\n", + " time_start) +\n", + " ' Time to initialize: {:.3f} s\\n'.format(\n", + " time_model -\n", + " time_start) +\n", + " ' Time to create: {:.3f} s\\n'.format(\n", + " time_create -\n", + " time_model) +\n", + " ' Time to connect: {:.3f} s\\n'.format(\n", + " time_connect -\n", + " time_create) +\n", + " ' Time to simulate: {:.3f} s\\n'.format(\n", + " time_simulate -\n", + " time_connect))\n", + "\n", + " # display prediction performance only for debugging \n", + " if params['evaluate_performance']:\n", + " \n", + " # print Ic\n", + " #zs = np.array([nest.GetStatus(model_instance.exc_neurons)[i]['z'] for i in range(params['M']*params['n_E'])])\n", + " #id_zs = np.where(zs>0.5)\n", + " #print(zs[id_zs])\n", + "\n", + " # load spikes from reference data\n", + " somatic_spikes = shtm.helper.load_spike_data(model_instance.data_path, 'somatic_spikes')\n", + " idend_eval = shtm.helper.load_spike_data(model_instance.data_path, 'idend_eval')\n", + " excitation_times = shtm.helper.load_data(model_instance.data_path, 'excitation_times')\n", + "\n", + " # get recoding times of dendriticAP\n", + " idend_recording_times = shtm.helper.load_data(model_instance.data_path, 'idend_recording_times')\n", + " characters_to_subpopulations = shtm.helper.load_data(model_instance.data_path, 'characters_to_subpopulations')\n", + "\n", + " seq_avg_errors, seq_avg_false_positives, seq_avg_false_negatives, _ = shtm.helper.compute_prediction_performance(somatic_spikes, idend_eval, idend_recording_times, characters_to_subpopulations, model_instance.sequences, model_instance.params)\n", + "\n", + " # get number of active neuron for each element in the sequence\n", + " number_elements_per_batch = sum([len(seq) for seq in model_instance.sequences])\n", + " start_time = excitation_times[-number_elements_per_batch] - 5 \n", + " end_time = excitation_times[-1] + 5\n", + "\n", + " idx_times = np.where((np.array(excitation_times) > start_time) & (np.array(excitation_times) < end_time)) \n", + " excitation_times_sel = np.array(excitation_times)[idx_times]\n", + "\n", + " num_active_neurons = shtm.helper.number_active_neurons_per_element(model_instance.sequences, somatic_spikes[:,1], somatic_spikes[:,0], excitation_times_sel, params['fixed_somatic_delay'])\n", + "\n", + " print(\"\\n##### testing sequences with number of somatic spikes \")\n", + " count_false_negatives = 0\n", + " for i, (sequence, seq_counts) in enumerate(zip(model_instance.sequences, num_active_neurons)): \n", + " seq = ''\n", + " for j, (char, counts) in enumerate(zip(sequence, seq_counts)):\n", + " seq += str(char)+'('+ str(seq_counts[char])+')'.ljust(2)\n", + "\n", + " if j != 0 and seq_counts[char] > 0.5*params['n_E']:\n", + " count_false_negatives += 1\n", + "\n", + " print(\"sequence %d: %s\" % (i, seq)) \n", + "\n", + " print(\"False negative counts\", count_false_negatives) \n", + "\n", + " print(\"\\n### Plasticity parameters\")\n", + " print(\"lambda plus: %0.4f\" % params['syn_dict_ee']['lambda_plus'])\n", + " print(\"lambda homeostasis: %0.4f\" % params['syn_dict_ee']['lambda_h'])\n", + " print(\"lambda minus: %0.4f\" % model_instance.params['syn_dict_ee']['lambda_minus']) \n", + " print(\"inh factor:\", params['inh_factor'])\n", + " print(\"excitation step %0.1fms\" % params['DeltaT']) #30-50 \n", + " print(\"seed number: %d\" % params['seed']) \n", + " print(\"number of learning episodes: %d\" % params['learning_episodes'])\n", + "\n", + "generate_reference_data()\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# experiments/sequence_learning_and_prediction/prediction_performance_analysis.py\n", + "\n", + "PS = copy.deepcopy(p)\n", + "PS_sel = copy.deepcopy(PS)\n", + "compute_overlap = True\n", + "\n", + "PL = shtm.helper.parameter_set_list(PS_sel)\n", + "\n", + "# get training data\n", + "sequences = shtm.helper.load_data('.', 'training_data')\n", + "\n", + "print(\"#### sequences used for training ### \")\n", + "for i, sequence in enumerate(sequences): \n", + " seq = '' \n", + " for char in sequence:\n", + " seq += str(char).ljust(2) \n", + " print(\"sequence %d: %s\" % (i, seq))\n", + "\n", + "fname = 'prediction_performance'\n", + "for cP, params in enumerate(PL):\n", + "\n", + " data = {}\n", + "\n", + " # get data path\n", + " # load somatic spikes and dendritic current\n", + " somatic_spikes = shtm.helper.load_spike_data(model_instance.data_path, 'somatic_spikes')\n", + " idend_eval = shtm.helper.load_spike_data(model_instance.data_path, 'idend_eval')\n", + "\n", + " # load record and excitation times \n", + " idend_recording_times = shtm.helper.load_data(model_instance.data_path, 'idend_recording_times')\n", + " characters_to_subpopulations = shtm.helper.load_data(model_instance.data_path, 'characters_to_subpopulations')\n", + " excitation_times = shtm.helper.load_data(model_instance.data_path, 'excitation_times')\n", + "\n", + " # compute prediction performance\n", + " errors, false_positives, false_negatives, num_active_neurons = shtm.helper.compute_prediction_performance(somatic_spikes, idend_eval, idend_recording_times, characters_to_subpopulations, sequences, params)\n", + "\n", + " if compute_overlap:\n", + " # sequences overlap\n", + " sequences_overlap = shtm.helper.measure_sequences_overlap(sequences, somatic_spikes[:,1], somatic_spikes[:,0], excitation_times, params['fixed_somatic_delay'], params['learning_episodes'])\n", + " data['overlap'] = sequences_overlap\n", + "\n", + " data['error'] = errors\n", + " data['false_positive'] = false_positives\n", + " data['false_negative'] = false_negatives\n", + " data['rel_active_neurons'] = num_active_neurons/params['n_E']\n", + " data['ep_num'] = params['episodes_to_testing'] * np.arange(int(params['learning_episodes']/params['episodes_to_testing'])+1)\n", + "\n", + " ep_to_sol = np.where(errors < 0.01)[0] \n", + " if len(ep_to_sol) == 0:\n", + " print(\"number of episodes to convergence\", params['learning_episodes'])\n", + " else: \n", + " print(\"number of episodes to convergence\", data['ep_num'][ep_to_sol][0])\n", + "\n", + " # save data\n", + " np.save(\"%s\" % (fname), data)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def load_data(path, fname):\n", + " \"\"\"Load data\n", + "\n", + " Parameters\n", + " ----------\n", + " path: str\n", + " fname: str\n", + "\n", + " Returns\n", + " -------\n", + " data: ndarray\n", + " \"\"\"\n", + "\n", + " #TODO: this is temporary hack!\n", + " try:\n", + " data = np.load('%s/%s.npy' % (path, fname), allow_pickle=True).item()\n", + " except:\n", + " data = np.load('%s/%s.npy' % (path, fname), allow_pickle=True)\n", + "\n", + " return data\n", + "\n", + "\n", + "\n", + "# get parameters \n", + "PS = p\n", + "PS_sel = copy.deepcopy(PS)\n", + "\n", + "params = PS_sel\n", + "num_neurons = params['M'] * params['n_E']\n", + "\n", + "# get trained sequences and vocabulary\n", + "sequences = shtm.helper.load_data('.', 'training_data')\n", + "vocabulary = shtm.helper.load_data('.', 'vocabulary')\n", + "\n", + "print('#### sequences used for training ### ')\n", + "for i, sequence in enumerate(sequences):\n", + " seq = ''\n", + " for char in sequence:\n", + " seq += str(char).ljust(2)\n", + " print('sequence %d: %s' % (i, seq))\n", + "\n", + "# load spikes\n", + "somatic_spikes = shtm.helper.load_spike_data(model_instance.data_path, 'somatic_spikes')\n", + "idend = shtm.helper.load_spike_data(model_instance.data_path, 'idend_last_episode')\n", + "\n", + "# load spike recordings\n", + "idend_recording_times = shtm.helper.load_data(model_instance.data_path, 'idend_recording_times')\n", + "characters_to_subpopulations = shtm.helper.load_data(model_instance.data_path, 'characters_to_subpopulations')\n", + "characters_to_time_excitation = shtm.helper.load_data(model_instance.data_path, 'excitation_times_soma')\n", + "\n", + "# load excitation times\n", + "excitation_times = shtm.helper.load_data(model_instance.data_path, 'excitation_times')\n", + "\n", + "# get dendritic AP\n", + "idx = np.where((idend[:, 2] > params['soma_params']['theta_dAP']))[0]\n", + "dendriticAP_currents = idend[:, 2][idx]\n", + "dendriticAP_times = idend[:, 1][idx]\n", + "dendriticAP_senders = idend[:, 0][idx]\n", + "\n", + "# organize the characters for plotting purpose\n", + "subpopulation_indices = []\n", + "chars_per_subpopulation = []\n", + "for char in vocabulary:\n", + " # shift the subpopulation indices for plotting purposes \n", + " char_to_subpopulation_indices = characters_to_subpopulations[char]\n", + " subpopulation_indices.extend(char_to_subpopulation_indices)\n", + "\n", + " chars_per_subpopulation.extend(char * len(characters_to_subpopulations[char]))\n", + "\n", + "shifted_subpopulation_indices = np.array(subpopulation_indices) + 0.5\n", + "\n", + "# ####################################################\n", + "# plotting routing\n", + "# ----------------------------------------------------\n", + "\n", + "# plot settings \n", + "fig_size = (5.2, 5.7)\n", + "plt.rcParams['font.size'] = 8\n", + "plt.rcParams['legend.fontsize'] = 6\n", + "plt.rcParams['figure.figsize'] = fig_size\n", + "plt.rcParams['font.family'] = 'sans-serif'\n", + "plt.rcParams['savefig.dpi'] = 300\n", + "plt.rcParams['text.usetex'] = False\n", + "\n", + "panel_label_pos = (-0.14,0.5)\n", + "panel_labels = ['B', 'D', 'F']\n", + "color_soma_spike = '#DB2763'\n", + "color_dendrite_spike = '#00B4BE' \n", + "fc_bg = '#dcdcdc'\n", + "fraction_active = 3\n", + "delta_time = 5.\n", + "ymin = -0.1\n", + "ymax = 2\n", + "xmin = 0\n", + "master_file_name = 'network_activity'\n", + "\n", + "# set up the figure frame\n", + "fig = plt.figure()\n", + "gs = mpl.gridspec.GridSpec(6, 2, height_ratios=[3, 15, 3, 15, 3, 15], bottom=0.07, right=0.95, top=1., wspace=0., hspace=0.)\n", + "\n", + "# panel A (placeholder for svg figure to be inserted; see below)\n", + "panel_label_pos_shift = (-0.26, 0.5)\n", + "plt.subplot(gs[0, 0])\n", + "plt.axis('off')\n", + "\n", + "# panel C (placeholder for svg figure to be inserted; see below)\n", + "plt.subplot(gs[2, 0])\n", + "plt.axis('off')\n", + "\n", + "# panel C (placeholder for svg figure to be inserted; see below)\n", + "plt.subplot(gs[4, 0])\n", + "plt.axis('off')\n", + "\n", + "for j, (learn, seq_num) in enumerate(zip([False, True, True], [0, 0, 1])):\n", + "\n", + " ###################################\n", + " # postprocessing of data\n", + " # ---------------------------------\n", + " if learn and seq_num == 0:\n", + " start_time = characters_to_time_excitation[sequences[0][0]][-1] - params['pad_time']\n", + " end_time = characters_to_time_excitation[sequences[0][-1]][-1] + params['pad_time']\n", + " elif learn and seq_num == 1:\n", + " start_time = characters_to_time_excitation[sequences[1][0]][-1] - params['pad_time']\n", + " end_time = characters_to_time_excitation[sequences[1][-1]][-1] + params['pad_time']\n", + " else:\n", + " start_time = characters_to_time_excitation[sequences[0][0]][0] - params['pad_time']\n", + " end_time = characters_to_time_excitation[sequences[0][-1]][0] + params['pad_time']\n", + "\n", + " # select data corresponding to the different sequences\n", + " idx_somatic_spikes = np.where((somatic_spikes[:,1] > start_time) & (somatic_spikes[:,1] < end_time))\n", + " idx_dAP = np.where((dendriticAP_times > start_time) & (dendriticAP_times < end_time))\n", + "\n", + " # postprocess somatic spikes\n", + " somatic_spikes_times = somatic_spikes[:,1][idx_somatic_spikes]\n", + " somatic_spikes_senders = somatic_spikes[:,0][idx_somatic_spikes]\n", + " initial_time = somatic_spikes_times[0]\n", + " somatic_spikes_times -= initial_time\n", + " xmax = somatic_spikes_times[-1] + delta_time\n", + "\n", + " # postporcess dendritic AP\n", + " dAP_senders = dendriticAP_senders[idx_dAP]\n", + " dAP_currents = dendriticAP_currents[idx_dAP]\n", + " dAP_times = dendriticAP_times[idx_dAP]\n", + " dAP_times -= initial_time\n", + "\n", + " idx_exc_times = np.where((excitation_times > start_time) & (excitation_times < end_time))\n", + " excitation_times_sel = excitation_times[idx_exc_times]\n", + "\n", + " # ###############################\n", + " # draw stimulus\n", + " # -------------------------------\n", + " plt.subplot(gs[2*j, 1])\n", + " plt.axis('off')\n", + "\n", + " for i in range(len(sequences[seq_num])): \n", + "\n", + " x = (excitation_times_sel[i]+delta_time-initial_time) / (xmax+delta_time)\n", + " y = 0.26\n", + " arrow_width = 0.03\n", + " arrow_height = 0.2\n", + "\n", + " pos = [x, y]\n", + " X = np.array([pos, [pos[0]+arrow_width, pos[1]], [pos[0]+arrow_width/2, pos[1]-arrow_height]])\n", + " t1 = plt.Polygon(X, color='black')\n", + " plt.gca().add_patch(t1)\n", + " #plt.text(pos[0]+arrow_width/8, pos[1]+0.5, sequences[seq_num][i])\n", + " plt.text(pos[0]-0.003, pos[1]+0.1, sequences[seq_num][i])\n", + "\n", + " # ###############################\n", + " # show soma and dendritic spikes\n", + " # ------------------------------- \n", + " plt.subplot(gs[2*j+1, 1])\n", + "\n", + " senders_subsampled = somatic_spikes_senders[::fraction_active]\n", + " line1 = plt.plot(somatic_spikes_times[::fraction_active], somatic_spikes_senders[::fraction_active], 'o', color=color_soma_spike, lw=0., ms=0.5, zorder=2)\n", + "\n", + " #for k,v in count_indices_ds.items():\n", + " for sender in senders_subsampled:\n", + " idx_sub = np.where(dAP_senders == sender)\n", + " line2 = plt.plot(dAP_times[idx_sub], dAP_senders[idx_sub], color=color_dendrite_spike, lw=1., zorder=1)\n", + "\n", + " plt.xlim(-delta_time, xmax)\n", + " plt.ylim(-10, num_neurons+10)\n", + "\n", + " ticks_pos = shifted_subpopulation_indices * params['n_E']\n", + " ticks_label = chars_per_subpopulation\n", + " subpopulation_indices_background = np.arange(params['M'])*params['n_E']\n", + "\n", + " plt.yticks(ticks_pos, ticks_label)\n", + " plt.tick_params(labelbottom=False)\n", + "\n", + " for i in range(params['M'])[::2]:\n", + " plt.axhspan(subpopulation_indices_background[i], subpopulation_indices_background[i]+params['n_E'], facecolor=fc_bg, zorder=0)\n", + "\n", + " if j == 2:\n", + " plt.xlabel('time (ms)')\n", + " plt.tick_params(labelbottom=True)\n", + "\n", + " if j == 0:\n", + " labels = ['somatic spikes', 'dendritic AP']\n", + " plt.legend((line1[0], line2[0]), labels)\n", + "\n", + "plt.savefig('/tmp/%s.png' % (master_file_name))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Figure 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "p = para.ParameterSpace({})\n", + "\n", + "DELAY = 0.1\n", + "\n", + "p['dt'] = 0.1 # simulation time resolution (ms)\n", + "p['print_simulation_progress'] = False # print the time progress.\n", + "\n", + "# neuron parameters of the excitatory neurons\n", + "p['soma_model'] = neuron_model_name\n", + "p['soma_params'] = {}\n", + "p['soma_params']['C_m'] = 250. # membrane capacitance (pF)\n", + "p['soma_params']['E_L'] = 0. # resting membrane potential (mV)\n", + "# p['soma_params']['I_e'] = 0. # external DC currents (pA)\n", + "p['soma_params']['V_m'] = 0. # initial potential (mV)\n", + "p['soma_params']['V_reset'] = 0. # reset potential (mV)\n", + "p['soma_params']['V_th'] = 20. # spike threshold (mV)\n", + "p['soma_params']['t_ref'] = 10. # refractory period\n", + "p['soma_params']['tau_m'] = 10. # membrane time constant (ms)\n", + "p['soma_params']['tau_syn1'] = 2. # synaptic time constant: external input (receptor 1)\n", + "p['soma_params']['tau_syn2'] = 5. # synaptic time constant: dendrtic input (receptor 2)\n", + "p['soma_params']['tau_syn3'] = 1. # synaptic time constant: inhibitory input (receptor 3)\n", + "# dendritic action potential\n", + "p['soma_params']['I_p'] = 200. # current clamp value for I_dAP during a dendritic action potenti\n", + "p['soma_params']['tau_dAP'] = 60. # time window over which the dendritic current clamp is active\n", + "p['soma_params']['theta_dAP'] = 59. # current threshold for a dendritic action potential\n", + "\n", + "p['soma_params']['I_dend_incr'] = 2.71 / 10e-3\n", + "\n", + "\n", + "p['fixed_somatic_delay'] = 2 # this is an approximate time of how long it takes the soma to fire\n", + " # upon receiving an external stimulus \n", + "\n", + "# neuron parameters for the inhibitory neuron\n", + "p['inhibit_model'] = 'iaf_psc_exp'\n", + "p['inhibit_params'] = {}\n", + "p['inhibit_params']['C_m'] = 250. # membrane capacitance (pF)\n", + "p['inhibit_params']['E_L'] = 0. # resting membrane potential (mV)\n", + "p['inhibit_params']['I_e'] = 0. # external DC currents (pA)\n", + "p['inhibit_params']['V_m'] = 0. # initial potential (mV)\n", + "p['inhibit_params']['V_reset'] = 0. # reset potential (mV)\n", + "p['inhibit_params']['V_th'] = 15. # spike threshold (mV)\n", + "p['inhibit_params']['t_ref'] = 2.0 # refractory period\n", + "p['inhibit_params']['tau_m'] = 5. # membrane time constant (ms)\n", + "p['inhibit_params']['tau_syn_ex'] = .5 # synaptic time constant of an excitatory input (ms) \n", + "p['inhibit_params']['tau_syn_in'] = 1.65 # synaptic time constant of an inhibitory input (ms)\n", + "\n", + "# synaptic parameters\n", + "p['J_EX_psp'] = 1.1 * p['soma_params']['V_th'] # somatic PSP as a response to an external input\n", + "p['J_IE_psp'] = 1.2 * p['inhibit_params']['V_th'] # inhibitory PSP as a response to an input from E neuron\n", + "p['J_EI_psp'] = -2 * p['soma_params']['V_th'] # somatic PSP as a response to an inhibitory input\n", + "p['convergence'] = 5\n", + "p['pattern_size'] = 20\n", + "\n", + "# parameters for ee synapses (stdsp)\n", + "p['syn_dict_ee'] = {}\n", + "p['permanence_min'] = 0.\n", + "p['permanence_max'] = 8.\n", + "p['calibration'] = 40.\n", + "p['syn_dict_ee']['weight'] = 0.01 # synaptic weight\n", + "p['syn_dict_ee']['synapse_model'] = synapse_model_name # synapse model\n", + "p['syn_dict_ee']['permanence_threshold'] = 10. # synapse maturity threshold\n", + "p['syn_dict_ee']['tau_pre_trace'] = 20. # plasticity time constant (potentiation)\n", + "p['syn_dict_ee']['delay'] = 2. # dendritic delay \n", + "p['syn_dict_ee']['receptor_type'] = 2 # receptor corresponding to the dendritic input\n", + "p['syn_dict_ee']['lambda_plus'] = 0.05 #0.1 # potentiation rate\n", + "p['syn_dict_ee']['zt'] = 1. # target dAP trace [pA]\n", + "p['syn_dict_ee']['lambda_h'] = 0.01 # homeostasis rate\n", + "p['syn_dict_ee']['Wmax'] = 1.1 * p['soma_params']['theta_dAP'] / p['convergence'] # Maximum allowed weight\n", + "p['syn_dict_ee']['permanence_max'] = 20. # Maximum allowed permanence\n", + "p['syn_dict_ee']['permanence_min'] = 1. # Minimum allowed permanence\n", + "p['syn_dict_ee']['lambda_minus'] = 0.004\n", + "\n", + "# parameters of EX synapses (external to soma of E neurons)\n", + "p['conn_dict_ex'] = {}\n", + "p['syn_dict_ex'] = {}\n", + "p['syn_dict_ex']['receptor_type'] = 1 # receptor corresponding to external input\n", + "p['syn_dict_ex']['delay'] = DELAY # dendritic delay\n", + "p['conn_dict_ex']['rule'] = 'all_to_all' # connection rule\n", + "\n", + "# parameters of EdX synapses (external to dendrite of E neurons) \n", + "p['conn_dict_edx'] = {}\n", + "p['syn_dict_edx'] = {}\n", + "p['syn_dict_edx']['receptor_type'] = 2 # receptor corresponding to the dendritic input\n", + "p['syn_dict_edx']['delay'] = DELAY # dendritic delay\n", + "p['syn_dict_edx']['weight'] = 10.4 * p['soma_params']['theta_dAP']\n", + "p['conn_dict_edx']['rule'] = 'fixed_outdegree' # connection rule\n", + "p['conn_dict_edx']['outdegree'] = p['pattern_size'] + 1 # outdegree\n", + "\n", + "# parameters for IE synapses \n", + "p['syn_dict_ie'] = {}\n", + "p['conn_dict_ie'] = {}\n", + "p['syn_dict_ie']['synapse_model'] = 'static_synapse' # synapse model\n", + "p['syn_dict_ie']['delay'] = DELAY # dendritic delay\n", + "p['conn_dict_ie']['rule'] = 'fixed_indegree' # connection rule\n", + "p['conn_dict_ie']['indegree'] = 5 # indegree \n", + "\n", + "# parameters for EI synapses\n", + "p['syn_dict_ei'] = {}\n", + "p['conn_dict_ei'] = {}\n", + "p['syn_dict_ei']['synapse_model'] = 'static_synapse' # synapse model\n", + "p['syn_dict_ei']['delay'] = DELAY # dendritic delay\n", + "p['syn_dict_ei']['receptor_type'] = 3 # receptor corresponding to the inhibitory input \n", + "p['conn_dict_ei']['rule'] = 'fixed_indegree' # connection rule\n", + "p['conn_dict_ei']['indegree'] = 20 # indegree" + ] + }, { "cell_type": "code", "execution_count": null, @@ -800,7 +1130,7 @@ " nest.SetKernelStatus({\n", " 'resolution': params['dt'],\n", " 'print_time': params['print_simulation_progress'],\n", - " 'local_num_threads': params['n_threads'],\n", + " #'local_num_threads': n_threads\n", " 'rng_seed': seed\n", " })\n", "\n", @@ -1082,13 +1412,6 @@ "\n", "p['dt'] = 0.1 # simulation time resolution (ms)\n", "p['print_simulation_progress'] = True # print the time progress.\n", - "p['n_threads'] = 1 # number of threads per MPI process \n", - "\n", - "# data path dict\n", - "p['data_path'] = {}\n", - "p['data_path']['data_root_path'] = 'data'\n", - "p['data_path']['project_name'] = 'sequence_learning_performance'\n", - "p['data_path']['parameterspace_label'] = 'plasticity_dynamics'\n", "\n", "# neuron parameters of the excitatory neurons\n", "p['soma_model'] = neuron_model_name\n", @@ -1118,8 +1441,8 @@ "\n", "# parameters for ee synapses (stdsp)\n", "p['syn_dict_ee'] = {}\n", - "p['p_min'] = 0.\n", - "p['p_max'] = 8.\n", + "p['permanence_min'] = 0.\n", + "p['permanence_max'] = 8.\n", "p['calibration'] = 0.\n", "p['syn_dict_ee']['weight'] = 0.01 # synaptic weight\n", "p['syn_dict_ee']['synapse_model'] = synapse_model_name # synapse model\n", @@ -1157,7 +1480,7 @@ "nest.SetKernelStatus({\n", " 'resolution': params['dt'],\n", " 'print_time': params['print_simulation_progress'],\n", - " 'local_num_threads': params['n_threads'],\n", + " #'local_num_threads': n_threads,\n", " 'rng_seed': seed\n", "})" ] diff --git a/pynestml/codegeneration/nest_code_generator.py b/pynestml/codegeneration/nest_code_generator.py index c04bdad7f..cdd4b9279 100644 --- a/pynestml/codegeneration/nest_code_generator.py +++ b/pynestml/codegeneration/nest_code_generator.py @@ -58,6 +58,7 @@ from pynestml.meta_model.ast_node_factory import ASTNodeFactory from pynestml.meta_model.ast_ode_equation import ASTOdeEquation from pynestml.symbol_table.symbol_table import SymbolTable +from pynestml.symbols.boolean_type_symbol import BooleanTypeSymbol from pynestml.symbols.real_type_symbol import RealTypeSymbol from pynestml.symbols.unit_type_symbol import UnitTypeSymbol from pynestml.symbols.symbol import SymbolKind