Skip to main content

Neuralyzer::Gather

Neuralyzer::Gather

Classes

Name
struct Neuralyzer::Gather::element_type_of
Helper to get element type from a data container.
struct Neuralyzer::Gather::element_type_of< DigitalEventSeries >
struct Neuralyzer::Gather::element_type_of< AnalogTimeSeries >
struct Neuralyzer::Gather::element_type_of< DigitalIntervalSeries >
struct Neuralyzer::Gather::BoundViewAdaptor
Result of binding a pipeline to produce a view adaptor.
struct Neuralyzer::Gather::BoundReducer
Result of binding a pipeline to produce a reducer.

Types

Name
template <typename T >
using typename element_type_of< T >::type
element_type_of_t
template <typename InElement ,typename OutElement >
using std::function< std::vector< OutElement >(std::span< InElement const >)>
ViewAdaptorFn
Type-erased view adaptor function.
using std::function< std::any(std::any const &)> ErasedViewAdaptorFn
Type-erased view adaptor that works with std::any.
template <typename InElement ,typename Scalar >
using std::function< Scalar(std::span< InElement const >)>
ReducerFn
Typed reducer function.
using std::function< std::any(std::any const &)> ErasedReducerFn
Type-erased reducer that works with std::any.
template <typename InElement ,typename Scalar >
using std::function< ReducerFn< InElement, Scalar >(Neuralyzer::Transforms::V2::PipelineValueStore const &)>
ReducerFactoryV2
Factory that creates a reducer from PipelineValueStore.
using std::function< ErasedReducerFn(Neuralyzer::Transforms::V2::PipelineValueStore const &)> ErasedReducerFactoryV2
Type-erased reducer factory (V2 pattern).
using std::variant< std::shared_ptr< DigitalIntervalSeries const >, std::shared_ptr< DigitalEventSeries const > > RowPipelineGeometry

Functions

Name
TimeFrameInterval convertIntervalToTimeFrame(TimeFrameInterval const & interval, TimeFrame const & from_time_frame, TimeFrame const & to_time_frame)
Convert an interval from one TimeFrame coordinate system to another.
TimeFrameInterval convertPreparedWindowToSourceInterval(TimeFrameInterval const & interval, std::shared_ptr< TimeFrame > const & interval_time_frame, std::shared_ptr< TimeFrame > const & source_time_frame)
Convert prepared gather-window bounds to source-data query bounds.
float extractSingleFloat(DataTypeVariant const & output)
Extract a single float from a DataTypeVariant pipeline output.
std::vector< float > gatherAndExecutePipeline(DataTypeVariant const & source, std::shared_ptr< DigitalIntervalSeries const > intervals, Neuralyzer::Transforms::V2::TransformPipeline const & pipeline)
Gather source data over intervals and execute a pipeline on each gathered view, returning one float per interval.
std::vector< float > gatherAndExecutePipeline(DataTypeVariant const & source, std::shared_ptr< DigitalIntervalSeries const > intervals, Neuralyzer::Transforms::V2::TransformPipeline const & pipeline, RowStores const & row_stores)
std::vector< float > gatherAndExecutePipeline(DataTypeVariant const & source, std::shared_ptr< DigitalIntervalSeries const > intervals, Neuralyzer::Transforms::V2::TransformPipeline const & pipeline, std::vector< Neuralyzer::Transforms::V2::PipelineValueStore > const & row_stores)
Gather source data over intervals and execute a pipeline with one PipelineValueStore per gathered row.
template <typename T >
Neuralyzer::Transforms::V2::PipelineValueStore
buildGatherRowStore(GatherResult< T > const & gather, typename GatherResult< T >::size_type row_index)
Build a TransformsV2 value store for one gathered row.
template <typename T ,typename Value >
std::vector< Neuralyzer::Transforms::V2::ValueProjectionFn< typename GatherResult< T >::element_type, Value > >
projectGatherRows(GatherResult< T > const & gather, Neuralyzer::Transforms::V2::ValueProjectionFactoryV2< typename GatherResult< T >::element_type, Value > const & factory)
Project each gathered row with a row-context-aware projection factory.
template <typename T ,typename Scalar >
std::vector< Scalar >
reduceGatherRows(GatherResult< T > const & gather, ReducerFactoryV2< typename GatherResult< T >::element_type, Scalar > const & reducer_factory)
Reduce each gathered row with a row-context-aware reducer factory.
template <typename T ,typename Scalar >
std::vector< typename GatherResult< T >::size_type >
sortGatherRowsBy(GatherResult< T > const & gather, ReducerFactoryV2< typename GatherResult< T >::element_type, Scalar > const & reducer_factory, bool ascending =true)
Return row indices sorted by a row-context-aware reduction.
template <typename InputT ,typename OutputT >
GatherResult< OutputT >
transformGatherRows(GatherResult< InputT > const & gather, Neuralyzer::Transforms::V2::TransformPipeline const & pipeline)
Execute a TransformsV2 pipeline for each row and return row-aligned DataObjects.
bool isIdentityRowPipelineJson(std::string_view row_pipeline_json)
Check whether row-pipeline JSON represents identity row geometry.
std::shared_ptr< DigitalIntervalSeries const > resolveIntervalGatherWindows(std::shared_ptr< DigitalIntervalSeries const > intervals, std::string_view row_pipeline_json, std::size_t expected_row_count)
Resolve interval-row gather windows for a tensor column.
RowPipelineGeometry resolveIntervalRowPipelineGeometry(std::shared_ptr< DigitalIntervalSeries const > intervals, std::string_view row_pipeline_json, std::size_t expected_row_count)
Resolve interval-row pipeline output as gather windows or sample times.

Types Documentation

using element_type_of_t

template <typename T >
using Neuralyzer::Gather::element_type_of_t =  typename element_type_of<T>::type;

using ViewAdaptorFn

template <typename InElement ,
typename OutElement >
using Neuralyzer::Gather::ViewAdaptorFn =  std::function<std::vector<OutElement>(std::span<InElement const>)>;

Type-erased view adaptor function.

Note: This is primarily used when type erasure is needed (e.g., storing in containers, passing through non-template interfaces).

Takes a span of input elements and produces a vector of output elements. This is the materialized version - for lazy evaluation, use the templated view adaptor that returns a range adaptor.

using ErasedViewAdaptorFn

using Neuralyzer::Gather::ErasedViewAdaptorFn =  std::function<std::any(std::any const &)>;

Type-erased view adaptor that works with std::any.

Used internally by the pipeline for runtime-typed execution.

using ReducerFn

template <typename InElement ,
typename Scalar >
using Neuralyzer::Gather::ReducerFn =  std::function<Scalar(std::span<InElement const>)>;

Typed reducer function.

Consumes a span of input elements and produces a scalar. This combines the view transformation and range reduction.

using ErasedReducerFn

using Neuralyzer::Gather::ErasedReducerFn =  std::function<std::any(std::any const &)>;

Type-erased reducer that works with std::any.

using ReducerFactoryV2

template <typename InElement ,
typename Scalar >
using Neuralyzer::Gather::ReducerFactoryV2 =  std::function<ReducerFn<InElement, Scalar>(Neuralyzer::Transforms::V2::PipelineValueStore const &)>;

Factory that creates a reducer from PipelineValueStore.

Template Parameters:

  • InElement Input element type
  • Scalar Output scalar type

See:

  • GatherResult::reduce() for usage
  • PipelineValueStore for store documentation

using ErasedReducerFactoryV2

using Neuralyzer::Gather::ErasedReducerFactoryV2 =  std::function<ErasedReducerFn(Neuralyzer::Transforms::V2::PipelineValueStore const &)>;

Type-erased reducer factory (V2 pattern).

using RowPipelineGeometry

using Neuralyzer::Gather::RowPipelineGeometry =  std::variant<
        std::shared_ptr<DigitalIntervalSeries const>,
        std::shared_ptr<DigitalEventSeries const>>;

Functions Documentation

function convertIntervalToTimeFrame

inline TimeFrameInterval convertIntervalToTimeFrame(
    TimeFrameInterval const & interval,
    TimeFrame const & from_time_frame,
    TimeFrame const & to_time_frame
)

Convert an interval from one TimeFrame coordinate system to another.

Parameters:

  • interval TimeFrameInterval expressed in from_time_frame indices
  • from_time_frame TimeFrame that owns interval coordinates
  • to_time_frame TimeFrame used by the source data being queried

Return: TimeFrameInterval expressed in to_time_frame indices

Precondition: from_time_frame and to_time_frame are valid TimeFrame references.

Postcondition: Returned bounds are expressed in to_time_frame coordinates.

function convertPreparedWindowToSourceInterval

inline TimeFrameInterval convertPreparedWindowToSourceInterval(
    TimeFrameInterval const & interval,
    std::shared_ptr< TimeFrame > const & interval_time_frame,
    std::shared_ptr< TimeFrame > const & source_time_frame
)

Convert prepared gather-window bounds to source-data query bounds.

Parameters:

  • interval Window bounds in the interval series TimeFrame
  • interval_time_frame Non-null TimeFrame from the interval/window series
  • source_time_frame Non-null TimeFrame from the source data

Return: Query interval in source-data TimeFrame coordinates

Precondition: Prepared gather windows and source data must both carry non-null TimeFrames.

Postcondition: Returned bounds are expressed in the source data TimeFrame.

function extractSingleFloat

float extractSingleFloat(
    DataTypeVariant const & output
)

Extract a single float from a DataTypeVariant pipeline output.

Parameters:

Exceptions:

  • std::runtime_error if the variant does not hold a float-producing type

Return: float scalar extracted from the output

Called after executing a range-reduction pipeline on one gathered interval view. The pipeline’s output should be a single-element AnalogTimeSeries (when the reduction produces a scalar) or a RaggedAnalogTimeSeries (for ragged intermediate results).

  • AnalogTimeSeries → returns values[0], or NAN if empty
  • RaggedAnalogTimeSeries → returns first value at the first time point, or NAN if empty
  • Any other type → throws std::runtime_error

function gatherAndExecutePipeline

std::vector< float > gatherAndExecutePipeline(
    DataTypeVariant const & source,
    std::shared_ptr< DigitalIntervalSeries const > intervals,
    Neuralyzer::Transforms::V2::TransformPipeline const & pipeline
)

Gather source data over intervals and execute a pipeline on each gathered view, returning one float per interval.

Parameters:

Exceptions:

  • std::runtime_error if the source type does not satisfy HasDataTraits or if extractSingleFloat() fails on the pipeline output

Return: std::vector with one element per interval

For each interval i the function:

  1. Creates a GatherResult view/copy of the source data within [intervals[i].start, intervals[i].end].
  2. Executes pipeline steps on that gathered view (T → DataTypeVariant), including JSON-loaded container steps.
  3. Applies the terminal range reduction to the step output.

If the source data and intervals use different TimeFrames, GatherResult converts interval boundaries to the source coordinate system when each view is created.

Dispatch is fully type-erased: the function visits the DataTypeVariant and uses GatherResult::create() + executePipeline() for each concrete contained type that supports gather.

function gatherAndExecutePipeline

std::vector< float > gatherAndExecutePipeline(
    DataTypeVariant const & source,
    std::shared_ptr< DigitalIntervalSeries const > intervals,
    Neuralyzer::Transforms::V2::TransformPipeline const & pipeline,
    RowStores const & row_stores
)

function gatherAndExecutePipeline

std::vector< float > gatherAndExecutePipeline(
    DataTypeVariant const & source,
    std::shared_ptr< DigitalIntervalSeries const > intervals,
    Neuralyzer::Transforms::V2::TransformPipeline const & pipeline,
    std::vector< Neuralyzer::Transforms::V2::PipelineValueStore > const & row_stores
)

Gather source data over intervals and execute a pipeline with one PipelineValueStore per gathered row.

Precondition: row_stores must have the same size as intervals.

function buildGatherRowStore

template <typename T >
Neuralyzer::Transforms::V2::PipelineValueStore buildGatherRowStore(
    GatherResult< T > const & gather,
    typename GatherResult< T >::size_type row_index
)

Build a TransformsV2 value store for one gathered row.

Parameters:

Template Parameters:

Return: PipelineValueStore populated with row metadata

Precondition:

  • row_index must be less than gather.size().
  • [gather](/api_generated/Files/GatherResult_8hpp.md#function-gather) must have interval metadata for row_index.

Postcondition: Returned store contains alignment_time, trial_index, trial_duration, and end_time.

function projectGatherRows

template <typename T ,
typename Value >
std::vector< Neuralyzer::Transforms::V2::ValueProjectionFn< typename GatherResult< T >::element_type, Value > > projectGatherRows(
    GatherResult< T > const & gather,
    Neuralyzer::Transforms::V2::ValueProjectionFactoryV2< typename GatherResult< T >::element_type, Value > const & factory
)

Project each gathered row with a row-context-aware projection factory.

Parameters:

  • gather GatherResult supplying rows and metadata
  • factory Factory that binds one projection per row store

Template Parameters:

  • T GatherResult row DataObject type
  • Value Projected value type

Return: One projection function per row

Precondition: factory must return a valid projection for each row store.

Postcondition: Return size equals gather.size().

function reduceGatherRows

template <typename T ,
typename Scalar >
std::vector< Scalar > reduceGatherRows(
    GatherResult< T > const & gather,
    ReducerFactoryV2< typename GatherResult< T >::element_type, Scalar > const & reducer_factory
)

Reduce each gathered row with a row-context-aware reducer factory.

Parameters:

  • gather GatherResult supplying rows and metadata
  • reducer_factory Factory that binds one reducer per row store

Template Parameters:

  • T GatherResult row DataObject type
  • Scalar Scalar reduction output type

Return: One scalar value per row

Precondition:

  • Each row DataObject must expose view().
  • reducer_factory must return a valid reducer for each row store.

Postcondition: Return size equals gather.size().

function sortGatherRowsBy

template <typename T ,
typename Scalar >
std::vector< typename GatherResult< T >::size_type > sortGatherRowsBy(
    GatherResult< T > const & gather,
    ReducerFactoryV2< typename GatherResult< T >::element_type, Scalar > const & reducer_factory,
    bool ascending =true
)

Return row indices sorted by a row-context-aware reduction.

Parameters:

  • gather GatherResult supplying rows and metadata
  • reducer_factory Factory that binds one reducer per row store
  • ascending Sort smallest values first when true

Template Parameters:

  • T GatherResult row DataObject type
  • Scalar Comparable scalar reduction output type

Return: Row indices that sort the reduction outputs

Precondition: reducer_factory must return comparable values.

Postcondition: NaN floating-point values sort to the end, matching the former core helper.

function transformGatherRows

template <typename InputT ,
typename OutputT >
GatherResult< OutputT > transformGatherRows(
    GatherResult< InputT > const & gather,
    Neuralyzer::Transforms::V2::TransformPipeline const & pipeline
)

Execute a TransformsV2 pipeline for each row and return row-aligned DataObjects.

Parameters:

Template Parameters:

  • InputT Input GatherResult row DataObject type
  • OutputT Pipeline output DataObject type

Return: GatherResult containing one output DataObject per input row

Precondition: pipeline must produce std::shared_ptr<OutputT> for every row.

Postcondition: Returned GatherResult preserves gather row metadata and ordering.

function isIdentityRowPipelineJson

bool isIdentityRowPipelineJson(
    std::string_view row_pipeline_json
)

Check whether row-pipeline JSON represents identity row geometry.

Parameters:

  • row_pipeline_json Embedded row-pipeline JSON string.

Exceptions:

  • std::runtime_error if non-empty JSON cannot be parsed as a pipeline descriptor.

Return: True when the JSON is empty/whitespace or contains no executable row steps.

Postcondition: Does not execute any transform pipeline.

function resolveIntervalGatherWindows

std::shared_ptr< DigitalIntervalSeries const > resolveIntervalGatherWindows(
    std::shared_ptr< DigitalIntervalSeries const > intervals,
    std::string_view row_pipeline_json,
    std::size_t expected_row_count
)

Resolve interval-row gather windows for a tensor column.

Parameters:

  • intervals Original tensor row-source intervals.
  • row_pipeline_json Embedded row-pipeline JSON string.
  • expected_row_count Number of rows in the original row source.

Exceptions:

  • std::runtime_error if intervals is null, row count changes, JSON is invalid, or the row pipeline output is not a DigitalIntervalSeries.

Return: Prepared gather windows for the column.

Precondition: intervals must not be null.

Postcondition: Identity row pipelines return the original interval series; non-identity pipelines return a row-aligned DigitalIntervalSeries result.

function resolveIntervalRowPipelineGeometry

RowPipelineGeometry resolveIntervalRowPipelineGeometry(
    std::shared_ptr< DigitalIntervalSeries const > intervals,
    std::string_view row_pipeline_json,
    std::size_t expected_row_count
)

Resolve interval-row pipeline output as gather windows or sample times.

Identity row pipelines return the original DigitalIntervalSeries windows. Non-identity row pipelines may return DigitalIntervalSeries windows or DigitalEventSeries sample times, both preserving the expected row count.


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