| 8 | | \begin{verbatim} |
|---|
| 9 | | >>> setup() |
|---|
| 10 | | \end{verbatim} |
|---|
| 11 | | \verb|setup()| takes various optional arguments: setting the simulation timestep (there is currently no support in the API for variable timestep methods although native simulator code can be used to select this option where the simulator supports it), setting the minimum and maximum synaptic delays, and turning debugging output on and off, e.g.: |
|---|
| 12 | | \begin{verbatim} |
|---|
| 13 | | >>> setup(timestep=0.1, min_delay=0.1, max_delay=0.5, debug=False) |
|---|
| 14 | | \end{verbatim} |
|---|
| 15 | | Debugging information is written to a log file in the working directory. |
|---|
| | 8 | \begin{verbatim} |
|---|
| | 9 | >>> setup(timestep=0.1, min_delay=0.1, |
|---|
| | 10 | max_delay=0.5, debug=False) |
|---|
| | 11 | \end{verbatim} |
|---|
| | 12 | |
|---|
| | 13 | Some simulators accept additional arguments, e.g. |
|---|
| | 14 | \begin{verbatim} |
|---|
| | 15 | >>> setup(threads=2) # nest2, pcsim |
|---|
| | 16 | \end{verbatim} |
|---|
| | 17 | |
|---|
| | 18 | \begin{verbatim} |
|---|
| | 19 | >>> setup(rngseeds=[12345,67890]) # nest2 |
|---|
| | 20 | \end{verbatim} |
|---|
| 27 | | Here, \verb|IF_curr_alpha| is a particular class of IF neuron with alpha-function shaped synaptic currents, that will work with any PyNN simulation engine, whether NEURON, NEST or PCSIM. |
|---|
| 28 | | \verb|IF_curr_alpha| is a so-called 'standard cell', implemented as a Python class. |
|---|
| 29 | | For more information, see the section StandardCells. |
|---|
| | 32 | Here, \verb|IF_curr_alpha| is a so-called 'standard cell', which will work with any PyNN backend, whether NEURON, NEST or PCSIM.\vspace{1ex} |
|---|
| 34 | | >>> create('iaf_neuron') |
|---|
| 35 | | \end{verbatim} |
|---|
| 36 | | \verb|iaf_neuron| is a neuron model available in the NEST simulator. |
|---|
| 37 | | Note that the model name has to be given as a string for simulator-specific models. |
|---|
| 38 | | |
|---|
| 39 | | To create many neurons at once, add the \verb|n| argument, e.g. |
|---|
| 40 | | \begin{verbatim} |
|---|
| 41 | | >>> create(IF_curr_alpha, n=10) |
|---|
| 42 | | \end{verbatim} |
|---|
| | 37 | >>> create("iaf_neuron") # NEST only |
|---|
| | 38 | \end{verbatim} |
|---|
| | 39 | |
|---|
| | 40 | \end{frame} |
|---|
| | 41 | |
|---|
| | 42 | |
|---|
| | 43 | \begin{frame}[fragile] % ------------------------------------------------------------ |
|---|
| | 44 | \frametitle{Creating neurons} |
|---|
| | 45 | |
|---|
| | 46 | To create many neurons at once, add the \verb|n| argument: |
|---|
| | 47 | \begin{verbatim} |
|---|
| | 48 | >>> create(IF_curr_alpha, n=10)\end{verbatim} |
|---|
| 44 | | stored in the \verb|default_values| of the standard cell class, e.g.: |
|---|
| 45 | | \begin{verbatim} |
|---|
| 46 | | >>> IF_curr_alpha.default_parameters #doctest" +NORMALIZE_WHITESPACE |
|---|
| 47 | | {'tau_refrac': 0.0, 'tau_m': 20.0, 'i_offset': 0.0, 'cm': 1.0, 'v_init': -65.0, |
|---|
| 48 | | 'v_thresh': -50.0, 'tau_syn_E': 0.5, 'v_rest': -65.0, 'tau_syn_I': 0.5, |
|---|
| 49 | | 'v_reset': -65.0} |
|---|
| 50 | | \end{verbatim} |
|---|
| 51 | | To use different parameter values, use the \verb|param_dict| argument, e.g.: |
|---|
| 52 | | \begin{verbatim} |
|---|
| 53 | | >>> create(IF_curr_alpha, param_dict={'tau_m': 15.0, 'cm': 0.9}, n=10) |
|---|
| 54 | | \end{verbatim} |
|---|
| | 50 | stored in the \verb|default_values| of the standard cell class: |
|---|
| | 51 | \begin{verbatim} |
|---|
| | 52 | >>> IF_curr_alpha.default_parameters |
|---|
| | 53 | {'tau_refrac': 0.0, 'tau_m': 20.0, 'i_offset': 0.0, |
|---|
| | 54 | 'cm': 1.0, 'v_init': -65.0, 'v_thresh': -50.0, |
|---|
| | 55 | 'tau_syn_E': 0.5, 'v_rest': -65.0, 'tau_syn_I': 0.5, |
|---|
| | 56 | 'v_reset': -65.0}\end{verbatim} |
|---|
| | 57 | To use different parameter values, use the \verb|param_dict| argument: |
|---|
| | 58 | \begin{verbatim} |
|---|
| | 59 | >>> create(IF_curr_alpha, |
|---|
| | 60 | param_dict={'tau_m': 15.0, 'cm': 0.9}, |
|---|
| | 61 | n=10) |
|---|
| | 62 | \end{verbatim} |
|---|
| | 63 | |
|---|
| | 64 | \end{frame} |
|---|
| | 65 | |
|---|
| | 66 | |
|---|
| | 67 | \begin{frame}[fragile] % ------------------------------------------------------------ |
|---|
| | 68 | \frametitle{Creating neurons} |
|---|
| | 69 | |
|---|
| 56 | | \begin{verbatim} |
|---|
| 57 | | >>> create(IF_curr_alpha, param_dict={'foo': 15.0}) |
|---|
| 58 | | Traceback (most recent call last): |
|---|
| 59 | | File "<stdin>", line 1, in ? |
|---|
| 60 | | File "/usr/lib/python/site-packages/pyNN/nest1.py", line 228, in create |
|---|
| 61 | | celltype = cellclass(param_dict) |
|---|
| 62 | | File "/usr/lib/python/site-packages/pyNN/nest1.py", line 68, in __init__ |
|---|
| 63 | | common.IF_curr_alpha.__init__(self,parameters) # checks supplied parameters and adds default |
|---|
| 64 | | File "/usr/lib/python/site-packages/pyNN/common.py", line 113, in __init__ |
|---|
| 65 | | self.parameters = self.checkParameters(parameters, with_defaults=True) |
|---|
| 66 | | File "/usr/lib/python/site-packages/pyNN/common.py", line 99, in checkParameters |
|---|
| 67 | | raise NonExistentParameterError(k) |
|---|
| 68 | | NonExistentParameterError: foo |
|---|
| 69 | | >>> create(IF_curr_alpha, param_dict={'tau_m': 'bar'}) |
|---|
| 70 | | Traceback (most recent call last): |
|---|
| 71 | | File "/usr/lib/python/site-packages/pyNN/nest1.py", line 228, in create |
|---|
| 72 | | celltype = cellclass(param_dict) |
|---|
| 73 | | File "/usr/lib/python/site-packages/pyNN/nest1.py", line 68, in __init__ |
|---|
| 74 | | common.IF_curr_alpha.__init__(self,parameters) # checks supplied parameters and adds default |
|---|
| 75 | | File "/usr/lib/python/site-packages/pyNN/common.py", line 113, in __init__ |
|---|
| 76 | | self.parameters = self.checkParameters(parameters, with_defaults=True) |
|---|
| 77 | | File "/usr/lib/python/site-packages/pyNN/common.py", line 90, in checkParameters |
|---|
| 78 | | raise InvalidParameterValueError, (type(supplied_parameters[k]), type(default_parameters[k])) |
|---|
| 79 | | InvalidParameterValueError: (<type 'str'>, <type 'float'>) |
|---|
| 80 | | \end{verbatim} |
|---|
| 81 | | |
|---|
| | 71 | \begin{verbatim} |
|---|
| | 72 | >>> create(IF_curr_alpha, param_dict={'foo': 15.0}) |
|---|
| | 73 | Traceback (most recent call last): |
|---|
| | 74 | . . . |
|---|
| | 75 | NonExistentParameterError: foo |
|---|
| | 76 | |
|---|
| | 77 | >>> create(IF_curr_alpha, param_dict={'tau_m': 'bar'}) |
|---|
| | 78 | Traceback (most recent call last): |
|---|
| | 79 | . . . |
|---|
| | 80 | InvalidParameterValueError: (<type 'str'>, <type 'float'>) |
|---|
| | 81 | \end{verbatim} |
|---|
| | 82 | |
|---|
| | 83 | \end{frame} |
|---|
| | 84 | |
|---|
| | 85 | |
|---|
| | 86 | \begin{frame}[fragile] % ------------------------------------------------------------ |
|---|
| | 87 | \frametitle{Creating neurons} |
|---|
| 97 | | >>> spike_source = create(SpikeSourceArray, param_dict={'spike_times': [10.0, 20.0, 30.0]}) |
|---|
| 98 | | >>> cell_list2 = create(IF_curr_exp, n=10) |
|---|
| 99 | | >>> connect(spike_source, cell_list2) |
|---|
| 100 | | \end{verbatim} |
|---|
| 101 | | In this case we connect a spike-generating mechanism (\verb|SpikeSourceArray| is a 'standard cell' model that emits spikes at times specified by the \verb|spike_times| parameter) to each cell in the list \verb|cells|, i.e. we create 10 connections at once. |
|---|
| | 103 | >>> times = [10.0, 20.0, 30.0] |
|---|
| | 104 | >>> spike_source = create(SpikeSourceArray, |
|---|
| | 105 | {'spike_times': times}) |
|---|
| | 106 | >>> cell_list2 = create(IF_curr_exp, n=10) |
|---|
| | 107 | >>> connect(spike_source, cell_list2)\end{verbatim} |
|---|
| | 108 | In this case we connect a spike-generating mechanism to each cell in the list \verb|cells|, i.e. we create 10 connections at once. |
|---|
| | 109 | \end{frame} |
|---|
| | 110 | |
|---|
| | 111 | |
|---|
| | 112 | \begin{frame}[fragile] % -------------------------------------------------------------------- |
|---|
| | 113 | \frametitle{Connecting neurons} |
|---|
| 107 | | In the latter case, each source (presynaptic) cell is connected to every target (postsynaptic) cell with probability given by the optional argument `p`, which defaults to 1, e.g.: |
|---|
| 108 | | \begin{verbatim} |
|---|
| 109 | | >>> source_list = cell_list |
|---|
| 110 | | >>> target_list = cell_list2 |
|---|
| 111 | | >>> connect(source_list, target_list, p=0.5) |
|---|
| 112 | | \end{verbatim} |
|---|
| 113 | | When specifying connections as above, default values are given to the synaptic weight and delay. |
|---|
| 114 | | These values are seldom very useful, and it is better to specify the \verb|weight| and \verb|delay| arguments of \verb|connect()|, e.g.: |
|---|
| 115 | | \begin{verbatim} |
|---|
| 116 | | >>> connect(source_list, target_list, weight=1.5, delay=0.5) |
|---|
| 117 | | \end{verbatim} |
|---|
| 118 | | Weights are specified in nA for 'current-based' synapses or $\mu$S for 'conductance-based' synapses. |
|---|
| | 118 | In the latter case, each source (presynaptic) cell is connected to every target (postsynaptic) cell with probability given by the optional argument \verb|p|, which defaults to 1, e.g.: |
|---|
| | 119 | \begin{verbatim} |
|---|
| | 120 | >>> source_list = cell_list |
|---|
| | 121 | >>> target_list = cell_list2 |
|---|
| | 122 | >>> connect(source_list, target_list, p=0.5) |
|---|
| | 123 | \end{verbatim} |
|---|
| | 124 | \end{frame} |
|---|
| | 125 | |
|---|
| | 126 | |
|---|
| | 127 | \begin{frame}[fragile] % -------------------------------------------------------------------- |
|---|
| | 128 | \frametitle{Connecting neurons} |
|---|
| | 129 | \framesubtitle{Specifying weights and delays} |
|---|
| | 130 | |
|---|
| | 131 | \begin{verbatim} |
|---|
| | 132 | >>> connect(source_list, target_list, |
|---|
| | 133 | weight=1.5, delay=0.5)\end{verbatim} |
|---|
| | 134 | |
|---|
| | 135 | {\footnotesize (Weights are in nA for 'current-based' synapses or $\mu$S for 'conductance-based' synapses. |
|---|
| 134 | | |
|---|
| 135 | | There are many ways to change the parameters for individual neurons and post-synaptic mechanisms after creation of the neuron. |
|---|
| 136 | | To change a single parameter of a single neuron, just set the relevant attribute of the neuron ID object, e.g.: |
|---|
| 137 | | \begin{verbatim} |
|---|
| 138 | | >>> cells = create(IF_curr_exp, param_dict={'v_init': -70.0}, n=10) |
|---|
| | 152 | \framesubtitle{for a single cell} |
|---|
| | 153 | |
|---|
| | 154 | To change a single parameter of a single neuron, set the relevant attribute of the neuron ID object, e.g.: |
|---|
| | 155 | \begin{verbatim} |
|---|
| | 156 | >>> cells = create(IF_curr_exp, n=10) |
|---|
| 197 | | The beginning of a typical spike file looks like: |
|---|
| 198 | | \begin{verbatim} |
|---|
| 199 | | # dt = 0.1 |
|---|
| 200 | | # n = 1000 |
|---|
| 201 | | 0.0 2 |
|---|
| 202 | | 0.3 5 |
|---|
| 203 | | 0.4 3 |
|---|
| 204 | | 0.9 2 |
|---|
| 205 | | 1.0 1 |
|---|
| 206 | | . . . |
|---|
| 207 | | \end{verbatim} |
|---|
| 208 | | The beginning of a typical membrane potential file looks like: |
|---|
| 209 | | \begin{verbatim} |
|---|
| 210 | | # dt = 0.1 |
|---|
| 211 | | # n = 1000 |
|---|
| 212 | | -65.0 0 |
|---|
| 213 | | -64.9 0 |
|---|
| 214 | | -64.7 0 |
|---|
| 215 | | -64.5 0 |
|---|
| 216 | | . . . |
|---|
| 217 | | \end{verbatim} |
|---|
| 218 | | Both file types begin with header lines giving the timestep (there is currently no support for variable-time step recording) and the number of data points in the file. |
|---|
| 219 | | Each line of the spike file then gives the occurence time of a spike (in ms) and the id of the neuron in which it was recorded. |
|---|
| 220 | | Each line of the membrane potential file gives the membrane potential (in mV) followed by the id of the neuron in which it was recorded. |
|---|
| 221 | | In both cases, whether the file is sorted by cell id or by time depends on the simulator: it is not standardised. |
|---|
| 222 | | |
|---|
| 223 | | In some cases it is more efficient to write files in the simulator's native format, rather than the standard PyNN format. |
|---|
| 224 | | In this case, use the \verb|compatible_output=False| argument to the \verb|end()| function. |
|---|
| 225 | | |
|---|
| 226 | | Considerable enhancements to file formats are planned for future releases of PyNN, including recording to binary (HDF5) rather than text files, support for variable time-step recording, and user-specified output formats. |
|---|
| 227 | | |
|---|
| | 219 | Typical spike file Typical membrane potential file |
|---|
| | 220 | \begin{verbatim} |
|---|
| | 221 | # dt = 0.1 # dt = 0.1 |
|---|
| | 222 | # n = 1000 # n = 10000 |
|---|
| | 223 | 0.0 2 -65.0 0 |
|---|
| | 224 | 0.3 5 -64.9 0 |
|---|
| | 225 | 0.4 3 -64.7 0 |
|---|
| | 226 | 0.9 2 -64.5 0 |
|---|
| | 227 | . . . . . . |
|---|
| | 228 | \end{verbatim} |
|---|
| | 229 | |
|---|
| | 230 | \end{frame} |
|---|
| | 231 | |
|---|
| | 232 | |
|---|
| | 233 | \begin{frame}[fragile] % -------------------------------------------------------------------- |
|---|
| | 234 | \frametitle{Recording spikes and membrane potential} |
|---|
| | 235 | |
|---|
| | 236 | \small |
|---|
| | 237 | \begin{itemize} |
|---|
| | 238 | \item Header contains the timestep (no support for variable-timestep recording) and the number of data points in the file. |
|---|
| | 239 | \item Each line of the spike file gives the occurence time of a spike (in ms) and the id of the neuron in which it was recorded. |
|---|
| | 240 | \item Each line of the membrane potential file gives the membrane potential (in mV) followed by the id of the neuron in which it was recorded. |
|---|
| | 241 | \item Whether the file is sorted by cell id or by time depends on the simulator: it is not standardised. |
|---|
| | 242 | \item In some cases it is more efficient to write files in the simulator's native format, rather than the standard PyNN format. |
|---|
| | 243 | In this case, use \verb|end(compatible_output=False)| function. |
|---|
| | 244 | \item Enhancements to file formats in future releases of PyNN: recording to binary files (HDF5), support for variable time-step recording, and user-specified output formats. |
|---|
| | 245 | \end{itemize} |
|---|