--- title: Differences between sample rates format: html: toc: true toc-title: Contents code-block-bg: true code-block-border-left: "#31BAE9" code-line-numbers: true highlight-style: atom-one link-external-icon: true link-external-newwindow: true eqn-number: true --- ### 1. General Idea The two aquisition systems have a different default sampling rate and currently there is a delay and maybe this is due to the different sampling rates. `open-ephys` has a sample-rate of 30 kHz and `relacs` one of 20 kHz. In this test we have two different recordings with one where the open-epyhs has 30 kHz and the other with 20 kHz. ### 2. Loading the data ```{python} from pathlib import Path import rlxnix as rlx import plotly.graph_objects as go from plotly.subplots import make_subplots import scipy.signal as signal import numpy as np # Path to test recording with different samplerate open-epyhs 30kHz and relacs 20kHz dataset_path_diff_fs = Path("../oephys2nix/test/Test1/2025-10-08-aa-invivo-2-recording.nix") relacs_path_diff_fs = Path("../oephys2nix/test/Test1/2025-10-08-aa-invivo-2_relacs/2025-10-08-aa-invivo-2.nix") # Path to test recording with same samplerate open-epyhs 20kHz and relacs 20kHz dataset_path_same_fs = Path("../oephys2nix/test/Test2/2025-10-08-ab-invivo-2-recording.nix") relacs_path_same_fs = Path("../oephys2nix/test/Test2/2025-10-08-ab-invivo-2_relacs/2025-10-08-ab-invivo-2.nix") dataset_diff_fs = rlx.Dataset(str(dataset_path_diff_fs)) relacs_diff_fs = rlx.Dataset(str(relacs_path_diff_fs)) dataset_same_fs = rlx.Dataset(str(dataset_path_same_fs)) relacs_same_fs = rlx.Dataset(str(relacs_path_same_fs)) repro_diff_fs_d = dataset_diff_fs.repro_runs("FileStimulus_1")[0].stimuli[2] repro_diff_fs_r = relacs_diff_fs.repro_runs("FileStimulus_1")[0].stimuli[2] repro_same_fs_d = dataset_same_fs.repro_runs("FileStimulus_1")[0].stimuli[2] repro_same_fs_r = relacs_same_fs.repro_runs("FileStimulus_1")[0].stimuli[2] #sinus, t = repro_diff_fs_d.trace_data("sinus") #sinus_r, t_r = repro_diff_fs_r.trace_data("V-1") stimulus_diff_oe, t_diff = repro_diff_fs_d.trace_data("stimulus") stimulus_diff_re, t_diff_r = repro_diff_fs_r.trace_data("GlobalEFieldStimulus") stimulus_same_oe, t_same = repro_same_fs_d.trace_data("stimulus") stimulus_same_re, t_same_r = repro_same_fs_r.trace_data("GlobalEFieldStimulus") ``` ### 3. Samples in the different recordings for one stimulus ```{python} #| echo: False print(f"Samples open-epyhs [30 kHz] for one trial: {stimulus_diff_oe.shape}") print(f"Samples relacs for one trial: {stimulus_diff_re.shape}") print(f"Samples open-epyhs [20 kHz] for one trial: {stimulus_same_oe.shape}") print(f"Samples relacs for one trial: {stimulus_same_re.shape}") ``` ### 4. Plotting first trial Here we plot the different output stimulus, different sample rates ```{python} #| echo: False x_lim = 0.05 fig = make_subplots( rows=2, cols=1, shared_xaxes=True, subplot_titles=("Different fs [30 khz and 20 kHz]", "Same fs [20kHz]")) fig.add_trace( go.Scattergl(x=t_diff_r[t_diff_r