def connect_isotropic(self, conn_type="ee"): """ conn_type must be 'ee', 'ei', 'ie' or 'ii' Connect cells in a distant dependent manner: p_ij = exp(- d_ij / (2 * w_sigma_x**2)) This will give a 'convergence constrained' connectivity, i.e. each cell will have the same sum of incoming weights ---> could be problematic for outlier cells """ if self.pc_id == 0: print "Connect isotropic %s - %s" % (conn_type[0].capitalize(), conn_type[1].capitalize()) (n_src, n_tgt, src_pop, tgt_pop, tp_src, tp_tgt, tgt_cells, syn_type) = self.resolve_src_tgt(conn_type) if conn_type == "ee": w_ = self.params["w_max"] w_tgt_in = params["w_tgt_in_per_cell_%s" % conn_type] n_max_conn = n_src * n_tgt - n_tgt elif conn_type == "ei": w_ = self.params["w_ei_mean"] w_tgt_in = params["w_tgt_in_per_cell_%s" % conn_type] n_max_conn = n_src * n_tgt elif conn_type == "ie": w_ = self.params["w_ie_mean"] w_tgt_in = params["w_tgt_in_per_cell_%s" % conn_type] n_max_conn = n_src * n_tgt elif conn_type == "ii": w_ = self.params["w_ii_mean"] w_tgt_in = params["w_tgt_in_per_cell_%s" % conn_type] n_max_conn = n_src * n_tgt - n_tgt if self.debug_connectivity: conn_list_fn = self.params["conn_list_%s_fn_base" % conn_type] + "%d.dat" % (self.pc_id) # conn_file = open(conn_list_fn, 'w') # output = '' # output_dist = '' w_mean = w_tgt_in / (self.params["p_%s" % conn_type] * n_max_conn / n_tgt) w_sigma = self.params["w_sigma_distribution"] * w_mean w_dist = RandomDistribution( "normal", (w_mean, w_sigma), rng=self.rng_conn, constrain="redraw", boundaries=(0, w_mean * 10.0) ) delay_dist = RandomDistribution( "normal", (self.params["standard_delay"], self.params["standard_delay_sigma"]), rng=self.rng_conn, constrain="redraw", boundaries=(self.params["delay_range"][0], self.params["delay_range"][1]), ) p_max = utils.get_pmax(self.params["p_%s" % conn_type], self.params["w_sigma_isotropic"], conn_type) connector = DistanceDependentProbabilityConnector( "%f * exp(-d/(2*%f**2))" % (p_max, params["w_sigma_isotropic"]), allow_self_connections=False, weights=w_dist, delays=delay_dist, space=self.torus, ) # , n_connections=n_conn_ee) print "p_max for %s" % conn_type, p_max if self.params["with_short_term_depression"]: prj = Projection(src_pop, tgt_pop, connector, target=syn_type, synapse_dynamics=self.short_term_depression) else: prj = Projection(src_pop, tgt_pop, connector, target=syn_type) # , synapse_dynamics=self.STD) self.projections[conn_type].append(prj) if self.debug_connectivity: # if self.pc_id == 0: # print 'DEBUG writing to file:', conn_list_fn prj.saveConnections(self.params["conn_list_%s_fn_base" % conn_type] + ".dat", gather=True)
def connect_isotropic(self, conn_type='ee'): """ conn_type must be 'ee', 'ei', 'ie' or 'ii' Connect cells in a distant dependent manner: p_ij = exp(- d_ij / (2 * w_sigma_x**2)) This will give a 'convergence constrained' connectivity, i.e. each cell will have the same sum of incoming weights ---> could be problematic for outlier cells """ if self.pc_id == 0: print 'Connect isotropic %s - %s' % (conn_type[0].capitalize(), conn_type[1].capitalize()) (n_src, n_tgt, src_pop, tgt_pop, tp_src, tp_tgt, tgt_cells, syn_type) = self.resolve_src_tgt(conn_type) if conn_type == 'ee': w_= self.params['w_max'] w_tgt_in = params['w_tgt_in_per_cell_%s' % conn_type] elif conn_type == 'ei': w_= self.params['w_ie_mean'] w_tgt_in = params['w_tgt_in_per_cell_%s' % conn_type] elif conn_type == 'ie': w_= self.params['w_ie_mean'] w_tgt_in = params['w_tgt_in_per_cell_%s' % conn_type] elif conn_type == 'ii': w_= self.params['w_ii_mean'] w_tgt_in = params['w_tgt_in_per_cell_%s' % conn_type] if self.debug_connectivity: conn_list_fn = self.params['conn_list_%s_fn_base' % conn_type] + '%d.dat' % (self.pc_id) conn_file = open(conn_list_fn, 'w') output = '' p_max = utils.get_pmax(self.params['p_%s' % conn_type]) for tgt in tgt_cells: w = np.zeros(n_src, dtype='float32') delays = np.zeros(n_src, dtype='float32') for src in xrange(n_src): if (src != tgt): # d_ij = np.sqrt((tp_src[src, 0] - tp_tgt[tgt, 0])**2 + (tp_src[src, 1] - tp_tgt[tgt, 1])**2) d_ij = utils.torus_distance2D(tp_src[src, 0], tp_tgt[tgt, 0], tp_src[src, 1], tp_tgt[tgt, 1]) p_ij = p_max * np.exp(-d_ij / (2 * params['w_sigma_x']**2)) if np.random.rand() <= p_ij: w[src] = w_ delays[src] = d_ij * self.params['delay_scale'] w *= w_tgt_in / w.sum() srcs = w.nonzero()[0] for src in srcs: if w[src] > self.params['w_thresh_connection']: delay = min(max(delays[src], self.params['delay_range'][0]), self.params['delay_range'][1]) # map the delay into the valid range connect(src_pop[int(src)], tgt_pop[int(tgt)], w[src], delay=delay, synapse_type=syn_type) output += '%d\t%d\t%.2e\t%.2e\n' % (src, tgt, w[src], delay) # connect(src_pop[int(src)], tgt_pop[int(tgt)], w[src], delay=params['standard_delay'], synapse_type=syn_type) # output += '%d\t%d\t%.2e\t%.2e\n' % (src, tgt, w[src], params['standard_delay']) if self.debug_connectivity: if self.pc_id == 0: print 'DEBUG writing to file:', conn_list_fn conn_file.write(output) conn_file.close()