output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir,
                                                   o.fileNamePrefix, o.job_num)
d = DataStorage.open(output_fname, 'w')
seed_gen = TrialSeedGenerator(int(o.master_seed))

out = []
overalT = 0.
################################################################################
for trial_idx in range(o.ntrials):
    print("\n\t\tStarting trial no. {0}\n".format(trial_idx))
    seed_gen.set_generators(trial_idx)
    d['master_seed'] = int(o.master_seed)
    d['invalidated'] = 1

    ei_net = BasicGridCellNetwork(o, simulationOpts=None)

    ei_net.endConstruction()
    ei_net.beginSimulation()

    data = ei_net.getNetParams()
    # E --> I neurons
    data['g_IE'] = ei_net.getConnMatrix("E")
    # I --> E neurons
    data['g_EI'] = ei_net.getConnMatrix("I")

    ei_net.endSimulation()

    out.append(data)
    constrT, simT, totalT = ei_net.printTimes()
    overalT += totalT
Esempio n. 2
0
    try:
        seed_gen.check_master_seed(d['master_seed'], int(o.master_seed))
    except ValueError as e:
        d.close()
        raise e

overalT = 0.
stop = False
###############################################################################
for trial_idx in range(len(d['trials']), o.ntrials):
    print("\n\t\tStarting trial no. {0}\n".format(trial_idx))
    seed_gen.set_generators(trial_idx)
    d['invalidated'] = 1
    ei_net = BasicGridCellNetwork(
        o,
        simulationOpts=None,
        nrec_spikes=(nrec_spikes_e, nrec_spikes_i),
        stateRecParams=(stateMonParams, stateMonParams),
        rec_spikes_probabilistic=o.rec_spikes_probabilistic)

    if o.velON and not o.constantPosition:
        ei_net.setVelocityCurrentInput_e()
    if o.pcON:
        # This also sets the start PCs
        posIn = ConstPosInputs(0, 0) if o.constantPosition else None
        ei_net.setPlaceCells(posIn=posIn)
    else:
        # Here the start PCs must be set explicitly
        ei_net.setStartPlaceCells(ConstPosInputs(0, 0))
    if o.ipc_ON:
        if o.constantPosition:
            raise RuntimeError("Place cells connected to I cells cannot be "
d = DataStorage.open(output_fname, 'a')
if "trials" not in d.keys():
    d['trials'] = []

seed_gen = TrialSeedGenerator(int(options.master_seed))

overalT = 0.

###############################################################################
for trial_idx in range(len(d['trials']), options.ntrials):
    print("\n\t\tStarting trial no. {0}\n".format(trial_idx))
    seed_gen.set_generators(trial_idx)
    d['master_seed'] = int(options.master_seed)
    d['invalidated'] = 1
    try:
        ei_net = BasicGridCellNetwork(options, simulationOpts=None)

        const_v = [0.0, 0.0]
        ei_net.setConstantVelocityCurrent_e(const_v)

        stateRecF_e = choice(ei_net.E_pop, options.gammaNSample, replace=False)
        stateRecF_i = choice(ei_net.I_pop, options.gammaNSample, replace=False)

        stateMonF_e_params = {
            'withtime': False,
            'interval': options.sim_dt * 10,
            'record_from': ['I_clamp_GABA_A']
        }

        stateMonF_e = ei_net.getGenericStateMonitor(stateRecF_e,
                                                    stateMonF_e_params,
d['trials'] = []

x_off = [0, 15, -15, 15]
y_off = [0, 15, -15, -15]

overalT = 0.
stop = False
###############################################################################
seed_gen = TrialSeedGenerator(int(o.master_seed))
for trial_idx in range(o.ntrials):
    seed_gen.set_generators(trial_idx)  # Each trial is reproducible
    d['master_seed'] = int(o.master_seed)
    d['invalidated'] = 1

    #const_v = [0.0, -o.Ivel]
    ei_net = BasicGridCellNetwork(o, simulationOpts=None)
    d['net_params'] = ei_net.getNetParams()  # Common settings will stay

    # turn velocity inputs on
    if o.velON:
        ei_net.setVelocityCurrentInput_e()

    # animal position inputs (constant)
    pos = ConstPosInputs(0 + x_off[trial_idx], 0 + y_off[trial_idx])

    # place cells
    if o.pcON:
        # activate place cells (including start place cells))
        ei_net.setPlaceCells()
    # start place cells
    if o.spcON:
Esempio n. 5
0
def run_network(options):
    '''Run network with given `options` and return the dictionary that would be
    saved to an output file.
    '''
    o = options

    seed_gen = TrialSeedGenerator(o.master_seed)

    stateMonParams = {
            'start' : o.time - o.stateMonDur
    }
    nrec_spikes_e = None # all neurons
    nrec_spikes_i = 10

    d = {}
    if "trials" not in d.keys():
        d['trials'] = []

    overalT = 0.
    ################################################################################
    for trial_idx in range(len(d['trials']), o.ntrials):
        print("\n\t\tStarting trial no. {0}\n".format(trial_idx))
        seed_gen.set_generators(trial_idx)
        d['invalidated'] = 1
        ei_net = BasicGridCellNetwork(o, simulationOpts=None,
                nrec_spikes=(nrec_spikes_e, nrec_spikes_i),
                stateRecParams=(stateMonParams, stateMonParams))
        if o.velON and not o.constantPosition:
            ei_net.setVelocityCurrentInput_e()
        posIn = ConstPosInputs(0, 0) if o.constantPosition else None
        ei_net.setPlaceCells(posIn=posIn)

        try:
            ei_net.simulate(o.time, printTime=o.printTime)
        except NESTError as e:
            print("Simulation interrupted. Message: {0}".format(str(e)))
            print("Trying to save the simulated data if possible...")
        ei_net.endSimulation()
        d['trials'].append(ei_net.getAllData())
        constrT, simT, totalT = ei_net.printTimes()
        overalT += totalT

    print("Script total run time: {0} s".format(overalT))
    ################################################################################
    return d
endPos_y = [90.0, -90.0, -90.0, 90.0]
borders = zip(zip(startPos_x, startPos_y), zip(endPos_x, endPos_y))
border_dim = max(startPos_x) - min(startPos_x), max(startPos_y) - min(
    startPos_y)

overalT = 0.
stop = False
###############################################################################
seed_gen = TrialSeedGenerator(int(o.master_seed))
for trial_idx in range(o.ntrials):
    seed_gen.set_generators(trial_idx)  # Each trial is reproducible
    d['master_seed'] = int(o.master_seed)
    d['invalidated'] = 1

    #const_v = [0.0, -o.Ivel]
    ei_net = BasicGridCellNetwork(o, simulationOpts=None)
    d['net_params'] = ei_net.getNetParams()  # Common settings will stay

    # turn velocity inputs on
    if o.velON:
        ei_net.setVelocityCurrentInput_e()

    # place cells
    if o.pcON:
        # activate place cells (including start place cells))
        ei_net.setPlaceCells(distribution='box_outline', boxSize=border_dim)
    elif o.spcON:
        # activate start place cells only
        ei_net.setStartPlaceCells(ConstPosInputs(0, 0))
    else:
        pass
output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir,
                                                   o.fileNamePrefix, o.job_num)
d = DataStorage.open(output_fname, 'w')
seed_gen = TrialSeedGenerator(o.master_seed)

out = []
overalT = 0.
################################################################################
for trial_idx in range(o.ntrials):
    print("\n\t\tStarting trial no. {0}\n".format(trial_idx))
    seed_gen.set_generators(trial_idx)
    d['master_seed'] = o.master_seed
    d['invalidated'] = 1

    ei_net = BasicGridCellNetwork(o, simulationOpts=None)

    ei_net.endConstruction()
    ei_net.beginSimulation()

    data = ei_net.getNetParams()
    # E --> I neurons
    data['g_IE'] = ei_net.getConnMatrix("E")
    # I --> E neurons
    data['g_EI'] = ei_net.getConnMatrix("I")

    ei_net.endSimulation()

    out.append(data)
    constrT, simT, totalT = ei_net.printTimes()
    overalT += totalT
    try:
        seed_gen.check_master_seed(d['master_seed'], int(o.master_seed))
    except ValueError as e:
        d.close()
        raise e

overalT = 0.
stop = False
###############################################################################
for trial_idx in range(len(d['trials']), o.ntrials):
    print("\n\t\tStarting trial no. {0}\n".format(trial_idx))
    seed_gen.set_generators(trial_idx)
    d['invalidated'] = 1
    ei_net = BasicGridCellNetwork(o, simulationOpts=None,
                                  nrec_spikes=(nrec_spikes_e, nrec_spikes_i),
                                  stateRecParams=(stateMonParams,
                                                  stateMonParams),
                                  rec_spikes_probabilistic=o.rec_spikes_probabilistic)

    if o.velON and not o.constantPosition:
        ei_net.setVelocityCurrentInput_e()
    if o.pcON:
        # This also sets the start PCs
        posIn = ConstPosInputs(0, 0) if o.constantPosition else None
        ei_net.setPlaceCells(posIn=posIn)
    else:
        # Here the start PCs must be set explicitly
        ei_net.setStartPlaceCells(ConstPosInputs(0, 0))
    if o.ipc_ON:
        if o.constantPosition:
            raise RuntimeError("Place cells connected to I cells cannot be "
Esempio n. 9
0
def run_network(options):
    '''Run network with given `options` and return the dictionary that would be
    saved to an output file.
    '''
    o = options

    seed_gen = TrialSeedGenerator(o.master_seed)

    stateMonParams = {'start': o.time - o.stateMonDur}
    nrec_spikes_e = None  # all neurons
    nrec_spikes_i = 10

    d = {}
    if "trials" not in d.keys():
        d['trials'] = []

    overalT = 0.
    ################################################################################
    for trial_idx in range(len(d['trials']), o.ntrials):
        print("\n\t\tStarting trial no. {0}\n".format(trial_idx))
        seed_gen.set_generators(trial_idx)
        d['invalidated'] = 1
        ei_net = BasicGridCellNetwork(o,
                                      simulationOpts=None,
                                      nrec_spikes=(nrec_spikes_e,
                                                   nrec_spikes_i),
                                      stateRecParams=(stateMonParams,
                                                      stateMonParams))
        if o.velON and not o.constantPosition:
            ei_net.setVelocityCurrentInput_e()
        posIn = ConstPosInputs(0, 0) if o.constantPosition else None
        ei_net.setPlaceCells(posIn=posIn)

        try:
            ei_net.simulate(o.time, printTime=o.printTime)
        except NESTError as e:
            print("Simulation interrupted. Message: {0}".format(str(e)))
            print("Trying to save the simulated data if possible...")
        ei_net.endSimulation()
        d['trials'].append(ei_net.getAllData())
        constrT, simT, totalT = ei_net.printTimes()
        overalT += totalT

    print("Script total run time: {0} s".format(overalT))
    ################################################################################
    return d
Esempio n. 10
0
output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir,
                                                   o.fileNamePrefix, o.job_num)
d = DataStorage.open(output_fname, 'w')
d['trials'] = []

overalT = 0.
stop = False
###############################################################################
seed_gen = TrialSeedGenerator(int(o.master_seed))
for trial_idx in range(o.ntrials):
    seed_gen.set_generators(trial_idx)  # Each trial is reproducible
    d['master_seed'] = int(o.master_seed)
    d['invalidated'] = 1

    #const_v = [0.0, -o.Ivel]
    ei_net = BasicGridCellNetwork(o, simulationOpts=None)
    d['net_params'] = ei_net.getNetParams()  # Common settings will stay

    # turn velocity inputs on
    ei_net.setVelocityCurrentInput_e()

    # activate place cells (including start place cells))
    ei_net.setPlaceCells()

    try:
        ei_net.simulate(o.time, printTime=o.printTime)
    except NESTError as e:
        print("Simulation interrupted. Message: {0}".format(str(e)))
        print("Not saving the data. Trying to clean up if possible...")
        stop = True
    ei_net.endSimulation()