Skip to content

ndi.fun.probe.geometry.writeKilosortMap

  NDI.FUN.PROBE.GEOMETRY.WRITEKILOSORTMAP - write a Kilosort/KIASORT channel map .mat from raw arrays

  NDI.FUN.PROBE.GEOMETRY.WRITEKILOSORTMAP(OUTPUTFILE, ...)

  Writes a channel-map .mat file OUTPUTFILE in the Kilosort convention. KIASORT's
  load_channel_map accepts exactly this convention (chanMap / chanMap0ind,
  connected, xcoords, ycoords, optional kcoords), so this file can be passed to
  run_kiasort_nogui(..., channelMapFile, ...) or selected in the KIASORT GUI.

  This is the low-level writer used by NDI.FUN.PROBE.GEOMETRY.TOKILOSORTMAP (which
  supplies real coordinates from a probe's stored geometry). Call it directly when
  you already have the coordinate arrays, or to write a placeholder map from just a
  channel count.

  The number of channels is taken from OPTIONS.num_channels, or read from the
  '.metadata' sidecar written by ndi.fun.probe.export.binary when
  OPTIONS.metadataFile is given (or when OUTPUTFILE sits next to a 'kilosort.bin' /
  'kiasort.bin' with a '.metadata' file).

  By default a simple single-column linear geometry is written (xcoords all 0,
  ycoords spaced by OPTIONS.spacing microns, all channels connected). This is a
  placeholder that lets KIASORT run; for real sorting, pass the true geometry via
  OPTIONS.xcoords / OPTIONS.ycoords (and OPTIONS.kcoords for multi-shank probes), or
  use NDI.FUN.PROBE.GEOMETRY.TOKILOSORTMAP to build it from the probe's geometry
  documents. A warning is issued when the default linear geometry is used.

  Name/value pairs:
  ---------------------------------------------------------------------------------
  | Parameter (default) | Description                                              |
  |---------------------|----------------------------------------------------------|
  | num_channels ([])   | Number of channels. If empty, read from metadataFile.    |
  | metadataFile ('')   | Path to a '.metadata' sidecar to read num_channels from. |
  |                     |   If '' and num_channels is empty, this function looks    |
  |                     |   for '<OUTPUTFILE dir>/kiasort.bin.metadata' then        |
  |                     |   'kilosort.bin.metadata'.                               |
  | chanMap ([])        | 1-based channel map (default 1:num_channels).            |
  | connected ([])      | logical vector of included channels (default all true).  |
  | xcoords ([])        | x coordinate (microns) of each channel (default zeros).  |
  | ycoords ([])        | y coordinate (microns) of each channel (default linear   |
  |                     |   0:spacing:(n-1)*spacing).                              |
  | kcoords ([])        | shank index of each channel (default ones).             |
  | spacing (20)        | Spacing (microns) between channels for the default       |
  |                     |   linear ycoords.                                        |
  | verbose (1)         | 0/1 Should we be verbose?                               |
  ---------------------------------------------------------------------------------

  See also: NDI.FUN.PROBE.GEOMETRY.TOKILOSORTMAP, NDI.FUN.PROBE.GEOMETRY.FROMKILOSORTMAP