Example #1
0
 def connect_nest_nodes(self):
     n_nodes = len(self.nest_nodes_ids)
     # For every different type of connections between distinct NEST nodes' populations
     for i_conn, conn in enumerate(ensure_list(self.node_connections)):
         conn_spec = self.default_synapse['params']
         conn_spec.update(conn['params'])
         model = conn.get("model", self.default_synapse["model"])
         weight = conn.get("weight", 1.0)
         delay = conn.get("delay", 0.0)
         # Define functions for the exact synthesis of source and target populations
         pop_src = lambda node: \
             flatten_tuple([node[pop]
                            for pop in ensure_list(conn['src_population'])])
         pop_trg = lambda node: \
             flatten_tuple([node[pop]
                            for pop in ensure_list(conn['trg_population'])])
         # ...and form the connection for every distinct pair of NEST nodes
         # TODO! Confirm that no self connections are allowed here!
         for i_n1 in range(n_nodes - 1):
             for i_n2 in range(1, n_nodes):
                 if self.tvb_weights[i_n1, i_n2] > 0:
                     self._connect_two_populations_between_nodes(
                         pop_src(self.nodes[i_n1]),
                         pop_trg(self.nodes[i_n2]), i_n1, i_n2, conn_spec,
                         model, weight, delay)
                 if self.tvb_weights[i_n2, i_n1] > 0:
                     self._connect_two_populations_between_nodes(
                         pop_src(self.nodes[i_n2]),
                         pop_trg(self.nodes[i_n1]), i_n2, i_n1, conn_spec,
                         model, weight, delay)
Example #2
0
def get_neurons_from_populations(population, index=None):
    try:
        # In case this is a list, tuple or dictionary (in which case index is a key)...
        return flatten_tuple(population[index])
    except:
        # Otherwise, if index is None, return the whole tuple of neurons' indices...
        return flatten_tuple(population)
Example #3
0
 def connect_nest_nodes(self):
     # Define a function for the exact synthesis of source and target populations
     population = lambda node, populations: \
         flatten_tuple([node[pop] for pop in ensure_list(populations)])
     # For every different type of connections between distinct NEST nodes' populations
     for i_conn, conn in enumerate(ensure_list(self.nodes_connections)):
         model = property_to_fun(conn["model"])
         weight = property_to_fun(conn["weight"])
         delay = property_to_fun(conn["delay"])
         receptor_type = property_to_fun(conn["receptor_type"])
         conn_spec = property_to_fun(conn['conn_spec'])
         # ...and form the connection for every distinct pair of NEST nodes
         for source_index in conn["source_nodes"]:
             i_source_node = np.where(
                 self.nest_nodes_ids == source_index)[0][0]
             for target_index in conn["target_nodes"]:
                 if source_index != target_index:  # TODO! Confirm that no self connections are allowed here!
                     i_target_node = np.where(
                         self.nest_nodes_ids == target_index)[0][0]
                     if self.tvb_weights[source_index, target_index] > 0:
                         self._connect_two_populations_between_nodes(
                             population(self.nodes[i_source_node],
                                        conn["source"]),
                             population(self.nodes[i_target_node],
                                        conn["target"]), i_source_node,
                             i_target_node,
                             conn_spec(source_index, target_index),
                             model(source_index, target_index),
                             weight(source_index, target_index),
                             delay(source_index, target_index),
                             receptor_type(source_index, target_index))
 def neurons(self, indices_or_keys=None):
     # Return the neurons of this region...
     if indices_or_keys is None:
         # ...either of all populations...
         return flatten_tuple(self)
     else:
         # ...or of selected ones:
         return self.__getitem__(indices_or_keys)
Example #5
0
 def get_senders(self, neurons=None, sort=False):
     senders = self.nest_instance.GetStatus(
         self.device)[0]['events']['senders'].tolist()
     if neurons is not None:
         neurons = flatten_tuple(neurons)
         new_senders = []
         for sender in senders:
             if sender in neurons:
                 new_senders.append(sender)
         senders = new_senders
     if sort:
         senders.sort()
     return senders
Example #6
0
 def get_times(self, neurons=[]):
     times = self.nest_instance.GetStatus(
         self.device)[0]['events']['times'].tolist()
     if neurons is not None:
         neurons = flatten_tuple(neurons)
         senders = self.nest_instance.GetStatus(
             self.device)[0]['events']['senders'].tolist()
         new_times = []
         for time, sender in zip(times, senders):
             if sender in neurons:
                 new_times.append(time)
         times = new_times
     return times
Example #7
0
 def _get_node_populations_neurons(self, node, populations):
     return flatten_tuple([node[pop] for pop in ensure_list(populations)])
Example #8
0
 def _get_node_populations_neurons(self, node, populations):
     # return handles to all neurons of specific neural populations of a Spiking Node
     return flatten_tuple([node[pop] for pop in ensure_list(populations)])
 def neurons(self, indices_or_keys=None):
     if indices_or_keys is None:
         return flatten_tuple(self)
     else:
         return self.__getitem__(indices_or_keys)
 def __getitem__(self, keys):
     return flatten_tuple(super(NESTRegionNode, self).__getitem__(keys))
Example #11
0
 def __getitem__(self, keys):
     # return the neurons' indices/handles of specific populations (keys) of this RegionNode
     return flatten_tuple(super(SpikingRegionNode, self).__getitem__(keys))