Skip to content

ndi.fun.probe.geometry.toKilosortMap

  NDI.FUN.PROBE.GEOMETRY.TOKILOSORTMAP - build a Kilosort/KIASORT channel map from a probe's stored geometry

  [TF, OUTPUTFILE] = NDI.FUN.PROBE.GEOMETRY.TOKILOSORTMAP(S, PROBE, OUTPUTFILE, ...)

  Reads the 'probe_geometry' (and 'site2channelmap') documents that describe the
  electrode geometry of PROBE in the ndi.session S, and writes a Kilosort-style
  channel-map .mat file OUTPUTFILE (via NDI.FUN.PROBE.GEOMETRY.WRITEKILOSORTMAP)
  whose xcoords/ycoords/kcoords/connected are aligned to the channel order of the
  binary exported by NDI.FUN.PROBE.EXPORT.BINARY. KIASORT's load_channel_map accepts
  this file directly, so a sort then uses the probe's real spatial layout.

  Returns TF = true and writes OUTPUTFILE if a probe_geometry document was found;
  TF = false and writes nothing if the probe has no geometry on file (so callers,
  e.g. ndi.fun.probe.import.kiasort.run, can fall back to a default map).

  ALIGNMENT: NDI stores per-site coordinates in 'probe_geometry'
  (site_locations_leftright, site_locations_frontback, site_locations_depth,
  shank_id) and a 'site2channelmap' whose 'map' column gives, for each site i, the
  recording channel index map(i). The exported binary orders channels 1..N in the
  probe's channel order, so this function inverts the map: for each site i it places
  that site's coordinates at channel map(i). Channels with no site are marked
  connected=false. If no 'site2channelmap' is found, an identity map (site i ->
  channel i) is assumed (with a warning) when the site count matches num_channels.

  By convention the Kilosort horizontal axis (xcoords) is the probe's left/right
  axis and the vertical axis (ycoords) is depth (matching ndi.fun.probe.plotProbeGeometry).

  Name/value pairs:
  ---------------------------------------------------------------------------------
  | Parameter (default)      | Description                                         |
  |--------------------------|-----------------------------------------------------|
  | num_channels ([])        | Number of channels in the export. If empty, read a  |
  |                          |   single sample from the probe to determine it.     |
  | horizontal_axis          | Which probe axis maps to xcoords: 'leftright' or    |
  |   ('leftright')          |   'frontback'. ycoords is always depth.             |
  | verbose (1)              | 0/1 Should we be verbose?                           |
  ---------------------------------------------------------------------------------

  See also: NDI.FUN.PROBE.GEOMETRY.FROMKILOSORTMAP, NDI.FUN.PROBE.GEOMETRY.WRITEKILOSORTMAP,
    NDI.FUN.PROBE.GEOMETRY.GET, NDI.FUN.PROBE.IMPORT.KIASORT.RUN, NDI.FUN.PROBE.PLOTPROBEGEOMETRY