How to use allensdk - 10 common examples

To help you get started, we’ve selected a few allensdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_optimize.py View on Github external
def main():
    module = ags.ArgSchemaParser(schema_type=OptimizeParameters)

    preprocess_results = ju.read(module.args["paths"]["preprocess_results"])
    passive_results = ju.read(module.args["paths"]["passive_results"])
    fit_style_data = ju.read(module.args["paths"]["fit_style"])

    results = optimize(hoc_files=module.args["paths"]["hoc_files"],
                       compiled_mod_library=module.args["paths"]["compiled_mod_library"],
                       morphology_path=module.args["paths"]["swc"],
                       preprocess_results=preprocess_results,
                       passive_results=passive_results,
                       fit_type=module.args["fit_type"],
                       fit_style_data=fit_style_data,
                       seed=module.args["seed"],
                       ngen=module.args["ngen"],
                       mu=module.args["mu"],
                       storage_directory = module.args["paths"]["storage_directory"],
                       starting_population = module.args["paths"].get("starting_population",None))
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / hack_consolidate_passive_strategy.py View on Github external
import os.path
import allensdk.core.json_utilities as ju
import biophys_optimize.neuron_passive_fit as npf

parser = argparse.ArgumentParser(description='hack in paths that strategy will do - passive')
parser.add_argument('preprocess_out', type=str)
parser.add_argument('fit_1_out', type=str)
parser.add_argument('fit_2_out', type=str)
parser.add_argument('fit_elec_out', type=str)
parser.add_argument('output', type=str)
args = parser.parse_args()

data = ju.read(args.preprocess_out)
fit_1 = ju.read(args.fit_1_out)
fit_2 = ju.read(args.fit_2_out)
fit_3 = ju.read(args.fit_elec_out)

out_data = {
    "paths": {
        "passive_info": data["paths"]["passive_info"],
        "preprocess_results": data["paths"]["preprocess_results"],
        "passive_fit_1": fit_1["paths"][npf.PASSIVE_FIT_1],
        "passive_fit_2": fit_2["paths"][npf.PASSIVE_FIT_2],
        "passive_fit_elec": fit_3["paths"][npf.PASSIVE_FIT_ELEC],
        "passive_results": os.path.join(data["paths"]["storage_directory"], "passive_results.json")
        }
}

ju.write(args.output, out_data)
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_consolidate_passive_fitting.py View on Github external
def main():
    module = ags.ArgSchemaParser(schema_type=ConsolidateParameters)

    preprocess_results = ju.read(module.args["paths"]["preprocess_results"])
    is_spiny = preprocess_results["is_spiny"]
    info = ju.read(module.args["paths"]["passive_info"])

    if info["should_run"]:
        fit_1_path = module.args["paths"]["passive_fit_1"]
        fit_1 = ju.read(fit_1_path)

        fit_2_path = module.args["paths"]["passive_fit_2"]
        fit_2 = ju.read(fit_2_path)

        fit_3_path = module.args["paths"]["passive_fit_elec"]
        fit_3 = ju.read(fit_3_path)

        ra, cm1, cm2 = cpf.compare_runs(preprocess_results, fit_1, fit_2, fit_3)
    else:
        ra = 100.
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_model_selection.py View on Github external
swc_path = module.args["paths"]["swc"]
    fit_style_paths = module.args["paths"]["fit_styles"]
    best_fit_json_path = module.args["paths"]["best_fit_json_path"]
    passive = ju.read(module.args["paths"]["passive_results"])
    preprocess = ju.read(module.args["paths"]["preprocess_results"])


    fits = module.args["paths"]["fits"]
    fit_results = ms.fit_info(fits)
    best_fit = ms.select_model(fit_results, module.args["paths"], passive, preprocess["v_baseline"],
                               module.args["noise_1_sweeps"], module.args["noise_2_sweeps"])
    if best_fit is None:
        raise Exception("Failed to find acceptable optimized model")

    logging.info("building fit data")
    fit_style_data = ju.read(module.args["paths"]["fit_styles"][best_fit["fit_type"]])
    fit_data = ms.build_fit_data(best_fit["params"], passive, preprocess, fit_style_data)

    logging.info("writing fit data: %s", best_fit_json_path)
    ju.write(best_fit_json_path, fit_data)

    output = {
        "paths": {
            "fit_json": best_fit_json_path,
        }
    }

    logging.info("writing output json: %s", module.args["output_json"])
    ju.write(module.args["output_json"], output)
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / hack_consolidate_passive_strategy.py View on Github external
import argparse
import os.path
import allensdk.core.json_utilities as ju
import biophys_optimize.neuron_passive_fit as npf

parser = argparse.ArgumentParser(description='hack in paths that strategy will do - passive')
parser.add_argument('preprocess_out', type=str)
parser.add_argument('fit_1_out', type=str)
parser.add_argument('fit_2_out', type=str)
parser.add_argument('fit_elec_out', type=str)
parser.add_argument('output', type=str)
args = parser.parse_args()

data = ju.read(args.preprocess_out)
fit_1 = ju.read(args.fit_1_out)
fit_2 = ju.read(args.fit_2_out)
fit_3 = ju.read(args.fit_elec_out)

out_data = {
    "paths": {
        "passive_info": data["paths"]["passive_info"],
        "preprocess_results": data["paths"]["preprocess_results"],
        "passive_fit_1": fit_1["paths"][npf.PASSIVE_FIT_1],
        "passive_fit_2": fit_2["paths"][npf.PASSIVE_FIT_2],
        "passive_fit_elec": fit_3["paths"][npf.PASSIVE_FIT_ELEC],
        "passive_results": os.path.join(data["paths"]["storage_directory"], "passive_results.json")
        }
}

ju.write(args.output, out_data)
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_passive_fitting.py View on Github external
def main(paths, passive_fit_type, output_json, **kwargs):
    info = ju.read(paths["passive_info"])
    if not info["should_run"]:
        ju.write(output_json, { "paths": {} })
        return

    swc_path = paths["swc"].encode('ascii', 'ignore')
    up_data = np.loadtxt(paths["up"])
    down_data = np.loadtxt(paths["down"])
    results_file = paths["passive_fit_results_file"]

    npf.initialize_neuron(swc_path, paths["fit"])

    if passive_fit_type == npf.PASSIVE_FIT_1:
        results = npf.passive_fit_1(up_data, down_data,
            info["fit_window_start"], info["fit_window_end"])
    elif passive_fit_type == npf.PASSIVE_FIT_2:
        results = npf.passive_fit_2(up_data, down_data,
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_optimize.py View on Github external
def main():
    module = ags.ArgSchemaParser(schema_type=OptimizeParameters)

    preprocess_results = ju.read(module.args["paths"]["preprocess_results"])
    passive_results = ju.read(module.args["paths"]["passive_results"])
    fit_style_data = ju.read(module.args["paths"]["fit_style"])

    results = optimize(hoc_files=module.args["paths"]["hoc_files"],
                       compiled_mod_library=module.args["paths"]["compiled_mod_library"],
                       morphology_path=module.args["paths"]["swc"],
                       preprocess_results=preprocess_results,
                       passive_results=passive_results,
                       fit_type=module.args["fit_type"],
                       fit_style_data=fit_style_data,
                       seed=module.args["seed"],
                       ngen=module.args["ngen"],
                       mu=module.args["mu"],
                       storage_directory = module.args["paths"]["storage_directory"],
                       starting_population = module.args["paths"].get("starting_population",None))

    logging.info("Writing optimization output")
    ju.write(module.args["output_json"], results)
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_consolidate_passive_fitting.py View on Github external
def main():
    module = ags.ArgSchemaParser(schema_type=ConsolidateParameters)

    preprocess_results = ju.read(module.args["paths"]["preprocess_results"])
    is_spiny = preprocess_results["is_spiny"]
    info = ju.read(module.args["paths"]["passive_info"])

    if info["should_run"]:
        fit_1_path = module.args["paths"]["passive_fit_1"]
        fit_1 = ju.read(fit_1_path)

        fit_2_path = module.args["paths"]["passive_fit_2"]
        fit_2 = ju.read(fit_2_path)

        fit_3_path = module.args["paths"]["passive_fit_elec"]
        fit_3 = ju.read(fit_3_path)

        ra, cm1, cm2 = cpf.compare_runs(preprocess_results, fit_1, fit_2, fit_3)
    else:
        ra = 100.
        cm1 = 1.
        if is_spiny:
            cm2 = 2.
        else:
            cm2 = 1.

    passive = {
        "ra": ra,
        "cm": {"soma": cm1, "axon": cm1, "dend": cm2 },
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_optimize.py View on Github external
def main():
    module = ags.ArgSchemaParser(schema_type=OptimizeParameters)

    preprocess_results = ju.read(module.args["paths"]["preprocess_results"])
    passive_results = ju.read(module.args["paths"]["passive_results"])
    fit_style_data = ju.read(module.args["paths"]["fit_style"])

    results = optimize(hoc_files=module.args["paths"]["hoc_files"],
                       compiled_mod_library=module.args["paths"]["compiled_mod_library"],
                       morphology_path=module.args["paths"]["swc"],
                       preprocess_results=preprocess_results,
                       passive_results=passive_results,
                       fit_type=module.args["fit_type"],
                       fit_style_data=fit_style_data,
                       seed=module.args["seed"],
                       ngen=module.args["ngen"],
                       mu=module.args["mu"],
                       storage_directory = module.args["paths"]["storage_directory"],
                       starting_population = module.args["paths"].get("starting_population",None))

    logging.info("Writing optimization output")
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_passive_fitting.py View on Github external
def main(paths, passive_fit_type, output_json, **kwargs):
    info = ju.read(paths["passive_info"])
    if not info["should_run"]:
        ju.write(output_json, { "paths": {} })
        return

    swc_path = paths["swc"].encode('ascii', 'ignore')
    up_data = np.loadtxt(paths["up"])
    down_data = np.loadtxt(paths["down"])
    results_file = paths["passive_fit_results_file"]

    npf.initialize_neuron(swc_path, paths["fit"])

    if passive_fit_type == npf.PASSIVE_FIT_1:
        results = npf.passive_fit_1(up_data, down_data,
            info["fit_window_start"], info["fit_window_end"])
    elif passive_fit_type == npf.PASSIVE_FIT_2:
        results = npf.passive_fit_2(up_data, down_data,
            info["fit_window_start"], info["fit_window_end"])
    elif passive_fit_type == npf.PASSIVE_FIT_ELEC: