[formatting]

This commit is contained in:
wendtalexander 2025-10-21 11:54:11 +02:00
parent 335a83414b
commit 3da1a323c2

View File

@ -20,22 +20,22 @@ Lets look at the calibration and the first trial of the recording.
import pathlib
import rlxnix as rlx
import plotly.graph_objects as go
import numpy as np
import plotly.graph_objects as go
import rlxnix as rlx
import scipy.signal as signal
from plotly.subplots import make_subplots
from util import trial_plot, plot_line_comparision
from util import plot_line_comparision, trial_plot
dataset_path = pathlib.Path("../oephys2nix/test/Test1/2025-10-08-aa-invivo-2-recording.nix")
relacs_path = pathlib.Path("../oephys2nix/test/Test1/2025-10-08-aa-invivo-2_relacs/2025-10-08-aa-invivo-2.nix")
relacs_path = pathlib.Path(
"../oephys2nix/test/Test1/2025-10-08-aa-invivo-2_relacs/2025-10-08-aa-invivo-2.nix"
)
dataset = rlx.Dataset(str(dataset_path))
relacs = rlx.Dataset(str(relacs_path))
#INFO: Select the first stimulus of the calibration repro
# INFO: Select the first stimulus of the calibration repro
repro_d = dataset.repro_runs("CalibEfield_1")[0].stimuli[2]
repro_r = relacs.repro_runs("CalibEfield_1")[0].stimuli[2]
@ -57,7 +57,7 @@ ttl, t = repro_d.trace_data("ttl-line")
If you zoom in you can see a little delay between the different recording systems. It seems that open-ephys is before the relacs recording.
```{python}
#| echo: False
# | echo: False
fig = trial_plot(repro_d, repro_r)
fig.show()
```
@ -68,11 +68,10 @@ print(f"Duration of the dataset {repro_d.duration}")
print(f"Duration of the relacs {repro_r.duration}")
# Resample the open-ephys data
sinus_resampled = signal.resample(sinus, len(sinus_r))
```
```{python}
#| echo: False
# | echo: False
fig = plot_line_comparision(t_r, t, sinus_r, sinus, ["sinus-relacs", "sinus-oephys"])
fig.show()
```
@ -83,19 +82,27 @@ oephys_lanes = [sinus, local_eod_oe, global_eod_oe, stimulus_oe]
relacs_lanes = [sinus_r, local_eod_re, global_eod_re, stimulus_re]
names_lanes = ["sinus", "local-eod", "global-eod", "stimulus"]
lags_lanes = []
for oephys_lane, relacs_lane, names_lane in zip(oephys_lanes, relacs_lanes, names_lanes, strict=True):
print(oephys_lane.shape)
print(relacs_lane.shape)
oephys_lane_resampled = signal.resample(oephys_lane, len(relacs_lane))
correlation = signal.correlate(oephys_lane_resampled, relacs_lane, mode="full")
lags = signal.correlation_lags(oephys_lane_resampled.size, relacs_lane.size, mode="full")
lag = lags[np.argmax(correlation)]
lags_lanes.append(lag)
print(f"{names_lane} has a lag of {lag}")
for oephys_lane, relacs_lane, names_lane in zip(
oephys_lanes, relacs_lanes, names_lanes, strict=True
):
print(oephys_lane.shape)
print(relacs_lane.shape)
oephys_lane_resampled = signal.resample(oephys_lane, len(relacs_lane))
correlation = signal.correlate(oephys_lane_resampled, relacs_lane, mode="full")
lags = signal.correlation_lags(oephys_lane_resampled.size, relacs_lane.size, mode="full")
lag = lags[np.argmax(correlation)]
lags_lanes.append(lag)
print(f"{names_lane} has a lag of {lag}")
```
```{python}
#| echo: False
fig = plot_line_comparision(t_r, t_r, np.roll(sinus_r, lags_lanes[0]),sinus_resampled, ["sinus-relacs", "sinus-resampled-openepyhs"])
# | echo: False
fig = plot_line_comparision(
t_r,
t_r,
np.roll(sinus_r, lags_lanes[0]),
sinus_resampled,
["sinus-relacs", "sinus-resampled-openepyhs"],
)
fig.show()
```