Example #1
0
    def _create_cells(self, cellclass, cellparams, n):
        """
        Create cells in NEST.
        
        `cellclass`  -- a PyNN standard cell or the name of a native NEST model.
        `cellparams` -- a dictionary of cell parameters.
        `n`          -- the number of cells to create
        """
        # this method should never be called more than once
        # perhaps should check for that
        assert n > 0, 'n must be a positive integer'
        n = int(n)

        celltype = cellclass(cellparams)
        nest_model = celltype.nest_name[simulator.state.spike_precision]
        try:
            self.all_cells = nest.Create(nest_model,
                                         n,
                                         params=celltype.parameters)
        except nest.NESTError, err:
            if "UnknownModelName" in err.message and "cond" in err.message:
                raise errors.InvalidModelError(
                    "%s Have you compiled NEST with the GSL (Gnu Scientific Library)?"
                    % err)
            raise errors.InvalidModelError(err)
Example #2
0
 def _create_cells(self):
     """
     Create cells in NEST using the celltype of the current Population.
     """
     # this method should never be called more than once
     # perhaps should check for that
     nest_model = self.celltype.nest_name[simulator.state.spike_precision]
     if isinstance(self.celltype, StandardCellType):
         params = _build_params(
             self.celltype.native_parameters,
             None,
             size=self.size,
             extra_parameters=self.celltype.extra_parameters)
     else:
         params = _build_params(self.celltype.parameter_space,
                                None,
                                size=self.size)
     try:
         self.all_cells = nest.Create(nest_model, self.size, params=params)
     except nest.NESTError, err:
         if "UnknownModelName" in err.message and "cond" in err.message:
             raise errors.InvalidModelError(
                 "%s Have you compiled NEST with the GSL (Gnu Scientific Library)?"
                 % err)
         raise  #errors.InvalidModelError(err)
Example #3
0
 def _create_cells(self):
     """
     Create cells in NEST using the celltype of the current Population.
     """
     # this method should never be called more than once
     # perhaps should check for that
     nest_model = self.celltype.nest_name[simulator.state.spike_precision]
     if isinstance(self.celltype, StandardCellType):
         self.celltype.parameter_space.shape = (
             self.size, )  # should perhaps do this on a copy?
         params = _build_params(
             self.celltype.native_parameters,
             None,
             size=self.size,
             extra_parameters=self.celltype.extra_parameters)
     else:
         params = _build_params(self.celltype.parameter_space,
                                None,
                                size=self.size)
     try:
         self.node_collection = nest.Create(nest_model,
                                            self.size,
                                            params=params)
     except nest.NESTError as err:
         if "UnknownModelName" in err.args[0] and "cond" in err.args[0]:
             raise errors.InvalidModelError(
                 "%s Have you compiled NEST with the GSL (Gnu Scientific Library)?"
                 % err)
         if "Spike times must be sorted in non-descending order" in err.args[
                 0]:
             raise errors.InvalidParameterValueError(
                 "Spike times given to SpikeSourceArray must be in increasing order"
             )
         raise  # errors.InvalidModelError(err)
     # create parrot neurons if necessary
     if hasattr(self.celltype, "uses_parrot") and self.celltype.uses_parrot:
         self.node_collection_source = self.node_collection  # we put the parrots into all_cells, since this will
         parrot_model = simulator.state.spike_precision == "off_grid" and "parrot_neuron_ps" or "parrot_neuron"
         self.node_collection = nest.Create(
             parrot_model, self.size
         )  # be used for connections and recording. all_cells_source
         # should be used for setting parameters
         self._deferred_parrot_connections = True
         # connecting up the parrot neurons is deferred until we know the value of min_delay
         # which could be 'auto' at this point.
     if self.node_collection.local is True:
         self._mask_local = np.array([True])
     else:
         self._mask_local = np.array(self.node_collection.local)
     self.all_cells = np.array(
         [simulator.ID(gid) for gid in self.node_collection.tolist()],
         simulator.ID)
     for gid in self.all_cells:
         gid.parent = self
         gid.node_collection = nest.NodeCollection([int(gid)])
     if hasattr(self.celltype, "uses_parrot") and self.celltype.uses_parrot:
         for gid, source in zip(self.all_cells,
                                self.node_collection_source.tolist()):
             gid.source = source
Example #4
0
 def _create_cells(self):
     """
     Create cells in NEST using the celltype of the current Population.
     """
     # this method should never be called more than once
     # perhaps should check for that
     nest_model = self.celltype.nest_name[simulator.state.spike_precision]
     if isinstance(self.celltype, StandardCellType):
         self.celltype.parameter_space.shape = (
             self.size, )  # should perhaps do this on a copy?
         params = _build_params(
             self.celltype.native_parameters,
             None,
             size=self.size,
             extra_parameters=self.celltype.extra_parameters)
     else:
         params = _build_params(self.celltype.parameter_space,
                                None,
                                size=self.size)
     try:
         self.all_cells = nest.Create(nest_model, self.size, params=params)
     except nest.NESTError as err:
         if "UnknownModelName" in err.args[0] and "cond" in err.args[0]:
             raise errors.InvalidModelError(
                 "%s Have you compiled NEST with the GSL (Gnu Scientific Library)?"
                 % err)
         raise  #errors.InvalidModelError(err)
     # create parrot neurons if necessary
     if hasattr(self.celltype, "uses_parrot") and self.celltype.uses_parrot:
         self.all_cells_source = numpy.array(
             self.all_cells
         )  # we put the parrots into all_cells, since this will
         self.all_cells = nest.Create(
             "parrot_neuron_ps", self.size
         )  # be used for connections and recording. all_cells_source
         # should be used for setting parameters
         nest.Connect(
             self.all_cells_source,
             numpy.array(self.all_cells),
             'one_to_one',
             syn_spec={'delay': simulator.state.dt}
         )  # for efficiency, we should defer this until after network construction,
         # and use min_delay (at this point, min_delay could be 'auto')
     self._mask_local = numpy.array(nest.GetStatus(self.all_cells, 'local'))
     self.all_cells = numpy.array(
         [simulator.ID(gid) for gid in self.all_cells], simulator.ID)
     for gid in self.all_cells:
         gid.parent = self
     if hasattr(self.celltype, "uses_parrot") and self.celltype.uses_parrot:
         for gid, source in zip(self.all_cells, self.all_cells_source):
             gid.source = source