neurocarto.probe_npx.plot

neurocarto.probe_npx.plot.channel_coordinate(shank_map, electrode_unit='cr', include_unused=False)

Get coordinate of all channels.

Parameters:
  • shank_map (ChannelMap)

  • electrode_unit (ELECTRODE_UNIT) – ‘xy’=(X,Y), ‘cr’=(S,C,R)

  • include_unused – including disconnected channels

Returns:

Array[um:float, E, (S, C, R)|(X, Y)]. NaN if electrode is missing.

Return type:

NDArray[np.float64]

neurocarto.probe_npx.plot.electrode_coordinate(probe_type, electrode_unit='cr')

Get coordinate of all electrodes.

Parameters:
  • probe_type (int | str | ChannelMap | ProbeType)

  • electrode_unit (ELECTRODE_UNIT) – ‘xy’=(X,Y), ‘cr’=(S,C,R)

Returns:

Array[um:int, E, (S, C, R)|(X, Y)]

Return type:

NDArray[np.int_]

neurocarto.probe_npx.plot.plot_probe_shape(ax, probe, height=10, shank_list=None, color='k', label_axis=False, shank_width_scale=1, **kwargs)

Plot the probe shape.

Parameters:
  • ax (Axes)

  • probe (int | str | ChannelMap | ProbeType) – probe type, see {cast_probe_type()}

  • height (float) – max height (mm) of probe need to plot

  • shank_list (list[int] | None) – show shank in order

  • color (str | None) – probe color

  • label_axis – add labels on axes

  • shank_width_scale (float) – scaling the width of a shank for visualizing purpose.

  • kwargs – pass to ax.plot(kwargs)

neurocarto.probe_npx.plot.plot_channelmap_block(ax, chmap, height=10, selection='channel', shank_list=None, shank_width_scale=1, fill=True, **kwargs)

Plot channel in rectangles.

Parameters:
  • ax (Axes)

  • chmap (ChannelMap) – channelmap instance

  • height (float) – max height (mm) of probe need to plot

  • selection (Literal['used', 'unused', 'channel', 'disconnected', 'electrode']) – electrode selection

  • shank_list (list[int] | None) – show shank in order

  • shank_width_scale (float) – scaling the width of a shank for visualizing purpose.

  • fill – fill rectangle

  • kwargs – pass to Rectangle(kwargs)

neurocarto.probe_npx.plot.plot_channelmap_grid(ax, chmap, height=10, shank_list=None, unused=True, half_as_full=False, color='g', **kwargs)

Plot a channel map in grid block style.

Parameters:
  • ax (Axes)

  • chmap (ChannelMap) – channelmap instance

  • height (float) – max height (mm) of probe need to plot

  • shank_list (list[int] | None) – show shank in list

  • unused – show disconnected channels

  • half_as_full – make unused electrode which over half of surrounding electrode are read-out channels as a channel.

  • color (str)

  • kwargs – pass to ax.plot(kwargs)

neurocarto.probe_npx.plot.plot_channelmap_matrix(ax, chmap, data, *, shank_list=None, kernel=None, cmap='magma', shank_gap_color='w', **kwargs)

Plot channel value.

Parameters:
  • ax (Axes)

  • chmap (ChannelMap) – channelmap instance

  • data (ndarray[tuple[int, ...], dtype[float64]]) – Array[V:float, C] or Array[float, C’, (C, V)]

  • shank_list (list[int] | None) – show shank in order

  • kernel (int | tuple[int, int] | Callable[[ndarray[tuple[int, ...], dtype[float64]]], ndarray[tuple[int, ...], dtype[float64]]] | None) – interpolate missing data (NaN) between channels. It is pass to interpolate_nan(). Default is (0, 1) on row-axis.

  • cmap – colormap used in ax.imshow(cmap)

  • shank_gap_color (str | None)

  • kwargs – pass to ax.imshow(kwargs)

Return type:

_ScalarMappable

neurocarto.probe_npx.plot.plot_electrode_block(ax, probe, electrode, electrode_unit='cr', *, height=10, shank_list=None, shank_width_scale=1, sparse=True, fill=True, cmap=None, **kwargs)

Plot electrodes in rectangles per electrodes or per shanks.

Data shape and units

the required shape of electrode is depended on electrode_unit.

  • cr: column and row, require shape Array[float, N, (S, C, R)]

  • crv: column and row, require shape Array[float, N, (S, C, R, V)]

  • xy: x and y position, require shape Array[float, N, (X, Y)]

  • xyv: x and y position, require shape Array[float, N, (X, Y, V)]

  • raw: require shape Array[V:float, E] or Array[V:float, S, C, R],

where E=S*C*R means all electrodes for the probe.

Parameters:
  • probe (int | str | ChannelMap | ProbeType) – any probe type identify.

  • electrode (ndarray[tuple[int, ...], dtype[float64]]) – electrode data array

  • electrode_unit (Literal['cr', 'xy', 'raw', 'crv', 'xyv']) – electrode ordering kind

  • ax (Axes)

  • probe – probe type, see cast_probe_type()

  • electrode – electrode data

  • electrode_unit – electrode value unit

  • sparse – If sparse, plot data block as rectangles (ignore V). use an image otherwise.

  • height (float | None) – max height (mm) of probe need to plot

  • shank_list (list[int] | None) – show shank in order

  • shank_width_scale (float) – scaling the width of a shank for visualizing purpose.

  • fill – fill rectangle

  • cmap (str | None) – colormap used by ax.imshow(kwargs).

  • kwargs – pass to Rectangle(kwargs) or ax.imshow(kwargs).

Returns:

Array[float, E, (S, C, R)] or Array[float, E, (S, C, R, V)]

neurocarto.probe_npx.plot.plot_electrode_grid(ax, probe, electrode, electrode_unit='cr', *, shank_list=None, height=10, shank_width_scale=1, color='g', label=None, transform=None, **kwargs)

Plot each electrode in grid rectangles.

Parameters:
  • ax (Axes)

  • probe (int | str | ChannelMap | ProbeType) – probe type, see {cast_probe_type()}

  • electrode (ndarray[tuple[int, ...], dtype[int64]]) – Array[int, E, (S, C, R)|(X, Y)]

  • electrode_unit (Literal['cr', 'xy', 'raw']) – ‘xy’=(X,Y), ‘cr’=(S,C,R)

  • shank_list (list[int] | None) – show shank in list

  • height (float | None) – max height (mm) of probe need to plot

  • shank_width_scale (float) – scaling the width of a shank for visualizing purpose.

  • color (str) – grid line color

  • label (str | None)

  • transform (tuple[float | list[float] | ndarray[tuple[int, ...], dtype[float64]] | None, float | None, float | None] | None) – distance tuple of (shank, column, row). shank distance could be a list of shank coordinates. By default, this method use (x:um, y:um) coordinate system. For another coordinate system, like (S*C:index, y:um) used by {plot_electrode_matrix()}, you can use (np.arange(n_shank) + 0.5, 1, None) to start adjust the value.

  • kwargs – pass to ax.plot(kwargs)

neurocarto.probe_npx.plot.plot_electrode_matrix(ax, probe, electrode, electrode_unit='cr', *, shank_list=None, kernel=None, cmap='magma', shank_gap_color='w', **kwargs)

Plot electrode value.

Data shape and units

the required shape of electrode is depended on electrode_unit.

  • cr: column and row, require shape Array[float, N, (S, C, R)]

  • crv: column and row, require shape Array[float, N, (S, C, R, V)]

  • xy: x and y position, require shape Array[float, N, (X, Y)]

  • xyv: x and y position, require shape Array[float, N, (X, Y, V)]

  • raw: require shape Array[V:float, E] or Array[V:float, S, C, R],

where E=S*C*R means all electrodes for the probe.

Parameters:
  • probe (int | str | ChannelMap | ProbeType) – any probe type identify.

  • electrode (ndarray[tuple[int, ...], dtype[float64]]) – electrode data array

  • electrode_unit (Literal['cr', 'xy', 'raw']) – electrode ordering kind

  • ax (Axes)

  • probe – probe type, see cast_probe_type()

  • electrode – electrode data

  • electrode_unit – electrode value unit

  • shank_list (list[int] | None) – show shank in order

  • kernel (int | tuple[int, int] | Callable[[ndarray[tuple[int, ...], dtype[float64]]], ndarray[tuple[int, ...], dtype[float64]]] | None) – interpolate missing data (NaN) between channels. It is pass to interpolate_nan(). Default is (0, 1) on row-axis.

  • cmap – colormap used in ax.imshow(cmap)

  • shank_gap_color (str | None) – color of shank gao line. Use None to disable plotting.

  • kwargs – pass to ax.imshow(kwargs)

Returns:

Array[float, E, (S, C, R)] or Array[float, E, (S, C, R, V)]

Return type:

_ScalarMappable

neurocarto.probe_npx.plot.plot_electrode_curve(ax, probe, electrode, electrode_unit='cr', *, kernel=None, shank_list=None, height=None, direction='right', vmax=None, normalize=1, shank_width_scale=1, label=None, **kwargs)

Data shape and units

the required shape of electrode is depended on electrode_unit.

  • cr: column and row, require shape Array[float, N, (S, C, R)]

  • crv: column and row, require shape Array[float, N, (S, C, R, V)]

  • xy: x and y position, require shape Array[float, N, (X, Y)]

  • xyv: x and y position, require shape Array[float, N, (X, Y, V)]

  • raw: require shape Array[V:float, E] or Array[V:float, S, C, R],

where E=S*C*R means all electrodes for the probe.

Parameters:
  • probe (int | str | ChannelMap | ProbeType) – any probe type identify.

  • electrode (ndarray[tuple[int, ...], dtype[float64]]) – electrode data array

  • electrode_unit (Literal['cr', 'xy', 'raw']) – electrode ordering kind

  • ax (Axes)

  • probe – probe type, see cast_probe_type()

  • electrode – electrode data

  • electrode_unit – electrode value unit

  • kernel (int | ndarray[tuple[int, ...], dtype[float64]] | Literal['norm'] | None) – smoothing kernel Array[float, Y], where Y use 1-um bins

  • shank_list (list[int] | None) – show shank in order

  • height (float | None) – y limitation of curve.

  • direction (Literal['left', 'right']) – the direction of the position value for the curves

  • vmax (float | None) – max value.

  • normalize (float | None) – normalize the max value to fit into the inter-shank space.

  • shank_width_scale (float) – scaling the width of a shank for visualizing purpose.

  • label (str | None)

  • kwargs – pass to ax.plot(kwargs)

Returns:

Array[float, E, (S, C, R)] or Array[float, E, (S, C, R, V)]

neurocarto.probe_npx.plot.plot_category_area(ax, probe, electrode, *, color=None, **kwargs)

Plot category blocks for a blueprint electrode.

Parameters:
  • ax (Axes)

  • probe (int | str | ChannelMap | ProbeType) – probe type, see cast_probe_type()

  • electrode (ndarray[tuple[int, ...], dtype[int64]] | list[ElectrodeDesp]) – Array[category:int, N], Array[int, N, (S, C, R, category)] or list of ElectrodeDesp

  • color (dict[int, str] | None) – category mapping dictionary

  • kwargs – pass to plot_electrode_block()

neurocarto.probe_npx.plot.cast_electrode_data(probe, electrode, electrode_unit)

Data shape and units

the required shape of electrode is depended on electrode_unit.

  • cr: column and row, require shape Array[float, N, (S, C, R)]

  • crv: column and row, require shape Array[float, N, (S, C, R, V)]

  • xy: x and y position, require shape Array[float, N, (X, Y)]

  • xyv: x and y position, require shape Array[float, N, (X, Y, V)]

  • raw: require shape Array[V:float, E] or Array[V:float, S, C, R],

where E=S*C*R means all electrodes for the probe.

Parameters:
  • probe (int | str | ChannelMap | ProbeType) – any probe type identify.

  • electrode (ndarray[tuple[int, ...], dtype[float64]]) – electrode data array

  • electrode_unit (Literal['cr', 'xy', 'raw', 'crv', 'xyv']) – electrode ordering kind

Returns:

Array[float, E, (S, C, R)] or Array[float, E, (S, C, R, V)]

Return type:

ndarray[tuple[int, …], dtype[float64]]

neurocarto.probe_npx.plot.cast_electrode_grid(data)
Parameters:

data (ndarray) – Array[float, S, C, R] electrode data array

Returns:

v_grid:Array[int, S, C+1, R] and h_grid:Array[int, S, C, R+1]

Return type:

tuple[ndarray, ndarray]

neurocarto.probe_npx.plot.cast_electrode_curve(probe, electrode, electrode_unit='cr', *, kernel=None)

smooth electrode data into 1d value data per shank.

Data shape and units

the required shape of electrode is depended on electrode_unit.

  • cr: column and row, require shape Array[float, N, (S, C, R)]

  • crv: column and row, require shape Array[float, N, (S, C, R, V)]

  • xy: x and y position, require shape Array[float, N, (X, Y)]

  • xyv: x and y position, require shape Array[float, N, (X, Y, V)]

  • raw: require shape Array[V:float, E] or Array[V:float, S, C, R],

where E=S*C*R means all electrodes for the probe.

Parameters:
  • probe (int | str | ChannelMap | ProbeType) – any probe type identify.

  • electrode (ndarray[tuple[int, ...], dtype[float64]]) – electrode data array

  • electrode_unit (Literal['cr', 'xy', 'raw']) – electrode ordering kind

  • probe – probe type, see cast_probe_type()

  • electrode – electrode data

  • electrode_unit – electrode value unit

  • kernel (int | ndarray[tuple[int, ...], dtype[float64]] | Literal['norm'] | None) – smoothing kernel Array[float, Y], where Y use 1-um bins

Returns:

Array[float, E, (S, C, R)] or Array[float, E, (S, C, R, V)]

Returns:

value Array[float, S, R] and y Array[um:float, R]

Return type:

tuple[ndarray[tuple[int, …], dtype[float64]], ndarray[tuple[int, …], dtype[float64]]]