[doc] calibration moving plotting to util
This commit is contained in:
parent
de42eba704
commit
365e309ce7
@ -26,6 +26,8 @@ import numpy as np
|
||||
import scipy.signal as signal
|
||||
from plotly.subplots import make_subplots
|
||||
|
||||
from util import trial_plot, plot_line_comparision
|
||||
|
||||
|
||||
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")
|
||||
@ -56,91 +58,7 @@ If you zoom in you can see a little delay between the different recording system
|
||||
|
||||
```{python}
|
||||
#| echo: False
|
||||
# 2. Add traces to the FIRST subplot (row=1, col=1)
|
||||
# Note: Plotly rows and columns are 1-indexed
|
||||
fig = make_subplots( rows=5, cols=1, shared_xaxes=True, subplot_titles=("TTL-Line",
|
||||
"Stimulus Comparison", "Local EOD Comparison", "Global EOD Comparison",
|
||||
"Sinus Comparison"))
|
||||
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t, y=ttl, name="ttl-line", line_color="magenta"),
|
||||
row=1,
|
||||
col=1,
|
||||
)
|
||||
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t_r, y=stimulus_re, name="stimulus (relacs)", line_color="blue"),
|
||||
row=2,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(
|
||||
x=t,
|
||||
y=stimulus_oe - np.mean(stimulus_oe), # The same data transformation
|
||||
name="stimulus (open-ephys)",
|
||||
line_color="red",
|
||||
),
|
||||
row=2,
|
||||
col=1,
|
||||
)
|
||||
|
||||
|
||||
# 3. Add traces to the SECOND subplot (row=2, col=1)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t_r, y=local_eod_re, name="local EOD (relacs)", line_color="blue"),
|
||||
row=3,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t, y=local_eod_oe, name="local EOD (open-ephys)", line_color="red"),
|
||||
row=3,
|
||||
col=1,
|
||||
)
|
||||
|
||||
|
||||
# 4. Add traces to the THIRD subplot (row=3, col=1)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t_r, y=global_eod_re, name="global EOD (relacs)", line_color="blue"),
|
||||
row=4,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(
|
||||
x=t, y=global_eod_oe, name="global EOD (open-ephys)", line_color="red"
|
||||
),
|
||||
row=4,
|
||||
col=1,
|
||||
)
|
||||
|
||||
# 5. Add traces to the FOURTH subplot (row=4, col=1)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t_r, y=sinus_r, name="sinus (relacs)", line_color="blue"),
|
||||
row=5,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t, y=sinus, name="sinus (open-ephys)", line_color="red"),
|
||||
row=5,
|
||||
col=1,
|
||||
)
|
||||
|
||||
# 6. Update the layout for a cleaner look
|
||||
fig.update_layout(
|
||||
template="plotly_dark",
|
||||
height=800, # Set the figure height in pixels
|
||||
# Control the legend
|
||||
#legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
|
||||
legend=dict(
|
||||
bgcolor="rgba(0,0,0,0)", # transparent dark (or use "#1f2630" to match bg)
|
||||
bordercolor="#444",
|
||||
borderwidth=0,
|
||||
font=dict(color="#e5ecf6") # matches plotly_dark foreground
|
||||
)
|
||||
)
|
||||
# Add a label to the shared x-axis (targeting the last subplot)
|
||||
fig.update_xaxes(title_text="Time (s)", row=4, col=1)
|
||||
|
||||
# 7. Show the figure
|
||||
fig = trial_plot(repro_d, repro_r)
|
||||
fig.show()
|
||||
```
|
||||
### Correlation between the Signals
|
||||
@ -155,22 +73,8 @@ sinus_resampled = signal.resample(sinus, len(sinus_r))
|
||||
|
||||
```{python}
|
||||
#| echo: False
|
||||
fig = go.Figure()
|
||||
fig.add_trace( go.Scatter(x=t_r, y=sinus_r, name="sinus (relacs)", line_color="blue", mode="lines+markers"))
|
||||
fig.add_trace( go.Scatter(x=t_r, y=sinus_resampled, name="sinus-resampled (open-ephys)", line_color="red", mode="lines+markers"))
|
||||
fig.update_layout(
|
||||
template="plotly_dark",
|
||||
height=500, # Set the figure height in pixels
|
||||
# Control the legend
|
||||
#legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
|
||||
legend=dict(
|
||||
bgcolor="rgba(0,0,0,0)", # transparent dark (or use "#1f2630" to match bg)
|
||||
bordercolor="#444",
|
||||
borderwidth=0,
|
||||
font=dict(color="#e5ecf6") # matches plotly_dark foreground
|
||||
)
|
||||
)
|
||||
fig.update_xaxes(range=[0, 0.01])
|
||||
fig = plot_line_comparision(t_r, t, sinus_r, sinus, ["sinus-relacs", "sinus-oephys"])
|
||||
fig.show()
|
||||
```
|
||||
We need to scale the two signals
|
||||
|
||||
@ -192,21 +96,6 @@ for oephys_lane, relacs_lane, names_lane in zip(oephys_lanes, relacs_lanes, name
|
||||
|
||||
```{python}
|
||||
#| echo: False
|
||||
fig = go.Figure()
|
||||
fig.add_trace( go.Scatter(x=t_r, y=sinus_r, name="sinus (relacs)", line_color="blue", mode="lines+markers"))
|
||||
fig.add_trace( go.Scatter(x=t_r, y=np.roll(sinus_resampled, -lags_lanes[0]), name="sinus-resampled (open-ephys)", line_color="red", mode="lines+markers"))
|
||||
fig.update_layout(
|
||||
title="Sinus",
|
||||
template="plotly_dark",
|
||||
height=500, # Set the figure height in pixels
|
||||
# Control the legend
|
||||
#legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
|
||||
legend=dict(
|
||||
bgcolor="rgba(0,0,0,0)", # transparent dark (or use "#1f2630" to match bg)
|
||||
bordercolor="#444",
|
||||
borderwidth=0,
|
||||
font=dict(color="#e5ecf6") # matches plotly_dark foreground
|
||||
)
|
||||
)
|
||||
fig.update_xaxes(range=[0, 0.01])
|
||||
fig = plot_line_comparision(t_r, t_r, np.roll(sinus_r, lags_lanes[0]),sinus_resampled, ["sinus-relacs", "sinus-resampled-openepyhs"])
|
||||
fig.show()
|
||||
```
|
||||
|
||||
Loading…
Reference in New Issue
Block a user