Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)
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,
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)
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 },
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")