From 9daf9ccab2a4e0aa7143b52c483f2d6b171b79ec Mon Sep 17 00:00:00 2001 From: Christopher Langfield Date: Wed, 28 Aug 2024 18:41:14 -0700 Subject: [PATCH] npultra sample meta file --- src/neuropixel.py | 6 +++--- src/spikeglx.py | 2 +- src/tests/unit/cpu/test_neuropixel.py | 4 ++-- src/tests/unit/cpu/test_spikeglx.py | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/neuropixel.py b/src/neuropixel.py index 1d0af16..6cb2b0a 100644 --- a/src/neuropixel.py +++ b/src/neuropixel.py @@ -64,7 +64,7 @@ CHANNEL_GRID = { 1: dict(DX=16, X0=11, DY=20, Y0=20), 2: dict(DX=32, X0=27, DY=15, Y0=20), - "uhd": dict(DX=6, X0=0, DY=6, Y0=0) + "NPultra": dict(DX=6, X0=0, DY=6, Y0=0) } @@ -138,7 +138,7 @@ def dense_layout(version=1, nshank=1): if version == 1: # version 1 has a dense layout, checkerboard pattern ch.update({"col": np.tile(np.array([2, 0, 3, 1]), int(NC / 4))}) - elif version == "uhd": # UHD has 8 columns with square grid spacing + elif version == "NPultra": # NPultra has 8 columns with square grid spacing ch.update({"row": np.floor(np.arange(NC) / 8)}) ch.update({"col": np.tile(np.arange(8), int(NC / 8))}) elif ( @@ -199,7 +199,7 @@ def adc_shifts(version=1, nc=NC): :param version: neuropixel major version 1 or 2 :param nc: number of channels """ - if version == 1 or version == "uhd": + if version == 1 or version == "NPultra": adc_channels = 12 n_cycles = 13 # version 1 uses 32 ADC that sample 12 channels each diff --git a/src/spikeglx.py b/src/spikeglx.py index 6417bbb..f6a3c55 100644 --- a/src/spikeglx.py +++ b/src/spikeglx.py @@ -518,7 +518,7 @@ def _get_serial_number_from_meta(md): def _get_neuropixel_major_version_from_meta(md): - MAJOR_VERSION = {"3A": 1, "3B2": 1, "3B1": 1, "NP2.1": 2, "NP2.4": 2.4} + MAJOR_VERSION = {"3A": 1, "3B2": 1, "3B1": 1, "NP2.1": 2, "NP2.4": 2.4, "NPultra": "NPultra"} version = _get_neuropixel_version_from_meta(md) if version is not None: return MAJOR_VERSION[version] diff --git a/src/tests/unit/cpu/test_neuropixel.py b/src/tests/unit/cpu/test_neuropixel.py index e76cb1c..8043ad0 100644 --- a/src/tests/unit/cpu/test_neuropixel.py +++ b/src/tests/unit/cpu/test_neuropixel.py @@ -16,7 +16,7 @@ def test_adc_shifts(): np.testing.assert_equal(h24["sample_shift"], h21["sample_shift"]) np.testing.assert_equal(np.unique(h21["sample_shift"] * 16), np.arange(16)) # test ADC shifts uhd - hUHD = neuropixel.trace_header(version="uhd") + hUHD = neuropixel.trace_header(version="NPultra") np.testing.assert_equal(hUHD["sample_shift"], h1["sample_shift"]) @@ -82,6 +82,6 @@ def test_geom_npultra(): y=np.repeat(np.arange(0, 288, 6), 8) ) - h = neuropixel.trace_header("uhd") + h = neuropixel.trace_header("NPultra") for k, v in gt.items(): np.testing.assert_equal(v, h[k]) diff --git a/src/tests/unit/cpu/test_spikeglx.py b/src/tests/unit/cpu/test_spikeglx.py index cdcff66..99b7de7 100644 --- a/src/tests/unit/cpu/test_spikeglx.py +++ b/src/tests/unit/cpu/test_spikeglx.py @@ -404,6 +404,17 @@ def test_read_NP24(self): ) self.assert_read_glx(bin_3b) + def test_read_NPultra(self): + with tempfile.TemporaryDirectory(prefix="glx_test") as tdir: + bin_3b = spikeglx._mock_spikeglx_file( + Path(tdir).joinpath("sampleNPultra_g0_t0.imec0.ap.bin"), + self.workdir / "sampleNPultra_g0_t0.imec0.ap.meta", + ns=32, + nc=385, + sync_depth=16, + ) + self.assert_read_glx(bin_3b) + def test_check_ephys_file(self): self.tdir = tempfile.TemporaryDirectory(prefix="glx_test") self.addCleanup(self.tdir.cleanup) @@ -517,6 +528,12 @@ def testGetRevisionAndType(self): self.assertTrue(len(md.keys()) >= 37) if meta_data_file.name.split(".")[-2] in ["lf", "ap"]: + # NPultra: non-numerical + if "NPultra" in meta_data_file.name: + self.assertEqual("NPultra", spikeglx._get_neuropixel_version_from_meta(md)) + self.assertEqual("NPultra", spikeglx._get_neuropixel_major_version_from_meta(md)) + continue + # for ap and lf look for version number # test getting revision revision = meta_data_file.name[6:8]