def run(config_file): conf = config.from_json(config_file) io.setup_output_dir(conf) nrn.load_neuron_modules(conf) graph = BioGraph.from_config(conf, property_schema=AIPropertySchema) net = BioNetwork.from_config(conf, graph) sim = Simulation.from_config(conf, network=net) sim.run() nrn.quit_execution()
def run(config_file): conf = config.from_json(config_file) # build configuration io.setup_output_dir(conf) # set up output directories nrn.load_neuron_modules(conf) # load NEURON modules and mechanisms graph = BioGraph.from_config(conf, network_format=TabularNetwork_AI, property_schema=AIPropertySchema) net = BioNetwork.from_config(conf, graph) # create network of in NEURON sim = Simulation(conf, network=net) # initialize a simulation sim.attach_current_clamp() sim.set_recordings( ) # set recordings of relevant variables to be saved as an ouput sim.run() # run simulation nrn.quit_execution() # exit
def run(config_file): conf = config.from_json(config_file) # build configuration io.setup_output_dir(conf) # set up output directories nrn.load_neuron_modules(conf) # load NEURON modules and mechanisms nrn.load_py_modules( cell_models=set_cell_params, # load custom Python modules syn_models=set_syn_params, syn_weights=set_weights) graph = BioGraph.from_config( conf, # create network graph containing parameters of the model network_format=TabularNetwork_AI, property_schema=AIPropertySchema) net = BioNetwork.from_config( conf, graph ) # create netwosim = Simulation.from_config(conf, network=net) rk of in NEURON sim = Simulation.from_config(conf, network=net) # initialize a simulation sim.run() # run simulation if MPI_RANK == 0: try: # Check spikes print2log0('Checking spike times') assert (os.path.exists(conf['output']['spikes_ascii_file'])) assert (spike_files_equal(conf['output']['spikes_ascii_file'], 'expected/spikes.txt')) print2log0('Spikes passed!') # Check extracellular recordings print2log0('Checking ECP output') check_ecp() print2log0('ECP passed!') # Check saved variables print2log0('Checking NEURON saved variables') for saved_gids in conf['node_id_selections']['save_cell_vars']: check_cellvars(saved_gids, conf) print2log0('variables passed!') except AssertionError: _, _, tb = sys.exc_info() traceback.print_tb(tb) pc.barrier() nrn.quit_execution() # exit
def run(config_file): conf = config.from_json(config_file) # build configuration io.setup_output_dir(conf) # set up output directories nrn.load_neuron_modules(conf) # load NEURON modules and mechanisms nrn.load_py_modules( cell_models=set_cell_params, # load custom Python modules syn_models=set_syn_params, syn_weights=set_weights) graph = BioGraph.from_config( conf) # create network graph containing parameters of the model net = BioNetwork.from_config(conf, graph) # create network of in NEURON sim = Simulation.from_config(conf, net) # initialize a simulation # sim.set_recordings() # set recordings of relevant variables to be saved as an ouput sim.run() # run simulation assert (os.path.exists(conf['output']['spikes_ascii_file'])) assert (spike_files_equal(conf['output']['spikes_ascii_file'], 'expected/spikes.txt')) nrn.quit_execution() # exit
def run(config_file): conf = config.from_json(config_file) # build configuration io.setup_output_dir(conf) # set up output directories nrn.load_neuron_modules(conf) # load NEURON modules and mechanisms nrn.load_py_modules( cell_models=set_cell_params, # load custom Python modules syn_models=set_syn_params, syn_weights=set_weights) graph = BioGraph.from_config( conf, # create network graph containing parameters of the model network_format=TabularNetwork_AI, property_schema=AIPropertySchema) net = BioNetwork.from_config( conf, graph ) # create netwosim = Simulation.from_config(conf, network=net) rk of in NEURON sim = Simulation.from_config(conf, network=net) # initialize a simulation # sim.set_recordings() # set recordings of relevant variables to be saved as an ouput sim.run() # run simulation assert (os.path.exists(conf['output']['spikes_ascii_file'])) assert (spike_files_equal(conf['output']['spikes_ascii_file'], 'expected/spikes.txt')) # Test the results of the ecp SAMPLE_SIZE = 100 expected_h5 = h5py.File('expected/ecp.h5', 'r') nrows, ncols = expected_h5['ecp'].shape expected_mat = np.matrix(expected_h5['ecp']) results_h5 = h5py.File('output/ecp.h5', 'r') assert ('ecp' in results_h5.keys()) results_mat = np.matrix(results_h5['ecp'][:]) assert (results_h5['ecp'].shape == (nrows, ncols)) for i, j in zip(randint(0, nrows, size=SAMPLE_SIZE), randint(0, ncols, size=SAMPLE_SIZE)): assert (results_mat[i, j] == expected_mat[i, j]) nrn.quit_execution() # exit
def run(config_file): conf = config.from_json(config_file) # build configuration io.setup_output_dir(conf) # set up output directories nrn.load_neuron_modules(conf) # load NEURON modules and mechanisms nrn.load_py_modules( cell_models=set_cell_params, # load custom Python modules syn_models=set_syn_params, syn_weights=set_weights) graph = BioGraph.from_config( conf, # create network graph containing parameters of the model network_format=TabularNetwork_AI, property_schema=AIPropertySchema) net = BioNetwork.from_config(conf, graph) sim = Simulation.from_config(conf, network=net) sim.run() assert (os.path.exists(conf['output']['spikes_ascii_file'])) assert (spike_files_equal(conf['output']['spikes_ascii_file'], 'expected/spikes.txt')) nrn.quit_execution() # exit
def run(config_file): conf = config.from_json(config_file) # build configuration io.setup_output_dir(conf) # set up output directories nrn.load_neuron_modules(conf) # load NEURON modules and mechanisms nrn.load_py_modules( cell_models=set_cell_params, # load custom Python modules syn_models=set_syn_params, syn_weights=set_weights) graph = BioGraph.from_config( conf, # create network graph containing parameters of the model #network_format=TabularNetwork_AI, property_schema=AIPropertySchema) ''' graph = BioGraph.from_config(conf) ''' net = BioNetwork.from_config(conf, graph) # create network of in NEURON sim = Simulation(conf, network=net) # initialize a simulation sim.set_recordings( ) # set recordings of relevant variables to be saved as an ouput sim.run() # run simulation nrn.quit_execution() # exit
def test_add_nodes(): nodes = bvf.NodesFile(N=100) net = BioGraph() net.add_component('morphologies_dir', '.') net.add_component('biophysical_neuron_models_dir', '.') net.add_component('point_neuron_models_dir', '.') net.add_nodes(nodes) assert (net.networks == [nodes.name]) assert (net.get_internal_nodes() == net.get_nodes(nodes.name)) for bionode in net.get_internal_nodes(): node_id = bionode.node_id orig_node = nodes[node_id] assert (node_id == orig_node.gid) assert (len(bionode.positions) == 3) assert (bionode['ei'] == orig_node['ei']) assert (bionode['model_type'] == orig_node['model_type']) assert (bionode['rotation'] == orig_node['rotation']) assert (os.path.basename( bionode.model_params) == orig_node['dynamics_params'])
def test_add_edges(): nodes = bvf.NodesFile(N=100) edges = bvf.EdgesFile(nodes, nodes) net = BioGraph() net.add_component('morphologies_dir', '.') net.add_component('biophysical_neuron_models_dir', '.') net.add_component('point_neuron_models_dir', '.') net.add_component('synaptic_models_dir', '.') with open('biophys_exc.json', 'w') as fp: json.dump({}, fp) with open('biophys_inh.json', 'w') as fp: json.dump({}, fp) with open('point_exc.json', 'w') as fp: json.dump({}, fp) with open('point_inh.json', 'w') as fp: json.dump({}, fp) net.add_nodes(nodes) net.add_edges(edges) count = 0 for trg_node in net.get_internal_nodes(): #print bionode.node_id for e in net.edges_iterator(trg_node.node_id, nodes.name): _, src_node, edge = e assert (edge['syn_weight'] == trg_node['weight']) count += 1 assert (count == 10000)