mirror of
https://github.com/davrot/gevi.git
synced 2025-07-05 08:00:01 +02:00
Add files via upload
This commit is contained in:
parent
62bd82dab5
commit
9fb22407a9
2 changed files with 111 additions and 89 deletions
|
@ -7,34 +7,41 @@ from functions.load_config import load_config
|
||||||
from functions.get_trials import get_trials
|
from functions.get_trials import get_trials
|
||||||
import h5py # type: ignore
|
import h5py # type: ignore
|
||||||
|
|
||||||
control_file_handle = h5py.File("ROI_control_49.mat", "r")
|
import argh
|
||||||
control_roi = (np.array(control_file_handle["roi"]).T) > 0
|
|
||||||
control_file_handle.close()
|
|
||||||
control_roi = control_roi.reshape((control_roi.shape[0] * control_roi.shape[1]))
|
|
||||||
|
|
||||||
s_darken_file_handle = h5py.File("ROI_sDarken_49.mat", "r")
|
|
||||||
s_darken_roi = (np.array(s_darken_file_handle["roi"]).T) > 0
|
|
||||||
s_darken_file_handle.close()
|
|
||||||
s_darken_roi = s_darken_roi.reshape((s_darken_roi.shape[0] * s_darken_roi.shape[1]))
|
|
||||||
|
|
||||||
mylogger = create_logger(
|
def main(*, experiment_id: int = 1, config_filename: str = "config.json") -> None:
|
||||||
save_logging_messages=True, display_logging_messages=True, log_stage_name="test_xxx"
|
|
||||||
)
|
|
||||||
config = load_config(mylogger=mylogger)
|
|
||||||
|
|
||||||
experiment_id: int = 1
|
mylogger = create_logger(
|
||||||
|
save_logging_messages=True,
|
||||||
|
display_logging_messages=True,
|
||||||
|
log_stage_name="test_xxx",
|
||||||
|
)
|
||||||
|
config = load_config(mylogger=mylogger, filename=config_filename)
|
||||||
|
|
||||||
raw_data_path: str = os.path.join(
|
roi_path: str = config["ref_image_path"]
|
||||||
|
|
||||||
|
control_file_handle = h5py.File(os.path.join(roi_path, "ROI_control.mat"), "r")
|
||||||
|
control_roi = (np.array(control_file_handle["roi"]).T) > 0
|
||||||
|
control_file_handle.close()
|
||||||
|
control_roi = control_roi.reshape((control_roi.shape[0] * control_roi.shape[1]))
|
||||||
|
|
||||||
|
s_darken_file_handle = h5py.File(os.path.join(roi_path, "ROI_sDarken.mat"), "r")
|
||||||
|
s_darken_roi = (np.array(s_darken_file_handle["roi"]).T) > 0
|
||||||
|
s_darken_file_handle.close()
|
||||||
|
s_darken_roi = s_darken_roi.reshape((s_darken_roi.shape[0] * s_darken_roi.shape[1]))
|
||||||
|
|
||||||
|
raw_data_path: str = os.path.join(
|
||||||
config["basic_path"],
|
config["basic_path"],
|
||||||
config["recoding_data"],
|
config["recoding_data"],
|
||||||
config["mouse_identifier"],
|
config["mouse_identifier"],
|
||||||
config["raw_path"],
|
config["raw_path"],
|
||||||
)
|
)
|
||||||
|
|
||||||
data_path: str = "output"
|
data_path: str = str(config["export_path"])
|
||||||
|
|
||||||
trails = get_trials(path=raw_data_path, experiment_id=experiment_id)
|
trails = get_trials(path=raw_data_path, experiment_id=experiment_id)
|
||||||
for i in range(0, trails.shape[0]):
|
for i in range(0, trails.shape[0]):
|
||||||
trial_id = int(trails[i])
|
trial_id = int(trails[i])
|
||||||
experiment_name: str = f"Exp{experiment_id:03d}_Trial{trial_id:03d}"
|
experiment_name: str = f"Exp{experiment_id:03d}_Trial{trial_id:03d}"
|
||||||
mylogger.info(f"Loading files for {experiment_name}")
|
mylogger.info(f"Loading files for {experiment_name}")
|
||||||
|
@ -45,19 +52,23 @@ for i in range(0, trails.shape[0]):
|
||||||
else:
|
else:
|
||||||
ratio_sequence += data["ratio_sequence"]
|
ratio_sequence += data["ratio_sequence"]
|
||||||
|
|
||||||
ratio_sequence /= float(trails.shape[0])
|
ratio_sequence /= float(trails.shape[0])
|
||||||
|
|
||||||
ratio_sequence = ratio_sequence.reshape(
|
ratio_sequence = ratio_sequence.reshape(
|
||||||
(ratio_sequence.shape[0] * ratio_sequence.shape[1], ratio_sequence.shape[2])
|
(ratio_sequence.shape[0] * ratio_sequence.shape[1], ratio_sequence.shape[2])
|
||||||
)
|
)
|
||||||
|
|
||||||
control = ratio_sequence[control_roi, :].mean(axis=0)
|
control = ratio_sequence[control_roi, :].mean(axis=0)
|
||||||
s_darken = ratio_sequence[s_darken_roi, :].mean(axis=0)
|
s_darken = ratio_sequence[s_darken_roi, :].mean(axis=0)
|
||||||
|
|
||||||
t = np.arange(0, control.shape[0]) / 100.0
|
t = np.arange(0, control.shape[0]) / 100.0
|
||||||
|
|
||||||
plt.plot(t, control, label="control")
|
plt.plot(t, control, label="control")
|
||||||
plt.plot(t, s_darken, label="sDarken")
|
plt.plot(t, s_darken, label="sDarken")
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.xlabel("Time [sec]")
|
plt.xlabel("Time [sec]")
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
argh.dispatch_command(main)
|
||||||
|
|
|
@ -8,34 +8,41 @@ from functions.get_trials import get_trials
|
||||||
import h5py # type: ignore
|
import h5py # type: ignore
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
control_file_handle = h5py.File("ROI_control_49.mat", "r")
|
import argh
|
||||||
control_roi = (np.array(control_file_handle["roi"]).T) > 0
|
|
||||||
control_file_handle.close()
|
|
||||||
control_roi = control_roi.reshape((control_roi.shape[0] * control_roi.shape[1]))
|
|
||||||
|
|
||||||
s_darken_file_handle = h5py.File("ROI_sDarken_49.mat", "r")
|
|
||||||
s_darken_roi = (np.array(s_darken_file_handle["roi"]).T) > 0
|
|
||||||
s_darken_file_handle.close()
|
|
||||||
s_darken_roi = s_darken_roi.reshape((s_darken_roi.shape[0] * s_darken_roi.shape[1]))
|
|
||||||
|
|
||||||
mylogger = create_logger(
|
def main(*, experiment_id: int = 1, config_filename: str = "config.json") -> None:
|
||||||
save_logging_messages=True, display_logging_messages=True, log_stage_name="test_xxx"
|
|
||||||
)
|
|
||||||
config = load_config(mylogger=mylogger)
|
|
||||||
|
|
||||||
experiment_id: int = 2
|
mylogger = create_logger(
|
||||||
|
save_logging_messages=True,
|
||||||
|
display_logging_messages=True,
|
||||||
|
log_stage_name="test_xxx",
|
||||||
|
)
|
||||||
|
config = load_config(mylogger=mylogger, filename=config_filename)
|
||||||
|
|
||||||
raw_data_path: str = os.path.join(
|
roi_path: str = config["ref_image_path"]
|
||||||
|
|
||||||
|
control_file_handle = h5py.File(os.path.join(roi_path, "ROI_control.mat"), "r")
|
||||||
|
control_roi = (np.array(control_file_handle["roi"]).T) > 0
|
||||||
|
control_file_handle.close()
|
||||||
|
control_roi = control_roi.reshape((control_roi.shape[0] * control_roi.shape[1]))
|
||||||
|
|
||||||
|
s_darken_file_handle = h5py.File(os.path.join(roi_path, "ROI_sDarken.mat"), "r")
|
||||||
|
s_darken_roi = (np.array(s_darken_file_handle["roi"]).T) > 0
|
||||||
|
s_darken_file_handle.close()
|
||||||
|
s_darken_roi = s_darken_roi.reshape((s_darken_roi.shape[0] * s_darken_roi.shape[1]))
|
||||||
|
|
||||||
|
raw_data_path: str = os.path.join(
|
||||||
config["basic_path"],
|
config["basic_path"],
|
||||||
config["recoding_data"],
|
config["recoding_data"],
|
||||||
config["mouse_identifier"],
|
config["mouse_identifier"],
|
||||||
config["raw_path"],
|
config["raw_path"],
|
||||||
)
|
)
|
||||||
|
|
||||||
data_path: str = "output"
|
data_path: str = str(config["export_path"])
|
||||||
|
|
||||||
trails = get_trials(path=raw_data_path, experiment_id=experiment_id)
|
trails = get_trials(path=raw_data_path, experiment_id=experiment_id)
|
||||||
for i in range(0, trails.shape[0]):
|
for i in range(0, trails.shape[0]):
|
||||||
trial_id = int(trails[i])
|
trial_id = int(trails[i])
|
||||||
experiment_name: str = f"Exp{experiment_id:03d}_Trial{trial_id:03d}"
|
experiment_name: str = f"Exp{experiment_id:03d}_Trial{trial_id:03d}"
|
||||||
mylogger.info(f"Loading files for {experiment_name}")
|
mylogger.info(f"Loading files for {experiment_name}")
|
||||||
|
@ -61,11 +68,15 @@ for i in range(0, trails.shape[0]):
|
||||||
else:
|
else:
|
||||||
ratio_sequence += rs_s_core - rs_c_core
|
ratio_sequence += rs_s_core - rs_c_core
|
||||||
|
|
||||||
ratio_sequence /= float(trails.shape[0])
|
ratio_sequence /= float(trails.shape[0])
|
||||||
|
|
||||||
t = np.arange(0, ratio_sequence.shape[0]) / 100.0
|
t = np.arange(0, ratio_sequence.shape[0]) / 100.0
|
||||||
|
|
||||||
plt.plot(t, ratio_sequence, label="sDarken-control")
|
plt.plot(t, ratio_sequence, label="sDarken - control")
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.xlabel("Time [sec]")
|
plt.xlabel("Time [sec]")
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
argh.dispatch_command(main)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue