def plot_potential(cell_vars_h5=None, config_file=None, gids=None, show_plot=True, save=False): if (cell_vars_h5 or config_file) is None: raise Exception( 'Please specify a cell_vars hdf5 file or a simulation config.') if cell_vars_h5 is not None: plot_potential_hdf5(cell_vars_h5, show_plot, save_as='sim_potential.jpg' if save else None) else: # load the json file or object if isinstance(config_file, basestring): config = cfg.from_json(config_file) elif isinstance(config_file, dict): config = config_file else: raise Exception('Could not convert {} (type "{}") to json.'.format( config_file, type(config_file))) gid_list = gids or config['node_id_selections']['save_cell_vars'] for gid in gid_list: save_as = '{}_v.jpg'.format(gid) if save else None title = 'cell gid {}'.format(gid) var_h5 = os.path.join(config['output']['cell_vars_dir'], '{}.h5'.format(gid)) plot_potential_hdf5(var_h5, title, show_plot, save_as)
def test_load_simulator_config(): cfg_full_path = config_path('files/simulator_config.json') config = cfg.from_json(cfg_full_path) manifest = config['manifest'] assert ('run' in config) assert (config['output']['log'] == os.path.join(manifest['$OUTPUT_DIR'], 'log.txt'))
def _get_config(config): if isinstance(config, basestring): return cfg.from_json(config) elif isinstance(config, dict): return config else: raise Exception('Could not convert {} (type "{}") to json.'.format(config, type(config)))
def test_load_parent_config(): """Test a parent config file can pull in children configs""" cfg_full_path = config_path('files/config.json') config = cfg.from_json(cfg_full_path) assert (config['config_path'] == cfg_full_path) assert ('components' in config) assert ('networks' in config) assert ('run' in config)
def main(config_file): configure = config.from_json(config_file) graph = PopGraph.from_config(config_file, network_format=TabularNetwork_AI, property_schema=AIPropertySchema, group_by='ei') net = PopNetwork.from_config(configure, graph) net.run()
def test_load_network_config(): cfg_full_path = config_path('files/circuit_config.json') config = cfg.from_json(cfg_full_path) manifest = config['manifest'] assert (config['config_path'] == cfg_full_path) assert (config['components']['morphologies'] == os.path.join( manifest['$COMPONENT_DIR'], 'morphologies')) assert (config['networks']['node_files'][0]['nodes'] == os.path.join( manifest['$NETWORK_DIR'], 'V1/v1_nodes.h5'))
def from_json(config_file, validate=True): """Converts a config file into a dictionary. Will resolve manifest variables, validate schema and input files, as well as other behind-the-scenes actions required by bionet. :param config_file: json file object or path to json configuration file :param validate: will validate the config file against schemas/config_schema.json (Default True) :return: config json file in dictionary format """ validator = bionet_validator if validate else None return msdk_config.from_json(config_file, validator)
def plot_spikes_config(configure, group_key=None, exclude=[], save_as=None, show_plot=True): if isinstance(configure, basestring): conf = config.from_json(configure) elif isinstance(configure, dict): conf = configure else: raise Exception("configure variable must be either a json dictionary or json file name.") cells_file_name = conf['internal']['nodes'] cell_models_file_name = conf['internal']['node_types'] spikes_file = conf['output']['spikes_ascii'] plot_spikes(cells_file_name, cell_models_file_name, spikes_file, group_key, exclude, save_as, show_plot)
def main(config_file): configure = config.from_json(config_file) graph = PopGraph.from_config(config_file, group_by='node_type_id') #v1_pops = graph.get_populations('V1') # print pop print graph.get_populations('LGN') pop0 = graph.get_population('LGN', 0) #pop0.firing_rate = 12.2 net = PopNetwork.from_config(configure, graph) net.run() assert (firing_rates_equal('expected/spike_rates.txt', configure['output']['rates_file']))
def plot_spikes_config(configure, group_key=None, exclude=[], save_as=None, show_plot=True): warnings.warn('Deprecated: Please use bmtk.analyzer.spike_trains.plot_raster instead.', DeprecationWarning) if isinstance(configure, string_types): conf = config.from_json(configure) elif isinstance(configure, dict): conf = configure else: raise Exception("configure variable must be either a json dictionary or json file name.") cells_file_name = conf['internal']['nodes'] cell_models_file_name = conf['internal']['node_types'] spikes_file = conf['output']['spikes_ascii'] plot_spikes(cells_file_name, cell_models_file_name, spikes_file, group_key, exclude, save_as, show_plot)
def main(config_file): configure = config.from_json(config_file) graph = Graph(configure) graph.add_weight_function(fn.wmax) graph.add_weight_function(fn.gaussianLL) net = nest_construction.Network(configure, graph) net.run(configure['run']['duration']) #assert(spike_files_equal(configure['output']['spikes_ascii'], 'expected/spikes.txt')) #plot_spikes(configure, 'pop_name') # Check all the output was created """
def from_json(config_file, validate=False): return msdk_config.from_json(config_file)
import bmtk.simulator.utils.config as config from bmtk.simulator.pointnet.graph import Graph from bmtk.simulator.pointnet.network import Network import weight_funcs as fn configure = config.from_json('config.json') graph = Graph(configure) graph.add_weight_function(fn.wmax) graph.add_weight_function(fn.gaussianLL) net = Network(configure, graph) net.run(configure['run']['duration'])
def main(config_file): configure = config.from_json(config_file) graph = PopGraph.from_config(config_file, group_by='node_type_id') net = PopNetwork.from_config(configure, graph) net.run()