Compare commits
3 Commits
13e418f81e
...
116bee2272
Author | SHA1 | Date | |
---|---|---|---|
116bee2272 | |||
0b1750ea24 | |||
c37ff0562c |
@ -35,6 +35,13 @@ def main(
|
|||||||
log.info(f"Selected data_path is {data_path}")
|
log.info(f"Selected data_path is {data_path}")
|
||||||
open_ephys_data_paths = list(Path(data_path).rglob("*open-ephys"))
|
open_ephys_data_paths = list(Path(data_path).rglob("*open-ephys"))
|
||||||
relacs_data_paths = list(Path(data_path).rglob("*relacs/*.nix"))
|
relacs_data_paths = list(Path(data_path).rglob("*relacs/*.nix"))
|
||||||
|
if not open_ephys_data_paths:
|
||||||
|
log.error("Did not find any open-ephys data")
|
||||||
|
raise typer.Exit()
|
||||||
|
|
||||||
|
if not relacs_data_paths:
|
||||||
|
log.error("Did not find any relacs data")
|
||||||
|
raise typer.Exit()
|
||||||
|
|
||||||
if len(open_ephys_data_paths) != len(relacs_data_paths):
|
if len(open_ephys_data_paths) != len(relacs_data_paths):
|
||||||
log.error(
|
log.error(
|
||||||
|
@ -25,6 +25,9 @@ console = Console()
|
|||||||
|
|
||||||
class StimulusToNix:
|
class StimulusToNix:
|
||||||
def __init__(self, open_ephys_path: pathlib.Path, relacs_nix_path: str, nix_file: str):
|
def __init__(self, open_ephys_path: pathlib.Path, relacs_nix_path: str, nix_file: str):
|
||||||
|
self.relacs_nix_path = relacs_nix_path
|
||||||
|
self.nix_file_path = nix_file
|
||||||
|
|
||||||
self.dataset = rlx.Dataset(relacs_nix_path)
|
self.dataset = rlx.Dataset(relacs_nix_path)
|
||||||
|
|
||||||
self.relacs_nix_file = nixio.File.open(relacs_nix_path, nixio.FileMode.ReadOnly)
|
self.relacs_nix_file = nixio.File.open(relacs_nix_path, nixio.FileMode.ReadOnly)
|
||||||
@ -34,7 +37,6 @@ class StimulusToNix:
|
|||||||
self.neo_data = OpenEphysBinaryIO(open_ephys_path).read(lazy=True)
|
self.neo_data = OpenEphysBinaryIO(open_ephys_path).read(lazy=True)
|
||||||
self.fs = self.neo_data[0].segments[0].analogsignals[0].sampling_rate.magnitude
|
self.fs = self.neo_data[0].segments[0].analogsignals[0].sampling_rate.magnitude
|
||||||
|
|
||||||
self.nix_file_path = nix_file
|
|
||||||
self.nix_file = nixio.File(nix_file, nixio.FileMode.ReadWrite)
|
self.nix_file = nixio.File(nix_file, nixio.FileMode.ReadWrite)
|
||||||
self.block = self.nix_file.blocks[0]
|
self.block = self.nix_file.blocks[0]
|
||||||
|
|
||||||
@ -450,11 +452,8 @@ class StimulusToNix:
|
|||||||
for repro_r, repro_n in zip(self.dataset.repro_runs(), nix_data_set.repro_runs()):
|
for repro_r, repro_n in zip(self.dataset.repro_runs(), nix_data_set.repro_runs()):
|
||||||
if repro_n.name.split("_")[0] not in important_repros:
|
if repro_n.name.split("_")[0] not in important_repros:
|
||||||
continue
|
continue
|
||||||
if "SAM" in repro_n.name:
|
embed()
|
||||||
embed()
|
exit()
|
||||||
exit()
|
|
||||||
else:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if "FileStimulus" in repro_n.name:
|
if "FileStimulus" in repro_n.name:
|
||||||
repro_n.stimulus_folder = "/home/alexander/stimuli/whitenoise/"
|
repro_n.stimulus_folder = "/home/alexander/stimuli/whitenoise/"
|
||||||
@ -464,10 +463,38 @@ class StimulusToNix:
|
|||||||
|
|
||||||
stim = repro_n.stimuli[0]
|
stim = repro_n.stimuli[0]
|
||||||
stim_r = repro_r.stimuli[0]
|
stim_r = repro_r.stimuli[0]
|
||||||
v, t = stim.trace_data("local-eod")
|
|
||||||
v_r, t_r = stim_r.trace_data("LocalEOD-1")
|
# stim = repro_n
|
||||||
plt.plot(t_r, v_r, "o--", color="tab:blue", label="relacs")
|
# stim_r = repro_r
|
||||||
plt.plot(t, v, "o--", color="tab:red", label="open-ephys")
|
sinus, t = stim.trace_data("sinus")
|
||||||
|
sinus_r, t_r = stim_r.trace_data("V-1")
|
||||||
|
|
||||||
|
stimulus_oe, t = stim.trace_data("stimulus")
|
||||||
|
stimulus_re, t_r = stim_r.trace_data("GlobalEFieldStimulus")
|
||||||
|
|
||||||
|
local_eod_oe, t = stim.trace_data("local-eod")
|
||||||
|
local_eod_re, t_r = stim_r.trace_data("LocalEOD-1")
|
||||||
|
|
||||||
|
global_eod_oe, t = stim.trace_data("global-eod")
|
||||||
|
global_eod_re, t_r = stim_r.trace_data("EOD")
|
||||||
|
|
||||||
|
ttl, t = stim.trace_data("ttl-line")
|
||||||
|
|
||||||
|
fig, ax = plt.subplots(4, sharex=True)
|
||||||
|
ax[0].plot(t_r, stimulus_re, color="tab:blue", label="relacs")
|
||||||
|
ax[0].plot(t, stimulus_oe - np.mean(stimulus_oe), color="tab:red", label="open-ephys")
|
||||||
|
ax[0].plot(t, ttl, color="black")
|
||||||
|
|
||||||
|
ax[1].plot(t_r, local_eod_re, color="tab:blue", label="relacs")
|
||||||
|
ax[1].plot(t, local_eod_oe, color="tab:red", label="open-ephys")
|
||||||
|
|
||||||
|
ax[2].plot(t_r, global_eod_re, color="tab:blue", label="relacs")
|
||||||
|
ax[2].plot(t, global_eod_oe, color="tab:red", label="open-ephys")
|
||||||
|
|
||||||
|
ax[3].plot(t_r, sinus_r, color="tab:blue", label="relacs")
|
||||||
|
ax[3].plot(t, sinus, color="tab:red", label="open-ephys")
|
||||||
|
|
||||||
|
plt.legend(loc="upper right")
|
||||||
# plt.plot(stimulus_time, white_noise, "o--", color="tab:orange", label="stimulus")
|
# plt.plot(stimulus_time, white_noise, "o--", color="tab:orange", label="stimulus")
|
||||||
# plt.plot(new_t, new_v, "go--", label="resampled")
|
# plt.plot(new_t, new_v, "go--", label="resampled")
|
||||||
for i, (s, r) in enumerate(zip(repro_n.stimuli, repro_r.stimuli)):
|
for i, (s, r) in enumerate(zip(repro_n.stimuli, repro_r.stimuli)):
|
||||||
@ -475,7 +502,6 @@ class StimulusToNix:
|
|||||||
v_r, t_r = r.trace_data("LocalEOD-1")
|
v_r, t_r = r.trace_data("LocalEOD-1")
|
||||||
plt.plot(t_r + (i * r.duration), v_r)
|
plt.plot(t_r + (i * r.duration), v_r)
|
||||||
plt.plot(t + (i * s.duration), v)
|
plt.plot(t + (i * s.duration), v)
|
||||||
plt.legend(loc="upper right")
|
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
am = extract_am(v, 30_000)
|
am = extract_am(v, 30_000)
|
||||||
@ -490,7 +516,9 @@ class StimulusToNix:
|
|||||||
ttl_oeph = self.block.data_arrays["ttl-line"][:]
|
ttl_oeph = self.block.data_arrays["ttl-line"][:]
|
||||||
|
|
||||||
time_index = np.arange(len(ttl_oeph))
|
time_index = np.arange(len(ttl_oeph))
|
||||||
peaks_ttl = time_index[(np.roll(ttl_oeph, 1) < 2) & (ttl_oeph > 2)]
|
peaks_ttl = time_index[
|
||||||
|
(np.roll(ttl_oeph, 1) < self.threshold) & (ttl_oeph > self.threshold)
|
||||||
|
]
|
||||||
|
|
||||||
stimulus_oeph = self.block.data_arrays["stimulus"]
|
stimulus_oeph = self.block.data_arrays["stimulus"]
|
||||||
stimulus = self.relacs_block.data_arrays["GlobalEFieldStimulus"]
|
stimulus = self.relacs_block.data_arrays["GlobalEFieldStimulus"]
|
||||||
|
@ -35,23 +35,19 @@ class RawToNix:
|
|||||||
self.block.metadata = sec
|
self.block.metadata = sec
|
||||||
|
|
||||||
def append_fish_lines(self):
|
def append_fish_lines(self):
|
||||||
efishs = [
|
efishs = ["ttl-line", "global-eod", "stimulus", "local-eod", "sinus"]
|
||||||
"ttl-line",
|
|
||||||
"global-eod",
|
|
||||||
"stimulus",
|
|
||||||
"local-eod",
|
|
||||||
]
|
|
||||||
|
|
||||||
efish_types = [
|
efish_types = [
|
||||||
"open-ephys.data.sampled",
|
"open-ephys.data.sampled",
|
||||||
"open-ephys.data.sampled",
|
"open-ephys.data.sampled",
|
||||||
"open-ephys.data.sampled",
|
"open-ephys.data.sampled",
|
||||||
"open-ephys.data.sampled",
|
"open-ephys.data.sampled",
|
||||||
|
"open-ephys.data.sampled",
|
||||||
]
|
]
|
||||||
|
|
||||||
efish_group = self.block.create_group("efish", "open-ephys.sampled")
|
efish_group = self.block.create_group("efish", "open-ephys.sampled")
|
||||||
|
|
||||||
efish_neo_data = self.neo_data[0].segments[0].analogsignals[1].load()
|
efish_neo_data = self.neo_data[0].segments[0].analogsignals[2].load()
|
||||||
|
|
||||||
for i in np.arange(len(efishs)):
|
for i in np.arange(len(efishs)):
|
||||||
log.debug(f"Appending efish traces {efishs[i]}")
|
log.debug(f"Appending efish traces {efishs[i]}")
|
||||||
|
Loading…
Reference in New Issue
Block a user