Skip to content

Commit

Permalink
npultra sample meta file
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-langfield committed Aug 29, 2024
1 parent 75bca65 commit 9daf9cc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/neuropixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}


Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/spikeglx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions src/tests/unit/cpu/test_neuropixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])


Expand Down Expand Up @@ -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])
17 changes: 17 additions & 0 deletions src/tests/unit/cpu/test_spikeglx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 9daf9cc

Please sign in to comment.