import json


def get_syn_setup_params(
    syn_extra_params_path,
    cpre_cpost_path,
    fit_params_path,
    gid,
    invivo,
):
    """Load json files and return syn_setup_params dict.

    Args:
        syn_extra_params_path (str): path to the glusynapses related extra parameters file
        cpre_cpost_path (str): path to the c_pre and c_post related file
            c_pre (resp. c_post) is the calcium amplitude during isolated presynaptic
            (resp. postsynaptic) activation
        fit_params_path (str): path to the file containing the glusynapse fitted parameters
            The fitted parameters are time constant of calcium integrator, depression rate,
            potentiation rate, and factors used in plasticity threshold computation.
        gid (int): ID of the postsynaptic cell
        invivo (bool): whether to run the simulation in 'in vivo' conditions

    Returns:
        dict: glusynapse setup related parameters
    """
    with open(syn_extra_params_path, "r", encoding="utf-8") as f:
        syn_extra_params = json.load(f)
    with open(cpre_cpost_path, "r", encoding="utf-8") as f:
        cpre_cpost = json.load(f)
    with open(fit_params_path, "r", encoding="utf-8") as f:
        fit_params = json.load(f)

    return {
        "syn_extra_params": syn_extra_params,
        "c_pre": cpre_cpost["c_pre"],
        "c_post": cpre_cpost["c_post"],
        "fit_params": fit_params,
        "postgid": gid,
        "invivo": invivo,
    }