Skip to content

probe_geometry.py

NXT3000 = [1, 70, 0, 53, 53, 0, 15, 128, 128] module-attribute

Electrode coordinate system - from Bill Karsh (https://github.com/billkarsh/SpikeGLX/blob/master/Markdown/Metadata_30.md)

The X-origin is the left edge of the shank The Y-origin is the center of the bottom-most elecrode row (closest to the tip)

build_electrode_layouts(probe_type, site_count_per_shank, col_spacing=None, row_spacing=None, row_offset=None, col_count_per_shank=1, shank_count=1, shank_spacing=None, y_origin='bottom', as_dataframe=False)

Builds electrode layouts.

Parameters:

Name Type Description Default
probe_type str

probe type (e.g., "neuropixels 1.0 - 3A").

required
site_count_per_shank int

site count per shank.

required
col_spacing float

(um) horizontal spacing between sites. Defaults to None (single column).

None
row_spacing float

(um) vertical spacing between columns. Defaults to None (single row).

None
row_offset list

(um) per-row offset spacing. Defaults to None.

None
col_count_per_shank int

number of column per shank. Defaults to 1 (single column).

1
shank_count int

number of shank. Defaults to 1 (single shank).

1
shank_spacing float

(um) spacing between shanks. Defaults to None (single shank).

None
y_origin str

{"bottom", "top"}. y value decrements if "top". Defaults to "bottom".

'bottom'
as_dataframe bool

if True, returns as pandas DataFrame, otherwise as list of dict

False
Source code in element_array_ephys/readers/probe_geometry.py
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
def build_electrode_layouts(
    probe_type: str,
    site_count_per_shank: int,
    col_spacing: float = None,
    row_spacing: float = None,
    row_offset: list = None,
    col_count_per_shank: int = 1,
    shank_count: int = 1,
    shank_spacing: float = None,
    y_origin="bottom",
    as_dataframe=False,
) -> list[dict]:
    """Builds electrode layouts.

    Args:
        probe_type (str): probe type (e.g., "neuropixels 1.0 - 3A").
        site_count_per_shank (int): site count per shank.
        col_spacing (float): (um) horizontal spacing between sites. Defaults to None (single column).
        row_spacing (float): (um) vertical spacing between columns. Defaults to None (single row).
        row_offset (list): (um) per-row offset spacing. Defaults to None.
        col_count_per_shank (int): number of column per shank. Defaults to 1 (single column).
        shank_count (int): number of shank. Defaults to 1 (single shank).
        shank_spacing (float): (um) spacing between shanks. Defaults to None (single shank).
        y_origin (str): {"bottom", "top"}. y value decrements if "top". Defaults to "bottom".
        as_dataframe (bool): if True, returns as pandas DataFrame, otherwise as list of dict
    """
    row_count = int(site_count_per_shank / col_count_per_shank)
    x_coords = np.tile(
        np.arange(0, (col_spacing or 1) * col_count_per_shank, (col_spacing or 1)),
        row_count,
    )
    y_coords = np.repeat(np.arange(row_count) * (row_spacing or 1), col_count_per_shank)

    if row_offset is None:
        row_offset = np.zeros_like(x_coords)
    else:
        assert len(row_offset) == row_count
        row_offset = np.tile(row_offset, col_count_per_shank)
    x_coords = x_coords + row_offset

    shank_cols = np.tile(range(col_count_per_shank), row_count)
    shank_rows = np.repeat(range(row_count), col_count_per_shank)

    electrode_layout = [
        {
            "probe_type": probe_type,
            "electrode": (site_count_per_shank * shank_no) + e_id,
            "shank": shank_no,
            "shank_col": c_id,
            "shank_row": r_id,
            "x_coord": x + (shank_no * (shank_spacing or 1)),
            "y_coord": {"top": -y, "bottom": y}[y_origin],
        }
        for shank_no in range(shank_count)
        for e_id, (c_id, r_id, x, y) in enumerate(
            zip(shank_cols, shank_rows, x_coords, y_coords)
        )
    ]

    return pd.DataFrame(electrode_layout) if as_dataframe else electrode_layout