コード例 #1
0
for x in start_idc:
    curr_idc = np.concatenate((BC_indices[x:24], BC_indices[0:x]))
    PP_to_BCs.append(
        np.random.choice(curr_idc, size=1, replace=False, p=pdf_bc))

PP_to_BCs = np.array(PP_to_BCs)

# Generate temporal patterns for the 100 PP inputs
np.random.seed(seed)
temporal_patterns = inhom_poiss(rate=args.poiss_rate)

# Start the runs of the model
for run in runs:
    nw = net_tunedrev.TunedNetwork(seed,
                                   temporal_patterns[0 + run:24 + run],
                                   PP_to_GCs[0 + run:24 + run],
                                   PP_to_BCs[0 + run:24 + run],
                                   pp_weight=args.pp_weight)

    # Attach voltage recordings to all cells
    nw.populations[0].voltage_recording(range(2000))
    nw.populations[1].voltage_recording(range(60))
    nw.populations[2].voltage_recording(range(24))
    nw.populations[3].voltage_recording(range(24))
    # Run the model
    """Initialization for -2000 to -100"""
    h.cvode.active(0)
    dt = 0.1
    h.steps_per_ms = 1.0 / dt
    h.finitialize(-60)
    h.t = -2000
コード例 #2
0
PP_to_BCs = []
for x in start_idc:
    curr_idc = np.concatenate((BC_indices[x:24], BC_indices[0:x]))
    PP_to_BCs.append(
        np.random.choice(curr_idc, size=1, replace=False, p=pdf_bc))

PP_to_BCs = np.array(PP_to_BCs)

# Generate temporal patterns for the 100 PP inputs
np.random.seed(seed)
temporal_patterns = inhom_poiss(rate=30)

# Start the runs of the model
for run in runs:
    nw = net_tunedrev.TunedNetwork(seed, temporal_patterns[0 + run:24 + run],
                                   PP_to_GCs[0 + run:24 + run],
                                   PP_to_BCs[0 + run:24 + run])

    # Attach voltage recordings to all cells
    nw.populations[0].voltage_recording(range(2000))
    nw.populations[1].voltage_recording(range(60))
    nw.populations[2].voltage_recording(range(24))
    nw.populations[3].voltage_recording(range(24))
    # Run the model
    """Initialization for -2000 to -100"""
    h.cvode.active(0)
    dt = 0.1
    h.steps_per_ms = 1.0 / dt
    h.finitialize(-60)
    h.t = -2000
    h.secondorder = 0
コード例 #3
0
PP_to_BCs = np.array(PP_to_BCs)


# generate temporal patterns out of grid cell act profiles as an input for pyDentate
input_grid_out = inhom_poiss(par_traj, n_traj, dt_s=0.0001, seed=seed_2)

np.random.seed(seed_3) #seed_3 again for network generation & simulation

granule_output = np.empty((n_granule, n_traj), dtype = np.ndarray)
mossy_output = np.empty((n_mossy, n_traj), dtype = np.ndarray)
basket_output = np.empty((n_basket, n_traj), dtype = np.ndarray)
hipp_output = np.empty((n_hipp, n_traj), dtype = np.ndarray)

for trj in range(n_traj):
    nw = net_tunedrev.TunedNetwork(seed_3, input_grid_out[:,trj], PP_to_GCs, PP_to_BCs)
    # Attach voltage recordings to all cells
    nw.populations[0].voltage_recording(range(n_granule))
    nw.populations[1].voltage_recording(range(n_mossy))
    nw.populations[2].voltage_recording(range(n_basket))
    nw.populations[3].voltage_recording(range(n_hipp))
    # Run the model
    
    """Initialization for -2000 to -100"""
    h.cvode.active(0)
    dt = 0.1
    h.steps_per_ms = 1.0/dt
    h.finitialize(-60)
    h.t = -2000
    h.secondorder = 0
    h.dt = 10
コード例 #4
0
for x in dll_files:
    if os.path.isfile(x):
        dll_dir = x
print("DLL loaded from: " + str(dll_dir))
h.nrn_load_dll(dll_dir)

# Setup specs for stimulation
stim_pool = 500  # Size of the pool from which stimulated cells are chosen
stim_loc = int(2000 / 2.0 - stim_pool / 2.0)
stim_amp = 1.5
stim_dur = 10
stim_delay = 50

for run in runs:
    # Create a standard networks and add the stimulation
    nw = net_tunedrev.TunedNetwork(seed=10000 + run)
    np.random.seed(10000 + run)

    # Make sure we are not stimulating a cell we measure
    stim_cells = np.random.choice(range(stim_loc, stim_loc + stim_pool),
                                  n_cells,
                                  replace=False)
    while np.intersect1d(stim_cells, cells_to_measure).any():
        stim_cells = np.random.choice(range(stim_loc, stim_loc + stim_pool),
                                      n_cells,
                                      replace=False)
    print("Done intersecting")

    nw.populations[0].current_clamp_range(stim_cells,
                                          amp=stim_amp,
                                          dur=stim_dur,
コード例 #5
0
def pyDentate(input_grid_out, seed_2, n_traj, dur_ms):
    savedir = os.getcwd()
    input_scale = 1000
    seed_3 = seed_2 + 150  #seed_3 for network generation & simulation
    # Where to search for nrnmech.dll file. Must be adjusted for your machine.
    # dll_files = [("C:\\Users\\DanielM\\Repos\\models_dentate\\"
    #               "dentate_gyrus_Santhakumar2005_and_Yim_patterns\\"
    #               "dentategyrusnet2005\\nrnmech.dll"),
    #              "C:\\Users\\daniel\\Repos\\nrnmech.dll",
    #              ("C:\\Users\\Holger\\danielm\\models_dentate\\"
    #               "dentate_gyrus_Santhakumar2005_and_Yim_patterns\\"
    #               "dentategyrusnet2005\\nrnmech.dll"),
    #              ("C:\\Users\\Daniel\\repos\\"
    #               "dentate_gyrus_Santhakumar2005_and_Yim_patterns\\"
    #               "dentategyrusnet2005\\nrnmech.dll"),
    #               ("/home/baris/Python/mechs_7-6_linux/"
    #                "x86_64/.libs/libnrnmech.so")]

    # for x in dll_files:
    #     if os.path.isfile(x):
    #         dll_dir = x
    # print("DLL loaded from: " + dll_dir)
    # h.nrn_load_dll(dll_dir)

    #number of cells
    n_grid = 200
    n_granule = 2000
    n_mossy = 60
    n_basket = 24
    n_hipp = 24

    np.random.seed(seed_3)  # seed_3 for connections in the network

    # Randomly choose target cells for the GridCell lines
    gauss_gc = stats.norm(loc=1000, scale=input_scale)
    gauss_bc = stats.norm(loc=12,
                          scale=(input_scale / float(n_granule)) * n_basket)
    pdf_gc = gauss_gc.pdf(np.arange(n_granule))
    pdf_gc = pdf_gc / pdf_gc.sum()
    pdf_bc = gauss_bc.pdf(np.arange(n_basket))
    pdf_bc = pdf_bc / pdf_bc.sum()
    GC_indices = np.arange(n_granule)
    start_idc = np.random.randint(0, n_granule - 1, size=n_grid)

    PP_to_GCs = []
    for x in start_idc:
        curr_idc = np.concatenate((GC_indices[x:n_granule], GC_indices[0:x]))
        PP_to_GCs.append(
            np.random.choice(curr_idc, size=100, replace=False, p=pdf_gc))

    PP_to_GCs = np.array(PP_to_GCs)

    BC_indices = np.arange(n_basket)
    start_idc = np.array(((start_idc / float(n_granule)) * 24), dtype=int)

    PP_to_BCs = []
    for x in start_idc:
        curr_idc = np.concatenate((BC_indices[x:24], BC_indices[0:x]))
        PP_to_BCs.append(
            np.random.choice(curr_idc, size=1, replace=False, p=pdf_bc))
    PP_to_BCs = np.array(PP_to_BCs)

    # generate temporal patterns out of grid cell act profiles as an input for pyDentate
    # input_grid_out = inhom_poiss(par_traj, n_traj, dt_s=0.0001, seed=seed_2)

    np.random.seed(seed_3)  #seed_3 again for network generation & simulation

    granule_output = np.empty((n_granule, n_traj), dtype=np.ndarray)
    mossy_output = np.empty((n_mossy, n_traj), dtype=np.ndarray)
    basket_output = np.empty((n_basket, n_traj), dtype=np.ndarray)
    hipp_output = np.empty((n_hipp, n_traj), dtype=np.ndarray)

    for trj in range(n_traj):
        nw = net_tunedrev.TunedNetwork(seed_3, input_grid_out[:, trj],
                                       PP_to_GCs, PP_to_BCs)
        # Attach voltage recordings to all cells
        nw.populations[0].voltage_recording(range(n_granule))
        nw.populations[1].voltage_recording(range(n_mossy))
        nw.populations[2].voltage_recording(range(n_basket))
        nw.populations[3].voltage_recording(range(n_hipp))
        # Run the model
        """Initialization for -2000 to -100"""
        h.cvode.active(0)
        dt = 0.1
        h.steps_per_ms = 1.0 / dt
        h.finitialize(-60)
        h.t = -2000
        h.secondorder = 0
        h.dt = 10
        while h.t < -100:
            h.fadvance()

        h.secondorder = 2
        h.t = 0
        h.dt = 0.1
        """Setup run control for -100 to 1500"""
        h.frecord_init()  # Necessary after changing t to restart the vectors
        while h.t < dur_ms:
            h.fadvance()
        print("Done Running")

        granule_output[:, trj] = np.array(
            [cell[0].as_numpy() for cell in nw.populations[0].ap_counters])
        # mossy_output[:,trj] =  np.array([cell[0].as_numpy() for cell in nw.populations[1].ap_counters])
        # basket_output[:,trj] =  np.array([cell[0].as_numpy() for cell in nw.populations[2].ap_counters])
        # hipp_output[:,trj] =  np.array([cell[0].as_numpy() for cell in nw.populations[3].ap_counters])

    return granule_output, mossy_output, basket_output, hipp_output
    BC_indices = np.arange(24)
    start_idc = np.array(((start_idc / 2000.0) * 24), dtype=int)

    PP_to_BCs = []
    for x in start_idc:
        curr_idc = np.concatenate((BC_indices[x:24], BC_indices[0:x]))
        PP_to_BCs.append(
            np.random.choice(curr_idc, size=1, replace=False, p=pdf_bc))

    PP_to_BCs = np.array(PP_to_BCs)
    PP_to_BCs = PP_to_BCs[0:24]

    # Generate temporal patterns for the 100 PP inputs
    temporal_patterns = inhom_poiss(rate=input_frequency)
    temporal_patterns[0:24]
    nw = net_tunedrev.TunedNetwork(nw_seed[0], temporal_patterns, PP_to_GCs,
                                   PP_to_BCs)

    # Attach voltage recordings to all cells
    nw.populations[0].voltage_recording(range(2000))
    nw.populations[1].voltage_recording(range(60))
    nw.populations[2].voltage_recording(range(24))
    nw.populations[3].voltage_recording(range(24))
    # Run the model
    """Initialization for -2000 to -100"""
    h.cvode.active(0)
    dt = 0.1
    h.steps_per_ms = 1.0 / dt
    h.finitialize(-60)
    h.t = -2000
    h.secondorder = 0
    h.dt = 10