Skip to main content

src/CoreUtilities/include/CoreUtilities/ProbeGeometry/ChannelPosition.hpp

src/CoreUtilities/include/CoreUtilities/ProbeGeometry/ChannelPosition.hpp

Generic probe electrode position metadata and sortable-rank types. More…

Classes

Name
struct ChannelPosition
Physical position of one electrode channel on a multi-channel probe.
struct NormalizedSeriesIdentity
Normalized identity parsed from a series key.

Types

Name
using std::unordered_map< std::string, std::vector< ChannelPosition > > ChannelPositionMap
Map of probe group name to its electrode channel positions.
using std::unordered_map< std::string, int > SortableRankMap
Generic rank map consumed by ordering policy.
using std::function< SortableRankMap(std::vector< std::string > const &)> SortableRankProvider
Provider contract for external sortable-rank sources.

Functions

Name
COREUTILITIES_EXPORT NormalizedSeriesIdentity parseSeriesIdentity(std::string const & key)
Parse a series key into a normalized group/channel identity.
std::optional< int > extractChannelFromSeriesKey(std::string const & key, std::string const & group, bool key_one_based)
Extract a 0-based channel index from a series key within a group.
COREUTILITIES_EXPORT bool detectKeyOneBased(std::vector< std::string > const & keys, std::string const & group)
Infer whether series key suffixes in a group are 1-based.

Detailed Description

Generic probe electrode position metadata and sortable-rank types.

Defines the source-agnostic data model for electrode channel positions on a multi-channel neural probe. These types are consumed by spike-sorting transforms (such as SwindaleEventDetection), rank adapter layers, and viewer ordering policies.

Types Documentation

using ChannelPositionMap

using ChannelPositionMap =  std::unordered_map<std::string, std::vector<ChannelPosition>>;

Map of probe group name to its electrode channel positions.

Keys are group names corresponding to the group component of a series key (e.g. “ephys” in “ephys_32”).

using SortableRankMap

using SortableRankMap =  std::unordered_map<std::string, int>;

Generic rank map consumed by ordering policy.

Maps series key to an integer rank.

using SortableRankProvider

using SortableRankProvider =  std::function<SortableRankMap(std::vector<std::string> const &)>;

Provider contract for external sortable-rank sources.

Functions Documentation

function parseSeriesIdentity

COREUTILITIES_EXPORT NormalizedSeriesIdentity parseSeriesIdentity(
    std::string const & key
)

Parse a series key into a normalized group/channel identity.

Parameters:

  • key Series key to parse (e.g. “ephys_32”)

Return: Normalized identity. Non-conforming keys return group=key, channel_id=nullopt.

function extractChannelFromSeriesKey

std::optional< int > extractChannelFromSeriesKey(
    std::string const & key,
    std::string const & group,
    bool key_one_based
)

Extract a 0-based channel index from a series key within a group.

Parameters:

  • key Series key (e.g. “voltage_19”)
  • group Expected group prefix (e.g. “voltage”)
  • key_one_based true when suffixes are 1-based (e.g. “voltage_1” = first channel)

Return: 0-based channel index, or std::nullopt when the key does not match

function detectKeyOneBased

COREUTILITIES_EXPORT bool detectKeyOneBased(
    std::vector< std::string > const & keys,
    std::string const & group
)

Infer whether series key suffixes in a group are 1-based.

Parameters:

  • keys Series keys to inspect (typically all analog keys in a group)
  • group Group prefix to match (e.g. “voltage”)

Return: false (0-based) when any key has suffix 0, otherwise true (1-based)

Source code

#ifndef COREUTILITIES_PROBE_GEOMETRY_CHANNEL_POSITION_HPP
#define COREUTILITIES_PROBE_GEOMETRY_CHANNEL_POSITION_HPP


#include "coreutilities_export.h"

#include <functional>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>

struct ChannelPosition {
    int channel_id{0};
    float x{0.0f};    
    float y{0.0f};    
};

using ChannelPositionMap = std::unordered_map<std::string, std::vector<ChannelPosition>>;

struct NormalizedSeriesIdentity {
    std::string group;
    std::optional<int> channel_id;
};

[[nodiscard]] COREUTILITIES_EXPORT NormalizedSeriesIdentity parseSeriesIdentity(std::string const & key);

[[nodiscard]] std::optional<int> extractChannelFromSeriesKey(
        std::string const & key,
        std::string const & group,
        bool key_one_based);

[[nodiscard]] COREUTILITIES_EXPORT bool detectKeyOneBased(
        std::vector<std::string> const & keys,
        std::string const & group);

using SortableRankMap = std::unordered_map<std::string, int>;

using SortableRankProvider = std::function<SortableRankMap(std::vector<std::string> const &)>;

#endif// COREUTILITIES_PROBE_GEOMETRY_CHANNEL_POSITION_HPP

Updated on 2026-11-13 at 20:25:42 +0000