src/WhiskerToolbox/DataViewer_Widget/Ordering/SpikeToAnalogPairingLoader.hpp
src/WhiskerToolbox/DataViewer_Widget/Ordering/SpikeToAnalogPairingLoader.hpp
Parser for CSV spike-to-analog channel pairing files. More…
Classes
| Name | |
|---|---|
| struct | SpikeToAnalogParseConfig Parse options for parseSpikeToAnalogCSV. |
| struct | SpikeToAnalogPairing One pairing between a digital spike channel and an analog LFP channel. |
Types
| Name | |
|---|---|
| enum class | SpikeToAnalogCsvDelimiter { Comma, Tab, Semicolon, Whitespace, Pipe} Field delimiter used in the spike-to-analog pairing CSV file. |
| enum class | SpikeToAnalogPlacementMode { AdjacentBelow = 0, AdjacentAbove = 1, Overlay = 2} Placement policy for spike-to-analog pairing loader. |
Functions
| Name | |
|---|---|
| std::vector< SpikeToAnalogPairing > | parseSpikeToAnalogCSV(std::string const & text, SpikeToAnalogParseConfig const & config =SpikeToAnalogParseConfig) Parse a spike-to-analog pairing CSV and compute the modal analog channel for each unique digital channel. |
Detailed Description
Parser for CSV spike-to-analog channel pairing files.
Parses a CSV file where each row records a spike event. The column positions for the digital and analog channel indices, the field delimiter, and whether indices are 1-based or 0-based are all configurable via [SpikeToAnalogParseConfig](/api_generated/Classes/structSpikeToAnalogParseConfig.md).
For each unique digital_channel, the analog_channel that appears most often (mode) is returned as the pairing. Channel numbers are converted to 0-based in the output according to the configured indexing policy.
Placement Modes
Three placement policies are supported when applying pairings to the DataViewer lane stack:
- AdjacentBelow: each
spikes_Nis placed in its own lane immediately below its pairedvoltage_M. - AdjacentAbove: each
spikes_Nis placed immediately above its pairedvoltage_M. - Overlay: each
spikes_Nshares thelane_idof its pairedvoltage_M(rendered in the same lane band withoverlay_mode = Overlay).
Types Documentation
enum SpikeToAnalogCsvDelimiter
| Enumerator | Value | Description |
|---|---|---|
| Comma | Comma (‘,’) — default. | |
| Tab | Tab (’). | |
| Semicolon | Semicolon (‘;’). | |
| Whitespace | Any whitespace (space or tab). | |
| Pipe | Pipe (’ |
Field delimiter used in the spike-to-analog pairing CSV file.
enum SpikeToAnalogPlacementMode
| Enumerator | Value | Description |
|---|---|---|
| AdjacentBelow | 0 | Place spike series in own lane immediately below the analog lane. |
| AdjacentAbove | 1 | Place spike series in own lane immediately above the analog lane. |
| Overlay | 2 | Spike series shares the analog series’ lane band. |
Placement policy for spike-to-analog pairing loader.
Functions Documentation
function parseSpikeToAnalogCSV
std::vector< SpikeToAnalogPairing > parseSpikeToAnalogCSV(
std::string const & text,
SpikeToAnalogParseConfig const & config =SpikeToAnalogParseConfig{}
)Parse a spike-to-analog pairing CSV and compute the modal analog channel for each unique digital channel.
Parameters:
- text Raw CSV text content
- config Parse options (delimiter, column positions, index base)
Return: One [SpikeToAnalogPairing](/api_generated/Classes/structSpikeToAnalogPairing.md) per unique digital channel (0-based indices). Returns an empty vector if no valid rows are found.
Each row is split by the delimiter specified in config. The digital and analog channel numbers are read from the configured column positions (1-based column indices). Rows that cannot be parsed are silently skipped.
When multiple analog channels appear for the same digital channel the most frequent one (mode) is chosen. Ties are broken by choosing the smallest analog channel index.
Source code
#ifndef DATAVIEWER_SPIKE_TO_ANALOG_PAIRING_LOADER_HPP
#define DATAVIEWER_SPIKE_TO_ANALOG_PAIRING_LOADER_HPP
#include <string>
#include <vector>
enum class SpikeToAnalogCsvDelimiter {
Comma,
Tab,
Semicolon,
Whitespace,
Pipe,
};
struct SpikeToAnalogParseConfig {
SpikeToAnalogCsvDelimiter delimiter{SpikeToAnalogCsvDelimiter::Comma};
int digital_column{2};
int analog_column{3};
bool digital_one_based{true};
bool analog_one_based{true};
bool digital_key_one_based{true};
bool analog_key_one_based{true};
};
struct SpikeToAnalogPairing {
int digital_channel{0};
int analog_channel{0};
};
enum class SpikeToAnalogPlacementMode {
AdjacentBelow = 0,
AdjacentAbove = 1,
Overlay = 2,
};
[[nodiscard]] std::vector<SpikeToAnalogPairing> parseSpikeToAnalogCSV(
std::string const & text,
SpikeToAnalogParseConfig const & config = SpikeToAnalogParseConfig{});
#endif// DATAVIEWER_SPIKE_TO_ANALOG_PAIRING_LOADER_HPPUpdated on 2026-11-13 at 20:25:45 +0000