From a053ef39355231d111df5d220089e9d80b0d92a8 Mon Sep 17 00:00:00 2001 From: David Rotermund Date: Mon, 12 Aug 2024 11:45:06 +0200 Subject: [PATCH] Add files via upload --- geci_loader.py | 91 +++++++++++++++++++------------------------------- geci_plot.py | 29 ---------------- 2 files changed, 35 insertions(+), 85 deletions(-) diff --git a/geci_loader.py b/geci_loader.py index 137ad9e..5ee5884 100644 --- a/geci_loader.py +++ b/geci_loader.py @@ -1,68 +1,45 @@ import numpy as np import os +import json +from jsmin import jsmin # type:ignore import argh +from functions.get_trials import get_trials +from functions.get_experiments import get_experiments -# mouse:int = 0, 1, 2, 3, 4 -def loader(mouse: int = 0, fpath: str = "/data_1/hendrik/gevi") -> None: +def loader( + filename: str = "config_M_Sert_Cre_49.json", fpath: str = "/data_1/hendrik/gevi" +) -> None: - mouse_name = [ - "M_Sert_Cre_41", - "M_Sert_Cre_42", - "M_Sert_Cre_45", - "M_Sert_Cre_46", - "M_Sert_Cre_49", - ] + if os.path.isfile(filename) is False: + print(f"{filename} is missing") + exit() - n_tris = [ - [ - 15, - 15, - 30, - 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 - ] + with open(filename, "r") as file: + config = json.loads(jsmin(file.read())) - n_exp = len(n_tris[mouse]) + raw_data_path: str = os.path.join( + config["basic_path"], + config["recoding_data"], + config["mouse_identifier"], + config["raw_path"], + ) - for i_exp in range(n_exp): - n_tri = n_tris[mouse][i_exp] - for i_tri in range(n_tri): + experiments = get_experiments(raw_data_path).numpy() + n_exp = experiments.shape[0] - experiment_name: str = f"Exp{i_exp + 1:03d}_Trial{i_tri + 1:03d}" + for i_exp in range(0, n_exp): + trials = get_trials(raw_data_path, experiments[i_exp]).numpy() + n_tri = trials.shape[0] + + for i_tri in range(0, n_tri): + + experiment_name: str = ( + f"Exp{experiments[i_exp]:03d}_Trial{trials[i_tri]:03d}" + ) tmp_fname = os.path.join( fpath, - "output_" + mouse_name[mouse], + "output_" + config["mouse_identifier"], experiment_name + "_acceptor_donor.npz", ) print(f'Processing file "{tmp_fname}"...') @@ -76,12 +53,14 @@ def loader(mouse: int = 0, fpath: str = "/data_1/hendrik/gevi") -> None: new_shape = [n_exp, *tmp_data_sequence.shape] data_sequence = np.zeros(new_shape) light_signal = np.zeros(new_shape) + + # Here you might want to use the exp fit and removal... data_sequence[i_exp] += tmp_data_sequence / n_tri light_signal[i_exp] += tmp_light_signal / n_tri - np.save("dsq_" + mouse_name[mouse], data_sequence) - np.save("lsq_" + mouse_name[mouse], light_signal) - np.save("msq_" + mouse_name[mouse], mask) + np.save("dsq_" + config["mouse_identifier"], data_sequence) + np.save("lsq_" + config["mouse_identifier"], light_signal) + np.save("msq_" + config["mouse_identifier"], mask) if __name__ == "__main__": diff --git a/geci_plot.py b/geci_plot.py index db31e91..8fd9ab4 100644 --- a/geci_plot.py +++ b/geci_plot.py @@ -27,35 +27,6 @@ def plot( fit_power: bool = False, # True => -ax^b ; False => exp(-b) ) -> None: - # 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", - # "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"], - # ] - if os.path.isfile(filename) is False: print(f"{filename} is missing") exit()