[doc] adding calc lag
This commit is contained in:
parent
ce1fe10050
commit
6dd148656b
31
doc/util.py
31
doc/util.py
@ -1,5 +1,6 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import plotly.graph_objects as go
|
import plotly.graph_objects as go
|
||||||
|
import scipy.signal as signal
|
||||||
from plotly.subplots import make_subplots
|
from plotly.subplots import make_subplots
|
||||||
|
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ def trial_plot(repro_d, repro_r, x_lim: int = 1.0):
|
|||||||
)
|
)
|
||||||
# Add a label to the shared x-axis (targeting the last subplot)
|
# Add a label to the shared x-axis (targeting the last subplot)
|
||||||
fig.update_xaxes(title_text="Time (s)", row=4, col=1)
|
fig.update_xaxes(title_text="Time (s)", row=4, col=1)
|
||||||
fig.update_xaxes(range=[0, 0.5])
|
fig.update_xaxes(range=[0, x_lim])
|
||||||
|
|
||||||
return fig
|
return fig
|
||||||
|
|
||||||
@ -178,5 +179,31 @@ def plot_line_comparision(
|
|||||||
x=0.72,
|
x=0.72,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
fig.update_xaxes(range=[0, 0.01])
|
fig.update_xaxes(title_text="Time (s)", range=[0, 0.01])
|
||||||
return fig
|
return fig
|
||||||
|
|
||||||
|
|
||||||
|
def calc_lag(repro_d, repro_r):
|
||||||
|
sinus, t = repro_d.trace_data("sinus")
|
||||||
|
sinus_r, t_r = repro_r.trace_data("V-1")
|
||||||
|
|
||||||
|
stimulus_oe, t = repro_d.trace_data("stimulus")
|
||||||
|
stimulus_re, t_r = repro_r.trace_data("GlobalEFieldStimulus")
|
||||||
|
|
||||||
|
local_eod_oe, t = repro_d.trace_data("local-eod")
|
||||||
|
local_eod_re, t_r = repro_r.trace_data("LocalEOD-1")
|
||||||
|
|
||||||
|
global_eod_oe, t = repro_d.trace_data("global-eod")
|
||||||
|
global_eod_re, t_r = repro_r.trace_data("EOD")
|
||||||
|
|
||||||
|
oephys_lanes = [sinus, local_eod_oe, global_eod_oe, stimulus_oe]
|
||||||
|
relacs_lanes = [sinus_r, local_eod_re, global_eod_re, stimulus_re]
|
||||||
|
lags_lanes = []
|
||||||
|
for oephys_lane, relacs_lane in zip(oephys_lanes, relacs_lanes, strict=True):
|
||||||
|
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)
|
||||||
|
|
||||||
|
return lags_lanes
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user