-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from alessandratrapani/full_cereb_100_trials
30 trials and full cerebellum
- Loading branch information
Showing
5 changed files
with
401 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import json | ||
|
||
with open("./demo_cerebellum.json", "r") as json_file: | ||
demo_cerebellum_config = json.load(json_file) | ||
with open("./data/mouse_cerebellum_config_healthy.json", "r") as json_file: | ||
mouse_cerebellum_config_healthy = json.load(json_file) | ||
#%% | ||
check_neurons_models = False | ||
demo_neuron_models = demo_cerebellum_config["cell_types"] | ||
mouse_healthy_neuron_models = mouse_cerebellum_config_healthy["simulations"][ | ||
"DCN_update" | ||
]["cell_models"] | ||
neuron_to_check = [ | ||
"basket_cell", | ||
"dcn_cell_GABA", | ||
"dcn_cell_Gly-I", | ||
"dcn_cell_glut_large", | ||
"golgi_cell", | ||
"granule_cell", | ||
"purkinje_cell", | ||
"stellate_cell", | ||
"io_cell", | ||
] | ||
if check_neurons_models: | ||
|
||
for cell in neuron_to_check: | ||
print(cell) | ||
|
||
for property in mouse_healthy_neuron_models[cell]["parameters"].keys(): | ||
assert ( | ||
demo_neuron_models[cell]["parameters"][property] | ||
== mouse_healthy_neuron_models[cell]["parameters"][property] | ||
), f"{cell}, {property}" | ||
if cell == "io_cell": | ||
for property in mouse_healthy_neuron_models[cell]["iaf_cond_alpha"].keys(): | ||
if property != "receptors": | ||
demo = demo_neuron_models[cell]["parameters"][property] | ||
ali = mouse_healthy_neuron_models[cell]["iaf_cond_alpha"][property] | ||
assert demo == ali, f"{cell}, {property}: demo={demo} ali={ali}" | ||
else: | ||
for property in mouse_healthy_neuron_models[cell][ | ||
"eglif_cond_alpha_multisyn" | ||
].keys(): | ||
if property != "receptors": | ||
demo = demo_neuron_models[cell]["parameters"][property] | ||
ali = mouse_healthy_neuron_models[cell][ | ||
"eglif_cond_alpha_multisyn" | ||
][property] | ||
assert demo == ali, f"{cell}, {property}: demo={demo} ali={ali}" | ||
#%% | ||
check_connections_model=True | ||
if check_connections_model: | ||
demo_conn_models = demo_cerebellum_config["connection_models"] | ||
mouse_healthy_conn_models = mouse_cerebellum_config_healthy["simulations"]["DCN_update"]["connection_models"] | ||
conn_models_to_check = demo_conn_models.keys() | ||
for conn in conn_models_to_check: | ||
demo = [demo_conn_models[conn]["weight"], demo_conn_models[conn]["delay"]] | ||
ali = [mouse_healthy_conn_models[conn]["connection"]["weight"], mouse_healthy_conn_models[conn]["connection"]["delay"]] | ||
assert demo==ali, f"{conn}, weight: demo={demo[0]} ali={ali[0]}, delay: demo={demo[1]} ali={ali[1]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#%% | ||
import h5py | ||
import dill | ||
|
||
|
||
def save_dict_to_hdf5(file_path, data_dict): | ||
with h5py.File(file_path, 'w') as hdf_file: | ||
recursively_save_dict_contents(hdf_file, '/', data_dict) | ||
|
||
def recursively_save_dict_contents(hdf_file, path, data_dict): | ||
for key, item in data_dict.items(): | ||
if key!="param_vt" and key!="vt_num": | ||
if isinstance(item, (dict)): | ||
recursively_save_dict_contents(hdf_file, path + key + '/', item) | ||
else: | ||
hdf_file[path + key] = item | ||
|
||
|
||
data_path = "./data/" | ||
hdf5_file = "cerebellum_300x_200z.hdf5" | ||
scaffold = h5py.File(data_path + hdf5_file, "r") | ||
neuronal_populations_from_hdf5 = scaffold["cells"]["placement"] | ||
connectivity_from_hdf5 = scaffold["cells"]["connections"] | ||
|
||
#%% | ||
create_new = False | ||
if create_new: | ||
network_geom_file = data_path + "geom_" + hdf5_file | ||
network_connectivity_file = data_path + "conn_" + hdf5_file | ||
neuronal_populations = dill.load(open(network_geom_file, "rb")) | ||
connectivity = dill.load(open(network_connectivity_file, "rb")) | ||
|
||
save_dict_to_hdf5(data_path + "new_geom_" + hdf5_file, neuronal_populations) | ||
save_dict_to_hdf5(data_path + "new_conn_" + hdf5_file, connectivity) | ||
#%% | ||
check_connections=False | ||
if check_connections: | ||
neuronal_populations = h5py.File(data_path + "new_geom_" + hdf5_file, "r") | ||
connectivity = h5py.File(data_path + "new_conn_" + hdf5_file, "r") | ||
|
||
for conn in connectivity: | ||
if not conn=="io_to_vt": | ||
print(conn) | ||
id_pre = connectivity[conn]["id_pre"] | ||
id_post = connectivity[conn]["id_post"] | ||
differences = [] | ||
for i in range(len(connectivity_from_hdf5[conn])): | ||
if id_pre[i] != int(connectivity_from_hdf5[conn][i][0])+1: | ||
differences.append([0,i]) | ||
if id_post[i] != int(connectivity_from_hdf5[conn][i][1])+1: | ||
differences.append([1,i]) | ||
print(differences) | ||
#%% |
Oops, something went wrong.