[doc] adding calibration doc
This commit is contained in:
parent
ccc563ce55
commit
764ee40b43
122
doc/calibration.qmd
Normal file
122
doc/calibration.qmd
Normal file
@ -0,0 +1,122 @@
|
||||
---
|
||||
title: Calibration
|
||||
---
|
||||
|
||||
### Calibration of the Amplitude
|
||||
```{python}
|
||||
import rlxnix as rlx
|
||||
import plotly.graph_objects as go
|
||||
import numpy as np
|
||||
from plotly.subplots import make_subplots
|
||||
|
||||
|
||||
dataset = rlx.Dataset("../oephys2nix/test/Test1/2025-10-08-aa-invivo-2-recording.nix")
|
||||
relacs = rlx.Dataset("../oephys2nix/test/Test1/2025-10-08-aa-invivo-2_relacs/2025-10-08-aa-invivo-2.nix")
|
||||
repro_d = dataset.repro_runs("CalibEfield_1")[0]
|
||||
repro_r = relacs.repro_runs("CalibEfield_1")[0]
|
||||
|
||||
fig = make_subplots(
|
||||
rows=4,
|
||||
cols=1,
|
||||
shared_xaxes=True,
|
||||
subplot_titles=(
|
||||
"Stimulus Comparison",
|
||||
"Local EOD Comparison",
|
||||
"Global EOD Comparison",
|
||||
"Sinus Comparison",
|
||||
),)
|
||||
|
||||
|
||||
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")
|
||||
|
||||
ttl, t = repro_d.trace_data("ttl-line")
|
||||
# 2. Add traces to the FIRST subplot (row=1, col=1)
|
||||
# Note: Plotly rows and columns are 1-indexed
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t_r, y=stimulus_re, name="stimulus (relacs)", line_color="blue"),
|
||||
row=1,
|
||||
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=1,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t, y=ttl, name="ttl-line", line_color="black"),
|
||||
row=1,
|
||||
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=2,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t, y=local_eod_oe, name="local EOD (open-ephys)", line_color="red"),
|
||||
row=2,
|
||||
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=3,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(
|
||||
x=t, y=global_eod_oe, name="global EOD (open-ephys)", line_color="red"
|
||||
),
|
||||
row=3,
|
||||
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=4,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t, y=sinus, name="sinus (open-ephys)", line_color="red"),
|
||||
row=4,
|
||||
col=1,
|
||||
)
|
||||
|
||||
|
||||
# 6. Update the layout for a cleaner look
|
||||
fig.update_layout(
|
||||
title_text="Relacs vs. Open Ephys Data Alignment",
|
||||
height=800, # Set the figure height in pixels
|
||||
# Control the legend
|
||||
legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
|
||||
)
|
||||
# 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.show()
|
||||
```
|
||||
Loading…
Reference in New Issue
Block a user