Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uhd geometry #38

Merged
merged 9 commits into from
Aug 29, 2024
Merged
18 changes: 14 additions & 4 deletions src/neuropixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any
import warnings
import traceback
import numbers

import scipy.signal
import numpy as np
Expand Down Expand Up @@ -60,7 +61,11 @@
NC = 384
SITES_COORDINATES: np.array
# channel layouts for neuropixel probes as a function of the major version (1 or 2)
CHANNEL_GRID = {1: dict(DX=16, X0=11, DY=20, Y0=20), 2: dict(DX=32, X0=27, DY=15, Y0=20)}
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)
}


def _deprecated_sites_coordinates() -> np.array:
Expand Down Expand Up @@ -97,7 +102,8 @@ def xy2rc(x, y, version=1):
:param version: neuropixel major version 1 or 2
:return: dictionary with keys x and y
"""
grid = CHANNEL_GRID[np.floor(version)]
version = np.floor(version) if isinstance(version, numbers.Number) else version
grid = CHANNEL_GRID[version]
col = (x - grid['X0']) / grid['DX']
row = (y - grid['Y0']) / grid['DY']
return {"col": col, "row": row}
Expand All @@ -111,7 +117,8 @@ def rc2xy(row, col, version=1):
:param version: neuropixel major version 1 or 2
:return: dictionary with keys x and y
"""
grid = CHANNEL_GRID[np.floor(version)]
version = np.floor(version) if isinstance(version, numbers.Number) else version
grid = CHANNEL_GRID[version]
x = col * grid['DX'] + grid['X0']
y = row * grid['DY'] + grid['Y0']
return {"x": x, "y": y}
Expand All @@ -131,6 +138,9 @@ 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
ch.update({"row": np.floor(np.arange(NC) / 8)})
ch.update({"col": np.tile(np.arange(8), int(NC / 8))})
elif (
np.floor(version) == 2 and nshank == 1
): # single shank NP1 has 2 columns in a dense patter
Expand Down Expand Up @@ -189,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:
if version == 1 or version == "uhd":
adc_channels = 12
n_cycles = 13
# version 1 uses 32 ADC that sample 12 channels each
Expand Down
Loading