Skip to content

Commit

Permalink
add test on the sync timestamps linear option
Browse files Browse the repository at this point in the history
  • Loading branch information
oliche committed Jun 21, 2024
1 parent 6de88f0 commit 07d5c09
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="ibl-neuropixel",
version="1.1.0a",
version="1.1.0a01",
author="The International Brain Laboratory",
description="Collection of tools for Neuropixel 1.0 and 2.0 probes data",
long_description=long_description,
Expand Down
2 changes: 1 addition & 1 deletion src/ibldsp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _interp_fcn(tsa, tsb, ib, linear=linear):
ab = np.polyfit(tsa[ib >= 0], tsb[ib[ib >= 0]] - tsa[ib >= 0], 1)
drift_ppm = ab[0] * 1e6
if linear:
fcn_a2b = lambda x: x * ab[0] + ab[1] # noqa
fcn_a2b = lambda x: x * (1 + ab[0]) + ab[1] # noqa
else:
fcn_a2b = scipy.interpolate.interp1d(
tsa[ib >= 0], tsb[ib[ib >= 0]], fill_value="extrapolate"
Expand Down
10 changes: 9 additions & 1 deletion src/tests/unit/cpu/test_ibldsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@


class TestSyncTimestamps(unittest.TestCase):
def test_timestamps_lin(self):

def test_sync_timestamps_linear(self):
ta = np.cumsum(np.abs(np.random.randn(100))) * 10
tb = ta * 1.0001 + 100
fcn, drif, ia, ib = utils.sync_timestamps(ta, tb, return_indices=True, linear=True)
np.testing.assert_almost_equal(drif, 100)
np.testing.assert_almost_equal(tb, fcn(ta))

def test_timestamps(self):
np.random.seed(4132)
n = 50
drift = 17.14
Expand Down

0 comments on commit 07d5c09

Please sign in to comment.