示例#1
0
def run(config_file):

    synapses.load()
    from bmtk.simulator.bionet.pyfunction_cache import add_weight_function

    def gaussianBL(edge_props, source, target):
        w0 = edge_props["syn_weight"]
        sigma = edge_props["weight_sigma"]
        return np.random.normal(w0, sigma, 1)

    def lognormal(edge_props, source, target):
        m = edge_props["syn_weight"]
        s = edge_props["weight_sigma"]
        mean = np.log(m) - 0.5 * np.log((s / m)**2 + 1)
        std = np.sqrt(np.log((s / m)**2 + 1))
        return np.random.lognormal(mean, std, 1)

    add_weight_function(lognormal)
    add_weight_function(gaussianBL)

    conf = bionet.Config.from_json(config_file, validate=True)
    conf.build_env()

    graph = bionet.BioNetwork.from_config(conf)
    sim = bionet.BioSimulator.from_config(conf, network=graph)
    sim.run()
    bionet.nrn.quit_execution()
示例#2
0
def run(config_file):
    warnings.simplefilter(action='ignore', category=FutureWarning)
    synapses.load()

    conf = bionet.Config.from_json(config_file, validate=True)
    conf.build_env()
    graph = bionet.BioNetwork.from_config(conf)
    sim = bionet.BioSimulator.from_config(conf, network=graph)

    sim.run()
    bionet.nrn.quit_execution()
    def __init__(self, params_file, seed=123):
        """Initializes the simulation builder, 
                setting up attributes but not actually building the BMTK network.

                Parameters
                ----------
                params_file : str
                    path to the JSON file with network parameters
                seed : int
                    base random seed for the simulation
                """
        #Loads the JSON file with information about the network.
        with open(params_file) as f:
            self.params = json.load(f)

        self.seed = seed

        #Loads synapse templates.
        synapses.load()
        self.syn = synapses.syn_params_dicts()

        avg_exc_div = np.mean(list(self.params["divergence"]["exc"].values()))

        self.n_dend_exc = int(
            (self.params["lengths"]["basal_dist"] *
             self.params["syn_density"]["exc"]) / avg_exc_div)

        self.n_apic_exc = int(
            (self.params["lengths"]["apic"] *
             self.params["syn_density"]["exc"]) / avg_exc_div)

        self.n_dend_inh = int((self.params["lengths"]["basal_dist"] *
                               self.params["syn_density"]["inh"]) /
                              self.params["divergence"]["basal_inh"]["m"])
        self.n_apic_inh = int((self.params["lengths"]["apic"] *
                               self.params["syn_density"]["inh"]) /
                              self.params["divergence"]["apic_inh"]["m"])

        self.n_prox_dend_inh = int((self.params["lengths"]["basal_prox"] *
                                    self.params["syn_density"]["inh"]) /
                                   self.params["divergence"]["peri_inh"]["m"])
        self.n_soma_inh = int(self.params["n_soma_syns"] /
                              self.params["divergence"]["peri_inh"]["m"])

        self.clust_per_group = int(
            (self.params["groups"]["cells_per_group"] * avg_exc_div) //
            (self.params["syn_density"]["exc"] * 10))
        if self.params["file_current_clamp"]["input_file"] == "None":
            self.file_current_clamp = None
        else:
            self.file_current_clamp = self.params["file_current_clamp"]
示例#4
0
def run(config_file):

    warnings.simplefilter(action='ignore', category=FutureWarning)
    synapses.load()
    from bmtk.simulator.bionet.pyfunction_cache import add_weight_function

    def gaussianBL(edge_props, source, target):
        w0 = edge_props["syn_weight"]
        sigma = edge_props["weight_sigma"]
        return np.random.normal(w0, sigma, 1)
	
    def lognormal(edge_props, source, target):
        m = edge_props["syn_weight"]
        s = edge_props["weight_sigma"]
        mean = np.log(m) - 0.5 * np.log((s/m)**2+1)
        std = np.sqrt(np.log((s/m)**2 + 1))
        return np.random.lognormal(mean, std, 1)

    add_weight_function(lognormal)
    add_weight_function(gaussianBL)


    conf = bionet.Config.from_json(config_file, validate=True)
    conf.build_env()

    graph = bionet.BioNetwork.from_config(conf)

    # This fixes the morphology error in LFP calculation
    pop = graph._node_populations['SPWR_biophysical']
    for node in pop.get_nodes():
        node._node._node_type_props['morphology'] = node.model_template[1]

    sim = bionet.BioSimulator.from_config(conf, network=graph)
    
    # This calls insert_mechs() on each cell to use its gid as a seed
    # to the random number generator, so that each cell gets a different
    # random seed for the point-conductance noise
    #cells = graph.get_local_cells()
    #for cell in cells:
    #    cells[cell].hobj.insert_mechs(cells[cell].gid)
    
    sim.run()
    bionet.nrn.quit_execution()
        fullsecname = seg.sec.name()

        source_pops.append(source._population)
        node_ids.append(source._node_id)

        weights.append(float(syn.initW))
        release_probs.append(float(syn.P_0))
        names.append(str(seg))
        sec_types.append(fullsecname.split(".")[1][:4])
        dists.append(float(h.distance(seg)))

    df = pd.DataFrame()
    df["Node ID"] = node_ids
    df["Distance"] = dists
    df["Conductance"] = weights
    df["Type"] = sec_types
    df["Name"] = names
    df["Source Population"] = source_pops
    df["Release Probability"] = release_probs
    df.to_csv("Connections.csv", index=False)


if __name__ == "__main__":
    synapses.load()
    syn = synapses.syn_params_dicts()

    np.random.seed(42)

    run.run_network(
        [save_connections],
        v_report_all=False)  #make v_report_all True to save all segments