Пример #1
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
Пример #2
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
'''Main simulation run: Only export E and I connections.'''
from __future__ import absolute_import, print_function, division

from grid_cell_model.models.parameters import getOptParser
from grid_cell_model.models.gc_net_nest import BasicGridCellNetwork
from grid_cell_model.models.seeds import TrialSeedGenerator
from simtools.storage import DataStorage


parser = getOptParser()
(o, args) = parser.parse_args()

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()
parser.add_argument("--bcON",
                    type=int,
                    choices=[0, 1],
                    default=0,
                    help="Border cell input ON?")
(o, args) = parser.parse_args()

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 = [-o.Ivel, 0.0]
    ei_net = ConstantVelocityNetwork(o, simulationOpts=None, vel=const_v)
    d['net_params'] = ei_net.getNetParams()  # Common settings will stay

    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
    data['stateMonF_e'] = [data['stateMonF_e'][0]]

    return data


parser          = getOptParser()
(options, args) = parser.parse_args()

output_fname = "{0}/{1}job{2:05}_output.h5".format(options.output_dir,
                                                   options.fileNamePrefix,
                                                   options.job_num)
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)
Пример #6
0
    logger.info('bumpCurrentSlope is NaN. Not performing the simulation')
    exit(0)
else:
    logger.info("bumpCurrentSlope: {0}".format(o.bumpCurrentSlope))

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

output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir,
                                                   o.fileNamePrefix, o.job_num)
d = DataStorage.open(output_fname, 'a')
if ("trials" not in d.keys()):
    d['trials'] = []

seed_gen = TrialSeedGenerator(int(o.master_seed))
if len(d['trials']) == 0:
    d['master_seed'] = int(o.master_seed)
else:
    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)
from grid_cell_model.models.gc_net_nest import ConstantVelocityNetwork
from grid_cell_model.models.seeds import TrialSeedGenerator
from simtools.storage import DataStorage

parser = getOptParser()
(o, args) = parser.parse_args()

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 = ConstantVelocityNetwork(o, simulationOpts=None, vel=const_v)
    d['net_params'] = ei_net.getNetParams()  # Common settings will stay

    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
                                     len(trial['IvelData']) * o.dIvel, o.dIvel)
        d.flush()


(o, args) = parser.parse_args()
o.master_seed = int(o.master_seed)

output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir,
                                                   o.fileNamePrefix, o.job_num)
d = DataStorage.open(output_fname, 'a')
if ("trials" not in d.keys()):
    d['trials'] = []

# Initialise seeds and check their consistency with previously saved data

seed_gen = TrialSeedGenerator(o.master_seed)

if len(d['trials']) == 0:
    d['master_seed'] = o.master_seed
else:
    try:
        seed_gen.check_master_seed(d['master_seed'], o.master_seed)
    except ValueError as e:
        d.close()
        raise e

overalT = 0.
oldNTrials = len(d['trials'])
################################################################################
for trial_idx in range(o.ntrials):
    print("\n\t\tStarting/appending to trial no. {0}\n".format(trial_idx))
    if 'IvelVec' not in trial.keys() and 'IvelData' in trial.keys():
        logger.info("Data present, but IvelVec is missing. Fixing...")
        trial['IvelVec'] = np.arange(.0, len(trial['IvelData'])*o.dIvel, o.dIvel)
        d.flush()

(o, args) = parser.parse_args()


output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir,
        o.fileNamePrefix, o.job_num)
d = DataStorage.open(output_fname, 'a')
if ("trials" not in d.keys()):
    d['trials'] = []

# Initialise seeds and check their consistency with previously saved data
seed_gen = TrialSeedGenerator(int(o.master_seed))
if len(d['trials']) == 0:
    d['master_seed'] = int(o.master_seed)
else:
    try:
        seed_gen.check_master_seed(d['master_seed'], int(o.master_seed))
    except ValueError as e:
        d.close()
        raise e

overalT = 0.
oldNTrials = len(d['trials'])
################################################################################
for trial_idx in range(o.ntrials):
    print("\n\t\tStarting/appending to trial no. {0}\n".format(trial_idx))
    if trial_idx >= oldNTrials:  # Create new trial
'''Main simulation run: Only export E and I connections.'''
from __future__ import absolute_import, print_function, division

from grid_cell_model.models.parameters import getOptParser
from grid_cell_model.models.gc_net_nest import BasicGridCellNetwork
from grid_cell_model.data_storage import DataStorage
from grid_cell_model.models.seeds import TrialSeedGenerator

parser = getOptParser()
(o, args) = parser.parse_args()

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()
Пример #11
0
    logger.info("bumpCurrentSlope: {0}".format(o.bumpCurrentSlope))


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

output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir,
        o.fileNamePrefix, o.job_num)
d = DataStorage.open(output_fname, 'a')
if ("trials" not in d.keys()):
    d['trials'] = []

seed_gen = TrialSeedGenerator(int(o.master_seed))
if len(d['trials']) == 0:
    d['master_seed'] = int(o.master_seed)
else:
    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)