Add files via upload

This commit is contained in:
David Rotermund 2024-08-12 10:54:17 +02:00 committed by GitHub
parent e88f8ca707
commit f144c97dc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 127 additions and 20 deletions

View file

@ -4,22 +4,53 @@ import argh
# mouse:int = 0, 1, 2, 3, 4 # mouse:int = 0, 1, 2, 3, 4
def loader(mouse:int = 0, fpath:str = "/data_1/hendrik/gevi") -> None: def loader(mouse: int = 0, fpath: str = "/data_1/hendrik/gevi") -> None:
mouse_name = [ mouse_name = [
'M_Sert_Cre_41', "M_Sert_Cre_41",
'M_Sert_Cre_42', "M_Sert_Cre_42",
'M_Sert_Cre_45', "M_Sert_Cre_45",
'M_Sert_Cre_46', "M_Sert_Cre_46",
'M_Sert_Cre_49' "M_Sert_Cre_49",
] ]
n_tris = [ n_tris = [
[15, 15, 30, 30, 30, 30,], # 0 in cond 7 [
[15, 15, 30, 30, 30, 30,], # 0 in cond 7 15,
[15, 15, 30, 30, 30, 30,], # 0 in cond 7 15,
[20, 40, 20, 20,], # 0, 0, 0 in cond 5-7 30,
[20, 40, 20, 20,], # 0, 0, 0 in cond 5-7 30,
30,
30,
], # 0 in cond 7
[
15,
15,
30,
30,
30,
30,
], # 0 in cond 7
[
15,
15,
30,
30,
30,
30,
], # 0 in cond 7
[
20,
40,
20,
20,
], # 0, 0, 0 in cond 5-7
[
20,
40,
20,
20,
], # 0, 0, 0 in cond 5-7
] ]
# 41, 42, 45, 46, 49: # 41, 42, 45, 46, 49:
@ -32,11 +63,32 @@ def loader(mouse:int = 0, fpath:str = "/data_1/hendrik/gevi") -> None:
# "7": "grating 3s" # "7": "grating 3s"
lbs = [ lbs = [
['control', 'visual control', 'op20 50 5', 'op20 100 5', 'op20 50 grat', 'op20 100 grat'], [
['control', 'visual control', 'op20 50 5', 'op20 100 5', 'op20 50 grat', 'op20 100 grat'], "control",
['control', 'visual control', 'op20 50 5', 'op20 100 5', 'op20 50 grat', 'op20 100 grat'], "visual control",
['control', 'visual control', 'op20 50 5', 'op20 100 5'], "op20 50 5",
['control', 'visual control', 'op20 50 5', 'op20 100 5'] "op20 100 5",
"op20 50 grat",
"op20 100 grat",
],
[
"control",
"visual control",
"op20 50 5",
"op20 100 5",
"op20 50 grat",
"op20 100 grat",
],
[
"control",
"visual control",
"op20 50 5",
"op20 100 5",
"op20 50 grat",
"op20 100 grat",
],
["control", "visual control", "op20 50 5", "op20 100 5"],
["control", "visual control", "op20 50 5", "op20 100 5"],
] ]
n_exp = len(n_tris[mouse]) n_exp = len(n_tris[mouse])
@ -45,9 +97,11 @@ def loader(mouse:int = 0, fpath:str = "/data_1/hendrik/gevi") -> None:
n_tri = n_tris[mouse][i_exp] n_tri = n_tris[mouse][i_exp]
for i_tri in range(n_tri): for i_tri in range(n_tri):
experiment_name: str = f"Exp{i_exp+1:03d}_Trial{i_tri+1:03d}" experiment_name: str = f"Exp{i_exp + 1:03d}_Trial{i_tri + 1:03d}"
tmp_fname = os.path.join( tmp_fname = os.path.join(
fpath, "output_" + mouse_name[mouse], experiment_name + "_acceptor_donor.npz" fpath,
"output_" + mouse_name[mouse],
experiment_name + "_acceptor_donor.npz",
) )
print(f'Processing file "{tmp_fname}"...') print(f'Processing file "{tmp_fname}"...')
tmp = np.load(tmp_fname) tmp = np.load(tmp_fname)
@ -67,5 +121,6 @@ def loader(mouse:int = 0, fpath:str = "/data_1/hendrik/gevi") -> None:
np.save("lsq_" + mouse_name[mouse], light_signal) np.save("lsq_" + mouse_name[mouse], light_signal)
np.save("msq_" + mouse_name[mouse], mask) np.save("msq_" + mouse_name[mouse], mask)
if __name__ == "__main__": if __name__ == "__main__":
argh.dispatch_command(loader) argh.dispatch_command(loader)

View file

@ -79,7 +79,7 @@ def plot(
trials = get_trials(raw_data_path, experiment).numpy() trials = get_trials(raw_data_path, experiment).numpy()
assert trials.shape[0] > 0 assert trials.shape[0] > 0
with open(os.path.join(raw_data_path, f"Exp{experiment:03d}_Trial{trials[0]:03d}_Part001_meta.txt"), "r") as file: with open(f"meta_{config["mouse_identifier"]}_exp{experiment:03d}.json", "r") as file:
metadata = json.loads(jsmin(file.read())) metadata = json.loads(jsmin(file.read()))
experiment_names = metadata['sessionMetaData']['experimentNames'][str(experiment)] experiment_names = metadata['sessionMetaData']['experimentNames'][str(experiment)]

View file

@ -0,0 +1,52 @@
import json
import os
import argh
from jsmin import jsmin # type:ignore
from functions.get_trials import get_trials
from functions.get_experiments import get_experiments
def converter(filename: str = "config_M_Sert_Cre_49.json") -> None:
if os.path.isfile(filename) is False:
print(f"{filename} is missing")
exit()
with open(filename, "r") as file:
config = json.loads(jsmin(file.read()))
raw_data_path: str = os.path.join(
config["basic_path"],
config["recoding_data"],
config["mouse_identifier"],
config["raw_path"],
)
if os.path.isdir(raw_data_path) is False:
print(f"ERROR: could not find raw directory {raw_data_path}!!!!")
exit()
experiments = get_experiments(raw_data_path).numpy()
for experiment in experiments:
trials = get_trials(raw_data_path, experiment).numpy()
assert trials.shape[0] > 0
with open(
os.path.join(
raw_data_path,
f"Exp{experiment:03d}_Trial{trials[0]:03d}_Part001_meta.txt",
),
"r",
) as file:
metadata = json.loads(jsmin(file.read()))
filename_out: str = f"meta_{config["mouse_identifier"]}_exp{experiment:03d}.json"
with open(filename_out, 'w') as file:
json.dump(metadata, file)
if __name__ == "__main__":
argh.dispatch_command(converter)