Exemplo n.º 1
0
def distance_connection_handler(source, target, d_weight_min, d_weight_max,
                                d_max, nsyn_min, nsyn_max, center):

    # Avoid self-connections.
    if (source['id'] == target['id']):
        return None

    # first create weights by euclidean distance between cells
    # DO NOT use PERIODIC boundary conditions in x and y!
    dw = nutil.distance_weight(
        np.array(source['position'][:2]) - np.array(target['position'][:2]),
        d_weight_min, d_weight_max, d_max)

    # drop the connection if the weight is too low
    if dw <= 0:
        return None

    # filter out nodes by treating the weight as a probability of connection
    if random.random() > dw:
        return None

    # Add the number of synapses for every connection.

    tmp_nsyn = random.randint(nsyn_min, nsyn_max)
    return {'nsyn': tmp_nsyn}
Exemplo n.º 2
0
def distance_tuning_connection_handler(source, target, d_weight_min,
                                       d_weight_max, d_max, t_weight_min,
                                       t_weight_max, nsyn_min, nsyn_max,
                                       center):
    # Avoid self-connections.
    if (source['id'] == target['id']):
        return None

    # first create weights by euclidean distance between cells
    # DO NOT use PERIODIC boundary conditions in x and y!
    dw = nutil.distance_weight(
        np.array(source['position'][:2]) - np.array(target['position'][:2]),
        d_weight_min, d_weight_max, d_max)

    # drop the connection if the weight is too low
    if dw <= 0:
        return None

    # next create weights by orientation tuning [ aligned, misaligned ] --> [ 1, 0 ]
    # Check that the orientation tuning property exists for both cells; otherwise,
    # ignore the orientation tuning.
    if (('orientation_tuning' in source.keys())
            and ('orientation_tuning' in target.keys())):
        tw = dw * nutil.orientation_tuning_weight(source['orientation_tuning'],
                                                  target['orientation_tuning'],
                                                  t_weight_min, t_weight_max)
    else:
        tw = dw

    # drop the connection if the weight is too low
    if tw <= 0:
        return None

    # filter out nodes by treating the weight as a probability of connection
    if random.random() > tw:
        return None

    # Add the number of synapses for every connection.

    tmp_nsyn = random.randint(nsyn_min, nsyn_max)
    return {'nsyn': tmp_nsyn}