Skip to content

dspk.synapse.spatial

Space: where each spike comes from on the probe (four localisers), and how the probe drifted (rigid or by depth blocks). Positions and depths are µm, in the probe’s coordinates.

drift How the probe moved over the recording, from where and when spikes occurred.
localize Where each spike comes from on the probe.
drift(
samples,
depths_um,
amplitudes_uv,
total_samples: int,
sample_rate: float,
*,
depth_min_um: float,
depth_max_um: float,
time_bin_s: float = DEFAULT_DRIFT_TIME_BIN_S,
depth_bin_um: float = DEFAULT_DRIFT_DEPTH_BIN_UM,
max_drift_um: float = DEFAULT_MAX_DRIFT_UM,
depth_blocks: int = DEFAULT_DRIFT_DEPTH_BLOCKS,
rigid: bool = True,
) -> dict

How the probe moved over the recording, from where and when spikes occurred.

Parameters

  • samples : array_like
    Sample of every spike.
  • depths_um : array_like
    Depth of every spike, in µm.
  • amplitudes_uv : array_like
    Amplitude of every spike, in µV.
  • total_samples : int
    Samples in the recording.
  • sample_rate : float
    Sample rate in Hz.
  • depth_min_um : float
    The depth range considered.
  • depth_max_um : float
    The depth range considered.
  • time_bin_s : float, default DEFAULT_DRIFT_TIME_BIN_S (2.0)
    Time resolution of the estimate.
  • depth_bin_um : float, default DEFAULT_DRIFT_DEPTH_BIN_UM (5.0)
    Depth resolution of the activity map.
  • max_drift_um : float, default DEFAULT_MAX_DRIFT_UM (50.0)
    Largest shift searched.
  • depth_blocks : int, default DEFAULT_DRIFT_DEPTH_BLOCKS (5)
    Blocks along depth, each with its own drift (rigid=False).
  • rigid : bool, default True
    One drift for the whole probe, or one per depth block.

Returns

  • dict — Rigid: times_s, drift_um, activity (time bins, depth bins). Non-rigid: times_s, block_centers_um, drift_um (depth_blocks, time bins).
localize(
snippets: dict,
probe: Probe,
*,
method: str = 'center_of_mass',
power: float = DEFAULT_COM_POWER,
max_iterations: int | None = None,
xy_radius_um: float = DEFAULT_GRID_XY_RADIUS_UM,
xy_step_um: float = DEFAULT_GRID_XY_STEP_UM,
z_values_um=DEFAULT_GRID_Z_VALUES_UM,
softmax_temperature: float = DEFAULT_GRID_SOFTMAX_TEMPERATURE,
) -> np.ndarray

Where each spike comes from on the probe.

Parameters

  • snippets : dict
    waveforms (spikes, k, samples) and channels (spikes, k), the spike’s own channel first, as synapse.extraction.snippets returns them.
  • probe : Probe
    The probe.
  • method : {"center_of_mass", "monopolar", "grid_convolution", "dipole"}, default 'center_of_mass'
    "center_of_mass": the sites weighted by peak-to-peak height to power. "monopolar": a point source fitted by Levenberg–Marquardt. "grid_convolution": a grid of candidate sources, weighted by a softmax. "dipole": a dipole fitted to the signed peaks.
  • power : float, default DEFAULT_COM_POWER (1.0)
    Exponent of the weights ("center_of_mass").
  • max_iterations : int, default None
    Fit iterations ("monopolar", "dipole"); by default DEFAULT_MONOPOLAR_ITERATIONS or DEFAULT_DIPOLE_ITERATIONS.
  • xy_radius_um : float, default DEFAULT_GRID_XY_RADIUS_UM (30.0)
    Extent and step of the candidate grid ("grid_convolution").
  • xy_step_um : float, default DEFAULT_GRID_XY_STEP_UM (5.0)
    Extent and step of the candidate grid ("grid_convolution").
  • z_values_um : sequence of float, default DEFAULT_GRID_Z_VALUES_UM ([5.0, 10.0, 20.0, 35.0, 50.0])
    Candidate distances from the probe plane ("grid_convolution").
  • softmax_temperature : float, default DEFAULT_GRID_SOFTMAX_TEMPERATURE (0.05)
    Sharpness of the grid weights ("grid_convolution").

Returns

  • np.ndarray — Positions (spikes, 3) in µm, in the probe’s coordinates.

Raises

  • ValueError: For an unknown method.
Name Type Value Description
DEFAULT_COM_POWER float 1.0
DEFAULT_DIPOLE_ITERATIONS int 40
DEFAULT_DRIFT_DEPTH_BIN_UM float 5.0
DEFAULT_DRIFT_DEPTH_BLOCKS int 5
DEFAULT_DRIFT_TIME_BIN_S float 2.0
DEFAULT_GRID_SOFTMAX_TEMPERATURE float 0.05
DEFAULT_GRID_XY_RADIUS_UM float 30.0
DEFAULT_GRID_XY_STEP_UM float 5.0
DEFAULT_GRID_Z_VALUES_UM tuple[float, ...] [5.0, 10.0, 20.0, 35.0, 50.0]
DEFAULT_MAX_DRIFT_UM float 50.0
DEFAULT_MONOPOLAR_ITERATIONS int 35
METHODS ('center_of_mass', 'monopolar', 'grid_convolution', 'dipole')