Add files via upload

This commit is contained in:
David Rotermund 2024-08-12 11:28:41 +02:00 committed by GitHub
parent d44662edfc
commit ee9f9904ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 58 deletions

View file

@ -53,44 +53,6 @@ def loader(mouse: int = 0, fpath: str = "/data_1/hendrik/gevi") -> None:
], # 0, 0, 0 in cond 5-7
]
# 41, 42, 45, 46, 49:
# "1": "control",
# "2": "visual control grating 100 1s",
# "3": "optical Stimulation 20Hz 50% 5 Intervals",
# "4": "optical Stimulation 20Hz 100% 5 Intervals",
# "5": "optical Stimulation 20Hz 50% and grating 100",
# "6": "optical Stimulation 20Hz 100% and grating 100",
# "7": "grating 3s"
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"],
]
n_exp = len(n_tris[mouse])
for i_exp in range(n_exp):

View file

@ -1,6 +1,5 @@
import numpy as np
import matplotlib.pyplot as plt
import h5py # type: ignore
import argh
import scipy # type: ignore
import json
@ -22,8 +21,8 @@ def plot(
experiment: int = 4,
skip_timesteps: int = 100,
# If there is no special ROI... Get one! This is just a backup
roi_control_path: str = "/data_1/hendrik/2023-03-15/ROI_control.mat",
roi_sdraken_path: str = "/data_1/hendrik/2023-03-15/ROI_sDarken.mat",
roi_control_path_default: str = "roi_controlM_Sert_Cre_49.npy",
roi_sdarken_path_default: str = "roi_sdarkenM_Sert_Cre_49.npy",
remove_fit: bool = True,
fit_power: bool = False, # True => -ax^b ; False => exp(-b)
) -> None:
@ -80,15 +79,16 @@ def plot(
experiment_names = metadata['sessionMetaData']['experimentNames'][str(experiment)]
roi_path: str = os.path.join(config["basic_path"], config["recoding_data"])
roi_control_mat: str = os.path.join(roi_path, "ROI_control.mat")
roi_sdarken_mat: str = os.path.join(roi_path, "ROI_sDarken.mat")
roi_control_path: str = f"roi_control{config["mouse_identifier"]}.npy"
roi_sdarken_path: str = f"roi_sdarken{config["mouse_identifier"]}.npy"
if os.path.isdir(roi_control_mat):
roi_control_path = roi_control_mat
if os.path.isfile(roi_control_path) is False:
print(f"Using replacement RIO: {roi_control_path_default}")
roi_control_path = roi_control_path_default
if os.path.isdir(roi_sdarken_mat):
roi_sdraken_path = roi_sdarken_mat
if os.path.isfile(roi_sdarken_path) is False:
print(f"Using replacement RIO: {roi_sdarken_path_default}")
roi_sdarken_path = roi_sdarken_path_default
print("Load data...")
data = np.load("dsq_" + config["mouse_identifier"] + ".npy", mmap_mode="r")
@ -99,31 +99,31 @@ def plot(
print("Load mask...")
mask = np.load("msq_" + config["mouse_identifier"] + ".npy")
hf = h5py.File(roi_control_path, "r")
roi_lighten = np.array(hf["roi"]).T
roi_lighten *= mask
roi_control = np.load(roi_control_path)
roi_control *= mask
assert roi_control.sum() > 0, "ROI control empty"
hf = h5py.File(roi_sdraken_path, "r")
roi_darken = np.array(hf["roi"]).T
roi_darken = np.load(roi_sdarken_path)
roi_darken *= mask
assert roi_darken.sum() > 0, "ROI sDarken empty"
plt.figure(1)
a_show = data[experiment - 1, :, :, 1000].copy()
a_show[(roi_darken + roi_lighten) < 0.5] = np.nan
a_show[(roi_darken + roi_control) < 0.5] = np.nan
plt.imshow(a_show)
plt.title(f"{config["mouse_identifier"]} -- Experiment: {experiment}")
plt.show(block=False)
plt.figure(2)
a_dontshow = data[experiment - 1, :, :, 1000].copy()
a_dontshow[(roi_darken + roi_lighten) > 0.5] = np.nan
a_dontshow[(roi_darken + roi_control) > 0.5] = np.nan
plt.imshow(a_dontshow)
plt.title(f"{config["mouse_identifier"]} -- Experiment: {experiment}")
plt.show(block=False)
plt.figure(3)
light_exp = light[experiment - 1, :, :, skip_timesteps:].copy()
light_exp[(roi_darken + roi_lighten) < 0.5, :] = 0.0
light_exp[(roi_darken + roi_control) < 0.5, :] = 0.0
light_signal = light_exp.mean(axis=(0, 1))
light_signal -= light_signal.min()
light_signal /= light_signal.max()
@ -131,7 +131,7 @@ def plot(
a_exp = data[experiment - 1, :, :, skip_timesteps:].copy()
if remove_fit:
combined_matrix = (roi_darken + roi_lighten) > 0
combined_matrix = (roi_darken + roi_control) > 0
idx = np.where(combined_matrix)
for idx_pos in range(0, idx[0].shape[0]):
temp = a_exp[idx[0][idx_pos], idx[1][idx_pos], :]
@ -185,7 +185,7 @@ def plot(
temp -= pattern
darken = a_exp[roi_darken > 0.5, :].sum(axis=0) / (roi_darken > 0.5).sum()
lighten = a_exp[roi_lighten > 0.5, :].sum(axis=0) / (roi_lighten > 0.5).sum()
lighten = a_exp[roi_control > 0.5, :].sum(axis=0) / (roi_control > 0.5).sum()
light_signal *= darken.max() - darken.min()
light_signal += darken.min()