Ejemplo n.º 1
0
V = np.sin(D / 8. * 2 * np.pi)
ax.quiver(X, Y, U, V, pivot='middle')
ax_spines.set_default(ax)

ax = axes[1, 2]
ax.text(0.05,
        0.95,
        'Homogeneous',
        verticalalignment='top',
        horizontalalignment='left',
        transform=ax.transAxes,
        fontsize=8,
        bbox={
            'facecolor': 'white',
            'pad': 3
        })
D = cl.homogeneous(size, specs={'phi': 3})
U = np.cos(D / 8. * 2 * np.pi)
V = np.sin(D / 8. * 2 * np.pi)
ax.quiver(X, Y, U, V, pivot='middle')
ax_spines.set_default(ax)

panel_label(axes[0, 0], 'a')
panel_label(axes[1, 0], 'b')

filename = 'sequence_networks_schematics'
fig.savefig(filename + '.png', format='png', dpi=300)
fig.savefig(filename + '.pdf', format='pdf')

pl.show()
Ejemplo n.º 2
0
def create_connectivity_EI_dir(neuron_parameters, connectivity_parameters,
                               save_AM_parameters):
    [
        nrowE, ncolE, nrowI, ncolI, nE, nI, nN, neuron_type, neuron_paramsE,
        neuron_paramsI
    ] = neuron_parameters
    [
        landscape_type, landscape_size, asymmetry, p, std, separation, width,
        alpha, seed
    ] = connectivity_parameters
    [pEE, pEI, pIE, pII] = p
    [stdEE, stdEI, stdIE, stdII] = std
    [AM_address, fname] = save_AM_parameters

    if asymmetry[0] == 'E':
        nrowL = nrowE
    else:
        nrowL = nrowI

    if landscape_type == 'symmetric':
        landscape = None
    elif landscape_type == 'random':
        landscape = cl.random(nrowL, {'seed': 0})
    elif landscape_type == 'homogenous':
        landscape = cl.homogeneous(nrowL, {'phi': 3})
    elif landscape_type == 'perlin':
        landscape = cl.Perlin(nrowL, {'size': int(landscape_size)})
    elif landscape_type == 'perlinuniform':
        landscape = cl.Perlin_uniform(nrowL, {
            'size': int(landscape_size),
            'base': seed
        })

    iso_AM = np.zeros((nN, nN))
    dir_AM = np.zeros((nN, nN))

    [alphaEE, alphaEI, alphaIE, alphaII] = [0, 0, 0, 0]
    if asymmetry == 'EE':
        alphaEE = alpha
    elif asymmetry == 'EI':
        alphaEI = alpha
    elif asymmetry == 'IE':
        alphaIE = alpha
    elif asymmetry == 'II':
        alphaII = alpha

    for idx in range(nE):

        targets, delays = lcrn.lcrn_gauss_targets(
            idx, nrowE, ncolE, nrowE, ncolE, int(pEE * nE * (1 - alphaEE)),
            stdEE)
        targets = targets[targets != idx]
        if asymmetry == 'EE':
            if landscape is not None:
                direction = landscape[idx]
                dir_targets = dirconn.get_directional_targets(
                    idx, nrowE, ncolE, nrowE, ncolE, direction, separation,
                    width, int(pEE * nE * alphaEE))
                dir_targets = dir_targets[dir_targets != idx]
                targets = np.setdiff1d(targets, dir_targets)
                dir_AM[idx, dir_targets] = 1.
        iso_AM[idx, targets] = 1.

        targets, delays = lcrn.lcrn_gauss_targets(
            idx, nrowE, ncolE, nrowI, ncolI, int(pEI * nI * (1 - alphaEI)),
            stdEI)
        if asymmetry == 'EI':
            if landscape is not None:
                direction = landscape[idx]
                dir_targets = dirconn.get_directional_targets(
                    idx, nrowE, ncolE, nrowI, ncolI, direction, separation,
                    width, int(pEI * nI * alphaEI))
                targets = np.setdiff1d(targets, dir_targets)
                dir_AM[idx, dir_targets + nE] = 1.
        iso_AM[idx, targets + nE] = 1.

    for idx in range(nI):

        targets, delays = lcrn.lcrn_gauss_targets(
            idx, nrowI, ncolI, nrowE, ncolE, int(pIE * nE * (1 - alphaIE)),
            stdIE)
        if asymmetry == 'IE':
            if landscape is not None:
                direction = landscape[idx]
                dir_targets = dirconn.get_directional_targets(
                    idx, nrowI, ncolI, nrowE, ncolE, direction, separation,
                    width, int(pIE * nE * alphaIE))
                targets = np.setdiff1d(targets, dir_targets)
                dir_AM[idx + nE, dir_targets] = 1.
        iso_AM[idx + nE, targets] = 1.

        targets, delays = lcrn.lcrn_gauss_targets(
            idx, nrowI, ncolI, nrowI, ncolI, int(pII * nI * (1 - alphaII)),
            stdII)
        targets = targets[targets != idx]
        if asymmetry == 'II':
            if landscape is not None:
                direction = landscape[idx]
                dir_targets = dirconn.get_directional_targets(
                    idx, nrowI, ncolI, nrowI, ncolI, direction, separation,
                    width, int(pII * nI * alphaII))
                dir_targets = dir_targets[dir_targets != idx]
                targets = np.setdiff1d(targets, dir_targets)
                dir_AM[idx + nE, dir_targets + nE] = 1.
        iso_AM[idx + nE, targets + nE] = 1.

    print('Multiple connections')
    print(np.where(iso_AM + dir_AM > 1.))

    sparse.save_npz(AM_address + fname + 'isoAM', sparse.coo_matrix(iso_AM))
    sparse.save_npz(AM_address + fname + 'dirAM', sparse.coo_matrix(dir_AM))
    sparse.save_npz(AM_address + fname + 'landscape',
                    sparse.coo_matrix(landscape))

    return [iso_AM, dir_AM, landscape, nrowL]
Ejemplo n.º 3
0
def create_connectivity_EI_random_dir(neuron_parameters,
                                      connectivity_parameters,
                                      save_AM_parameters):
    [
        nrowE, ncolE, nrowI, ncolI, nE, nI, nN, neuron_type, neuron_paramsE,
        neuron_paramsI
    ] = neuron_parameters
    [landscape_type, landscape_size, asymmetry, p, shift, std, alpha,
     seed] = connectivity_parameters
    [pEE, pEI, pIE, pII] = p
    [stdEE, stdEI, stdIE, stdII] = std
    [AM_address, fname] = save_AM_parameters

    if asymmetry[0] == 'E':
        nrowL = nrowE
    else:
        nrowL = nrowI

    if asymmetry[-1] == 'E':
        nrowM = nrowE
    else:
        nrowM = nrowI
    move = cl.move(nrowM)

    if landscape_type == 'symmetric':
        landscape = None
    elif landscape_type == 'random':
        landscape = cl.random(nrowL, {'seed': 0})
    elif landscape_type == 'homogenous':
        landscape = cl.homogeneous(nrowL, {'phi': 3})
    elif landscape_type == 'perlin':
        landscape = cl.Perlin(nrowL, {'size': int(landscape_size)})
    elif landscape_type == 'perlinuniform':
        landscape = cl.Perlin_uniform(nrowL, {
            'size': int(landscape_size),
            'base': seed
        })

    ran_AM = np.zeros((nN, nN))
    dir_AM = np.zeros((nN, nN))

    [alphaEE, alphaEI, alphaIE, alphaII] = [0, 0, 0, 0]
    if asymmetry == 'EE':
        alphaEE = alpha
    elif asymmetry == 'EI':
        alphaEI = alpha
    elif asymmetry == 'IE':
        alphaIE = alpha
    elif asymmetry == 'II':
        alphaII = alpha

    for idx in range(nE):

        targets = []
        if (asymmetry == 'EE') and (landscape is not None):
            targets, delays = lcrn.lcrn_gauss_targets(idx, nrowE, ncolE, nrowE,
                                                      ncolE,
                                                      int(pEE * nE * alphaEE),
                                                      stdEE)
            targets = (targets + shift * move[landscape[idx] % len(move)]) % nE
            targets = targets[targets != idx].astype(int)
            dir_AM[idx, targets] = 1.
        r_targets = get_random_targets(idx, nrowE, ncolE, nrowE, ncolE,
                                       int(pEE * nE * (1 - alphaEE)))
        r_targets = np.setdiff1d(r_targets, targets)
        ran_AM[idx, r_targets] = 1.

        targets = []
        if (asymmetry == 'EI') and (landscape is not None):
            targets, delays = lcrn.lcrn_gauss_targets(idx, nrowE, ncolE, nrowI,
                                                      ncolI,
                                                      int(pEI * nI * alphaEI),
                                                      stdEI)
            targets = (targets + shift * move[landscape[idx] % len(move)]) % nI
            dir_AM[idx, targets + nE] = 1.
        r_targets = get_random_targets(idx, nrowE, ncolE, nrowI, ncolI,
                                       int(pEI * nI * (1 - alphaEI)))
        r_targets = np.setdiff1d(r_targets, targets)
        ran_AM[idx, r_targets + nE] = 1.

    for idx in range(nI):

        targets = []
        if (asymmetry == 'IE') and (landscape is not None):
            targets, delays = lcrn.lcrn_gauss_targets(idx, nrowI, ncolI, nrowE,
                                                      ncolE,
                                                      int(pIE * nE * alphaIE),
                                                      stdIE)
            targets = (targets + shift * move[landscape[idx] % len(move)]) % nI
            dir_AM[idx + nE, targets] = 1.
        r_targets = get_random_targets(idx, nrowI, ncolI, nrowE, ncolE,
                                       int(pIE * nE * (1 - alphaIE)))
        r_targets = np.setdiff1d(r_targets, targets)
        ran_AM[idx + nE, r_targets] = 1.

        targets = []
        if (asymmetry == 'II') and (landscape is not None):
            targets, delays = lcrn.lcrn_gauss_targets(idx, nrowI, ncolI, nrowI,
                                                      ncolI,
                                                      int(pII * nI * alphaII),
                                                      stdII)
            targets = (targets + shift * move[landscape[idx] % len(move)]) % nI
            targets = targets[targets != idx].astype(int)
            dir_AM[idx + nE, targets + nE] = 1.
        r_targets = get_random_targets(idx, nrowI, ncolI, nrowI, ncolI,
                                       int(pII * nI * (1 - alphaII)))
        r_targets = np.setdiff1d(r_targets, targets)
        ran_AM[idx + nE, r_targets + nE] = 1.

    print('Multiple connections')
    print(np.where(ran_AM + dir_AM > 1.))

    sparse.save_npz(AM_address + fname + 'random_rAM',
                    sparse.coo_matrix(ran_AM))
    sparse.save_npz(AM_address + fname + 'random_dAM',
                    sparse.coo_matrix(dir_AM))
    sparse.save_npz(AM_address + fname + 'landscape',
                    sparse.coo_matrix(landscape))

    return [ran_AM, dir_AM, landscape, nrowL]
Ejemplo n.º 4
0
def create_connectivity_EI(neuron_parameters, connectivity_parameters,
                           save_AM_parameters):
    [
        nrowE, ncolE, nrowI, ncolI, nE, nI, nN, neuron_type, neuron_paramsE,
        neuron_paramsI
    ] = neuron_parameters
    [landscape_type, landscape_size, asymmetry, p, std, shift,
     seed] = connectivity_parameters
    [pEE, pEI, pIE, pII] = p
    [stdEE, stdEI, stdIE, stdII] = std
    [AM_address, fname] = save_AM_parameters

    if asymmetry[0] == 'E':
        nrowL = nrowE
    else:
        nrowL = nrowI

    if asymmetry[-1] == 'E':
        nrowM = nrowE
    else:
        nrowM = nrowI

    move = cl.move(nrowM)

    if landscape_type == 'symmetric':
        landscape = None
    elif landscape_type == 'random':
        landscape = cl.random(nrowL, {'seed': 0})
    elif landscape_type == 'homogenous':
        landscape = cl.homogeneous(nrowL, {'phi': 3})
    elif landscape_type == 'perlin':
        landscape = cl.Perlin(nrowL, {'size': int(landscape_size)})
    elif landscape_type == 'perlinuniform':
        landscape = cl.Perlin_uniform(nrowL, {
            'size': int(landscape_size),
            'base': seed
        })

    AM = np.zeros((nN, nN))

    for idx in range(nE):

        targets, delays = lcrn.lcrn_gauss_targets(idx, nrowE, ncolE, nrowE,
                                                  ncolE, int(pEE * nE), stdEE)
        if asymmetry == 'EE':
            if landscape is not None:
                targets = (targets +
                           shift * move[landscape[idx] % len(move)]) % nE
        targets = targets[targets != idx].astype(int)
        AM[idx, targets] = 1.

        targets, delays = lcrn.lcrn_gauss_targets(idx, nrowE, ncolE, nrowI,
                                                  ncolI, int(pEI * nI), stdEI)
        if asymmetry == 'EI':
            if landscape is not None:
                targets = (
                    (targets + shift * move[landscape[idx] % len(move)]) %
                    nI).astype(int)
        AM[idx, targets + nE] = 1.

    for idx in range(nI):

        targets, delays = lcrn.lcrn_gauss_targets(idx, nrowI, ncolI, nrowE,
                                                  ncolE, int(pIE * nE), stdIE)
        if asymmetry == 'IE':
            if landscape is not None:
                targets = (
                    (targets + shift * move[landscape[idx] % len(move)]) %
                    nE).astype(int)
        AM[idx + nE, targets] = 1.

        targets, delays = lcrn.lcrn_gauss_targets(idx, nrowI, ncolI, nrowI,
                                                  ncolI, int(pII * nI), stdII)
        if asymmetry == 'II':
            if landscape is not None:
                targets = (targets +
                           shift * move[landscape[idx] % len(move)]) % nI
        targets = targets[targets != idx].astype(int)
        AM[idx + nE, targets + nE] = 1.

    sparse.save_npz(AM_address + fname + 'normalAM', sparse.coo_matrix(AM))
    sparse.save_npz(AM_address + fname + 'landscape',
                    sparse.coo_matrix(landscape))

    return [AM, landscape, nrowL]