How to use the allensdk.core.json_utilities.write function in allensdk

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_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:
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / hack_consolidate_passive_strategy.py View on Github external
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 / hack_optimize_input.py View on Github external
"preprocess_results": data["paths"]["preprocess_results"],
    "passive_results": os.path.join(data["paths"]["storage_directory"], "passive_results.json"),
    "fit_style": resource_filename(boph_name, "fit_styles/%s_fit_style.json" % fit_type),
    "compiled_mod_library": resource_filename(boph_name, "x86_64/.libs/libnrnmech.so"),
    "hoc_files": [ "stdgui.hoc", "import3d.hoc", resource_filename(boph_name, "cell.hoc") ]
  },
  "fit_type": fit_type,
  "seed": seed,
  "mu": args.mu,
  "ngen": args.ngen,
}

if args.sp is not None:
    output["paths"]["starting_population"] = args.sp

ju.write(args.output, output)
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_model_selection.py View on Github external
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 / run_consolidate_passive_fitting.py View on Github external
cm2 = 2.
        else:
            cm2 = 1.

    passive = {
        "ra": ra,
        "cm": {"soma": cm1, "axon": cm1, "dend": cm2 },
        "e_pas": preprocess_results["v_baseline"]
    }

    passive["e_pas"] = preprocess_results["v_baseline"]
    if preprocess_results["has_apical"]:
        passive["cm"]["apic"] = cm2

    passive_results_path = module.args["paths"]["passive_results"]
    ju.write(passive_results_path, passive)

    output = {
        "paths": {
            "passive_results": passive_results_path,
        }
    }

    ju.write(module.args["output_json"], output)
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_consolidate_passive_fitting.py View on Github external
}

    passive["e_pas"] = preprocess_results["v_baseline"]
    if preprocess_results["has_apical"]:
        passive["cm"]["apic"] = cm2

    passive_results_path = module.args["paths"]["passive_results"]
    ju.write(passive_results_path, passive)

    output = {
        "paths": {
            "passive_results": passive_results_path,
        }
    }

    ju.write(module.args["output_json"], output)
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_preprocessing.py View on Github external
escape_time = preprocess.passive_fit_window(grand_up, grand_down, t,
            start_time=passive_fit_start_time)
        passive_info = {
            "should_run": True,
            "bridge": bridge_avg,
            "fit_window_start": passive_fit_start_time,
            "fit_window_end": escape_time,
            "electrode_cap": electrode_capacitance,
            "is_spiny": is_spiny,
        }
        paths["up"] = up_file
        paths["down"] = down_file

    passive_info_path = os.path.join(
        paths["storage_directory"], "passive_info.json")
    ju.write(passive_info_path, passive_info)

    # Determine whether morphology has an apical dendrite
    has_apical = preprocess.swc_has_apical_compartments(paths["swc"])

    # Decide which fits to run based on morphology and AP width
    fit_types = preprocess.FitStyle.get_fit_types(
        has_apical=has_apical,
        is_spiny=is_spiny,
        width=target_info.at["width", "mean"])

    stage_1_tasks = [{"fit_type": fit_type, "seed": seed}
        for seed in random_seeds
        for fit_type in fit_types]

    stage_2_tasks = [{"fit_type": preprocess.FitStyle.map_stage_2(fit_type), "seed": seed}
        for seed in random_seeds
github AllenInstitute / biophys_optimize / biophys_optimize / scripts / run_preprocessing.py View on Github external
"sweeps": sweeps,
        "sweeps_to_fit": [s.sweep_number for s in sweep_set_to_fit.sweeps],
    })

    paths.update({
        "preprocess_results": preprocess_results_path,
        "passive_info": passive_info_path,
    })

    output = {
        "paths": paths,
        "stage_1_task_list": stage_1_tasks,
        "stage_2_task_list": stage_2_tasks,
    }

    ju.write(module.args["output_json"], output)