Neuralyzer::Transforms::V2::Examples
Neuralyzer::Transforms::V2::Examples
Classes
Types
| Name | |
|---|---|
| enum class | DifferenceMethod { Backward, Central, Forward} Difference method applied to each sample. |
| enum class | DifferenceEdgePolicy { Skip, NaN, Zero, Clamp} Policy for handling samples where the differencing window is incomplete. |
| enum class | IntervalEventPoint { start, end, center} Which point within an interval becomes the output event time. |
| enum class | LineAngleMethod { DirectPoints, PolynomialFit} Angle calculation method. |
| enum class | LineCurvatureMethod { PolynomialFit} Curvature calculation method. |
| enum class | LinePointExtractionMethod { Direct, Parametric} Point extraction method. |
| enum class | LineResampleMethod { FixedSpacing, DouglasPeucker, PolynomialSmooth} Line simplification algorithm selection. |
| enum class | LineSubsegmentMethod { Direct, Parametric} Subsegment extraction method. |
| enum class | SkeletonizeMethod { ZhangSuen, MedialAxis} Skeletonization algorithm selection. |
| enum class | PointCoordinateComponent { X, Y} Coordinate component to extract from each point. |
| enum class | PointReductionMethod { First, Mean, Sum, Max, Min} Method for reducing multiple points at a single time frame into a scalar. |
| enum class | SincWindowType { Lanczos, Hann, Blackman} Window function type for the sinc kernel. |
| enum class | BoundaryMode { SymmetricExtension, ZeroPad} Boundary handling mode for edge samples. |
| enum class | CARMethod { Mean, Median} Method used to compute the cross-channel reference signal. |
| enum class | DeltaBoundaryPolicy { NaN, Drop, Clamp, Zero} Policy for handling boundary rows where t-1 or t+1 is out-of-range. |
| enum class | BoundaryPolicy { NaN, Drop, Clamp, Zero} Policy for handling boundary rows where a neighbor offset is out-of-range. |
Functions
| Name | |
|---|---|
| std::shared_ptr< AnalogTimeSeries > | analogDifference(AnalogTimeSeries const & input, AnalogDifferenceParams const & params, ComputeContext const & ctx) Compute backward, central, or forward difference on an AnalogTimeSeries. |
| std::shared_ptr< DigitalEventSeries > | analogEventThreshold(AnalogTimeSeries const & input, AnalogEventThresholdParams const & params, ComputeContext const & ctx) Detect threshold crossing events in an analog time series. |
| std::shared_ptr< AnalogTimeSeries > | analogHilbertPhase(AnalogTimeSeries const & input, AnalogHilbertPhaseParams const & params, ComputeContext const & ctx) Calculate instantaneous phase or amplitude using Hilbert transform. |
| std::shared_ptr< TensorData > | analogToTensor(std::vector< std::shared_ptr< AnalogTimeSeries const > > const & channels, AnalogToTensorParams const & params, ComputeContext const & ctx) Pack multiple AnalogTimeSeries channels into a single 2D TensorData. |
| std::shared_ptr< DigitalIntervalSeries > | eventToInterval(DigitalEventSeries const & input, EventToIntervalParams const & params, ComputeContext const & ctx) Expand each event in a DigitalEventSeries into a window interval. |
| TimeFrameIndex | eventTimeForInterval(TimeFrameInterval const & interval, IntervalEventPoint point) Compute the event time for an interval at the selected alignment point. |
| std::shared_ptr< DigitalEventSeries > | intervalToEvent(DigitalIntervalSeries const & input, IntervalToEventParams const & params, ComputeContext const & ctx) Extract one event per interval from a DigitalIntervalSeries. |
| float | calculateLineAngle(Line2D const & line, LineAngleParams const & params) Calculate the angle at a specified position along a line. |
| float | calculateLineAngleWithContext(Line2D const & line, LineAngleParams const & params, ComputeContext const & ctx) Context-aware version with progress reporting. |
| Line2D | flipLineBase(Line2D const & line, LineBaseFlipParams const & params) Flip a line’s base if it’s farther from the reference point than the end. |
| Line2D | flipLineBaseWithContext(Line2D const & line, LineBaseFlipParams const & params, ComputeContext const & ctx) Context-aware version with progress reporting. |
| Line2D | clipLineAtReference(Line2D const & line, Line2D const & reference_line, LineClipParams const & params) Clip a line at its intersection with a reference line. |
| Line2D | clipLineAtReferenceWithContext(Line2D const & line, Line2D const & reference_line, LineClipParams const & params, ComputeContext const & ctx) Context-aware version with progress reporting. |
| float | calculateLineCurvature(Line2D const & line, LineCurvatureParams const & params) Calculate the curvature at a specified position along a line. |
| float | calculateLineCurvatureWithContext(Line2D const & line, LineCurvatureParams const & params, ComputeContext const & ctx) Context-aware version with progress reporting. |
| Line2D | extendLineAtReference(Line2D const & line, Line2D const & reference_line, LineExtendParams const & params) Extend a line along a smoothed tangent until it hits a reference polyline. |
| Line2D | extendLineAtReferenceWithContext(Line2D const & line, Line2D const & reference_line, LineExtendParams const & params, ComputeContext const & ctx) Context-aware version with progress reporting. |
| float | calculateLineLength(Line2D const & line, LineLengthParams const & params) Calculate the total arc length of a Line2D. |
| float | calculateLineLengthWithContext(Line2D const & line, LineLengthParams const & params, ComputeContext const & ctx) Context-aware version with progress reporting and cancellation. |
| float | pointToLineSegmentDistance2(Point2D< float > const & point, Point2D< float > const & line_start, Point2D< float > const & line_end) Calculate squared distance from point to line segment. |
| float | pointToLineMinDistance2(Point2D< float > const & point, Line2D const & line) Calculate minimum squared distance from point to entire line. |
| float | calculateLineMinPointDistance(Line2D const & line, Point2D< float > const & point, LineMinPointDistParams const & params) Calculate distance from a single point to a line. |
| float | calculateLineMinPointDistanceWithContext(Line2D const & line, Point2D< float > const & point, LineMinPointDistParams const & params, ComputeContext const & ctx) Context-aware version with progress reporting. |
| Point2D< float > | extractLinePoint(Line2D const & line, LinePointExtractionParams const & params) Extract a point at a specified position along a line. |
| Point2D< float > | extractLinePointWithContext(Line2D const & line, LinePointExtractionParams const & params, ComputeContext const & ctx) Context-aware version with progress reporting. |
| Line2D | resampleLine(Line2D const & line, LineResampleParams const & params) Resample or simplify a line based on the selected algorithm. |
| Line2D | resampleLineWithContext(Line2D const & line, LineResampleParams const & params, ComputeContext const & ctx) Context-aware version with progress reporting. |
| Line2D | extractLineSubsegment(Line2D const & line, LineSubsegmentParams const & params) Extract a subsegment from a line between specified fractional positions. |
| Line2D | extractLineSubsegmentWithContext(Line2D const & line, LineSubsegmentParams const & params, ComputeContext const & ctx) Context-aware version with progress reporting. |
| float | calculateMaskArea(Mask2D const & mask, MaskAreaParams const & params) Calculate area of a single mask. |
| float | calculateMaskAreaWithContext(Mask2D const & mask, MaskAreaParams const & params, ComputeContext const & ctx) Calculate area with context support. |
| Point2D< float > | calculateMaskCentroid(Mask2D const & mask, MaskCentroidParams const & params) Calculate the centroid (center of mass) of a single mask. |
| Point2D< float > | calculateMaskCentroidWithContext(Mask2D const & mask, MaskCentroidParams const & params, ComputeContext const & ctx) Calculate the centroid with context support for progress/cancellation. |
| Mask2D | applyMedianFilter(Mask2D const & mask, MaskMedianFilterParams const & params) Apply median filtering to a single mask element. |
| Mask2D | applyMedianFilterWithContext(Mask2D const & mask, MaskMedianFilterParams const & params, ComputeContext const & ctx) Apply median filtering with progress reporting and cancellation support. |
| Mask2D | skeletonizeMask(Mask2D const & mask, MaskSkeletonizeParams const & params) Parameters for mask skeletonization. |
| Mask2D | skeletonizeMaskWithContext(Mask2D const & mask, MaskSkeletonizeParams const & params, ComputeContext const & ctx) Skeletonize a mask with progress reporting and cancellation support. |
| Line2D | maskToLine(Mask2D const & mask, MaskToLineParams const & params) Order mask points into a directed line polyline. |
| Line2D | maskToLineWithContext(Mask2D const & mask, MaskToLineParams const & params, ComputeContext const & ctx) Order mask points into a line with progress reporting and cancellation support. |
| std::shared_ptr< RaggedAnalogTimeSeries > | pointCoordinate(PointData const & input, PointCoordinateParams const & params, ComputeContext const & ctx) Project PointData x or y coordinates into RaggedAnalogTimeSeries. |
| std::shared_ptr< AnalogTimeSeries > | pointCoordinateReduction(PointData const & input, PointCoordinateReductionParams const & params, ComputeContext const & ctx) Project PointData x or y coordinates into an AnalogTimeSeries, collapsing multiple points at a single time. |
| std::shared_ptr< DigitalIntervalSeries > | pruneOverlappingIntervals(DigitalIntervalSeries const & input, PruneOverlappingIntervalsParams const & params, ComputeContext const & ctx) Greedy keep-first pruning of overlapping intervals. |
| Line2D | removeLineOutliers(Line2D const & line, RemoveLineOutliersParams const & params) Remove geometric outlier points from an ordered line. |
| Line2D | removeLineOutliersWithContext(Line2D const & line, RemoveLineOutliersParams const & params, ComputeContext const & ctx) Remove line outliers with progress reporting and cancellation support. |
| std::shared_ptr< AnalogTimeSeries > | sincInterpolation(AnalogTimeSeries const & input, SincInterpolationParams const & params, ComputeContext const & ctx) Apply band-limited sinc interpolation to upsample an AnalogTimeSeries. |
| std::vector< float > | sumReduction(std::span< float const > values, SumReductionParams const & params) Sum all floats at a given time point into a single float. |
| std::vector< float > | sumReductionWithContext(std::span< float const > values, SumReductionParams const & params, ComputeContext const & ctx) Context-aware version with progress reporting. |
| std::shared_ptr< TensorData > | tensorCAR(TensorData const & input, TensorCARParams const & params, ComputeContext const & ctx) Apply Common Average Reference to a multi-channel TensorData. |
| std::shared_ptr< TensorData > | tensorCentralDifference(TensorData const & input, TensorCentralDifferenceParams const & params, ComputeContext const & ctx) Append central-difference columns to a time-indexed TensorData. |
| std::shared_ptr< TensorData > | tensorICA(TensorData const & input, TensorICAParams const & params, ComputeContext const & ctx) Apply ICA (RADICAL) to a TensorData. |
| std::shared_ptr< TensorData > | tensorPCA(TensorData const & input, TensorPCAParams const & params, ComputeContext const & ctx) Apply PCA dimensionality reduction to a TensorData. |
| std::shared_ptr< TensorData > | tensorRobustPCA(TensorData const & input, TensorRobustPCAParams const & params, ComputeContext const & ctx) Apply Robust PCA dimensionality reduction to a TensorData. |
| std::shared_ptr< TensorData > | tensorTemporalNeighbors(TensorData const & input, TensorTemporalNeighborParams const & params, ComputeContext const & ctx) Augment a time-indexed TensorData with neighbor feature columns. |
| std::vector< std::shared_ptr< AnalogTimeSeries > > | tensorToAnalog(TensorData const & input, TensorToAnalogParams const & params, ComputeContext const & ctx) Extract columns from a 2D TensorData as independent AnalogTimeSeries. |
| std::shared_ptr< TensorData > | tensorTSNE(TensorData const & input, TensorTSNEParams const & params, ComputeContext const & ctx) Apply t-SNE dimensionality reduction to a TensorData. |
| std::shared_ptr< TensorData > | tensorWhitening(TensorData const & input, TensorWhiteningParams const & params, ComputeContext const & ctx) Apply robust ZCA whitening to the included channels of a 2D tensor. |
| std::any | loadParametersForTransform(std::string const & transform_name, std::string const & json_str) |
| template <typename ParamsT > rfl::Result< ParamsT > |
loadParametersFromJson(std::string const & json_str) |
| template <typename ParamsT > rfl::Result< ParamsT > |
loadParametersFromFile(std::string const & file_path) Load parameters from JSON file. |
| template <typename ParamsT > std::string |
saveParametersToJson(ParamsT const & params) Save parameters to JSON string. |
| template <typename ParamsT > bool |
saveParametersToFile(ParamsT const & params, std::string const & file_path, bool pretty_print =true) Save parameters to JSON file. |
| std::filesystem::path | defaultUserPipelineDirectory(std::filesystem::path const & config_dir) Default subdirectory for user TransformsV2 pipelines under a config root. |
| rfl::Result< std::filesystem::path > | ensureUserPipelineDirectory(std::filesystem::path const & config_dir) Create the user pipeline directory if it does not exist. |
| std::string | sanitizePipelineFilename(std::string_view name) Convert a human-readable name into a safe filename stem. |
| std::vector< PipelineLibraryEntry > | listPipelineFiles(std::filesystem::path const & directory) List .json pipeline files in a directory. |
| rfl::Result< PipelineDescriptor > | loadPipelineDescriptorFromFile(std::filesystem::path const & filepath) Read and parse a PipelineDescriptor from disk. |
| rfl::Result< rfl::Nothing > | savePipelineDescriptorToFile(std::filesystem::path const & filepath, PipelineDescriptor const & descriptor) Write a PipelineDescriptor to disk as JSON. |
| rfl::Result< rfl::Nothing > | deletePipelineFile(std::filesystem::path const & filepath) Remove a pipeline file from the library. |
| PipelineStep | createPipelineStepFromRegistry(ElementRegistry const & registry, std::string const & transform_name, std::any const & params_any) Create PipelineStep using the factory registry. |
| rfl::Result< PipelineStep > | loadStepFromDescriptor(PipelineStepDescriptor const & descriptor) Load a single pipeline step from JSON descriptor. |
| rfl::Result< ReductionStep > | loadPreReductionFromDescriptor(PreReductionStepDescriptor const & descriptor) Load a pre-reduction from JSON descriptor. |
| rfl::Result< std::pair< std::string, std::any > > | loadRangeReductionFromDescriptor(RangeReductionStepDescriptor const & descriptor) Load a range reduction from JSON descriptor. |
| rfl::Result< TransformPipeline > | loadPipelineFromJson(std::string const & json_str) Load a complete pipeline from JSON string. |
| rfl::Result< TransformPipeline > | loadPipelineFromFile(std::string const & filepath) Load pipeline from JSON file. |
| std::string | savePipelineToJson(PipelineDescriptor const & descriptor) Save pipeline descriptor to JSON string. |
| rfl::Result< rfl::Nothing > | savePipelineToFile(std::string const & filepath, PipelineDescriptor const & descriptor) Save a pipeline descriptor to a JSON file. |
| rfl::Result< PipelineDescriptor > | loadPipelineDescriptorFromJsonFile(std::string const & filepath) Load a pipeline descriptor from a JSON file (parse only; does not build TransformPipeline). |
| std::unordered_map< std::type_index, std::function< PipelineStep(std::string const &, std::any const &)> > & | getPipelineStepFactoryRegistry() Registry of PipelineStep factory functions. |
| template <typename Params > void |
registerPipelineStepFactoryFor() Helper to register a PipelineStep factory for a parameter type. |
Types Documentation
enum DifferenceMethod
| Enumerator | Value | Description |
|---|---|---|
| Backward | data[i] - data[i - window] | |
| Central | (data[i + window] - data[i - window]) / (2 * window) | |
| Forward | data[i + window] - data[i] |
Difference method applied to each sample.
enum DifferenceEdgePolicy
| Enumerator | Value | Description |
|---|---|---|
| Skip | Omit samples where the window is incomplete (default). | |
| NaN | Fill with quiet_NaN(). | |
| Zero | Fill with 0. | |
| Clamp | Clamp missing neighbors to the first/last sample. |
Policy for handling samples where the differencing window is incomplete.
enum IntervalEventPoint
| Enumerator | Value | Description |
|---|---|---|
| start | Use interval.start. | |
| end | Use interval.end. | |
| center | Use (interval.start + interval.end) / 2. |
Which point within an interval becomes the output event time.
enum LineAngleMethod
| Enumerator | Value | Description |
|---|---|---|
| DirectPoints | ||
| PolynomialFit |
Angle calculation method.
enum LineCurvatureMethod
| Enumerator | Value | Description |
|---|---|---|
| PolynomialFit |
Curvature calculation method.
enum LinePointExtractionMethod
| Enumerator | Value | Description |
|---|---|---|
| Direct | ||
| Parametric |
Point extraction method.
enum LineResampleMethod
| Enumerator | Value | Description |
|---|---|---|
| FixedSpacing | Resample to target spacing between points. | |
| DouglasPeucker | Simplify using Douglas-Peucker algorithm. | |
| PolynomialSmooth | Smooth via parametric polynomial fit and resample. |
Line simplification algorithm selection.
enum LineSubsegmentMethod
| Enumerator | Value | Description |
|---|---|---|
| Direct | ||
| Parametric |
Subsegment extraction method.
enum SkeletonizeMethod
| Enumerator | Value | Description |
|---|---|---|
| ZhangSuen | Morphological thinning (Zhang–Suen), adapted from scikit-image. | |
| MedialAxis | Distance-transform medial axis, Felzenszwalb EDT + scikit-image thinning. |
Skeletonization algorithm selection.
enum PointCoordinateComponent
| Enumerator | Value | Description |
|---|---|---|
| X | ||
| Y |
Coordinate component to extract from each point.
enum PointReductionMethod
| Enumerator | Value | Description |
|---|---|---|
| First | ||
| Mean | ||
| Sum | ||
| Max | ||
| Min |
Method for reducing multiple points at a single time frame into a scalar.
enum SincWindowType
| Enumerator | Value | Description |
|---|---|---|
| Lanczos | ||
| Hann | ||
| Blackman |
Window function type for the sinc kernel.
enum BoundaryMode
| Enumerator | Value | Description |
|---|---|---|
| SymmetricExtension | ||
| ZeroPad |
Boundary handling mode for edge samples.
enum CARMethod
| Enumerator | Value | Description |
|---|---|---|
| Mean | Arithmetic mean across channels. | |
| Median | Median across channels (default; more robust to outliers). |
Method used to compute the cross-channel reference signal.
enum DeltaBoundaryPolicy
| Enumerator | Value | Description |
|---|---|---|
| NaN | Fill missing delta with NaN (default). | |
| Drop | Drop boundary rows from the output. | |
| Clamp | Clamp to the first/last row when computing the difference. | |
| Zero | Fill missing delta with zero. |
Policy for handling boundary rows where t-1 or t+1 is out-of-range.
enum BoundaryPolicy
| Enumerator | Value | Description |
|---|---|---|
| NaN | Fill missing neighbor features with NaN (default). | |
| Drop | Drop rows where any offset is out-of-range. | |
| Clamp | Clamp to the first/last row. | |
| Zero | Fill missing neighbor features with zero. |
Policy for handling boundary rows where a neighbor offset is out-of-range.
Functions Documentation
function analogDifference
std::shared_ptr< AnalogTimeSeries > analogDifference(
AnalogTimeSeries const & input,
AnalogDifferenceParams const & params,
ComputeContext const & ctx
)Compute backward, central, or forward difference on an AnalogTimeSeries.
Parameters:
- input Input analog time series
- params Differencing parameters
- ctx Compute context for progress/cancellation
Return: New AnalogTimeSeries with differenced values, or nullptr on validation failure or when Skip policy eliminates all samples
Precondition: params.window >= 1
Container signature: AnalogTimeSeries → AnalogTimeSeries
Each output sample is anchored at the same TimeFrameIndex as the corresponding input index. With Skip edge policy, boundary samples are omitted from output.
function analogEventThreshold
std::shared_ptr< DigitalEventSeries > analogEventThreshold(
AnalogTimeSeries const & input,
AnalogEventThresholdParams const & params,
ComputeContext const & ctx
)Detect threshold crossing events in an analog time series.
Parameters:
- input Input analog time series
- params Threshold parameters (value, direction, lockout)
- ctx Compute context for progress/cancellation
Return: Shared pointer to digital event series containing event times
This is a container-level transform because it has temporal dependencies: the lockout period requires looking at previous samples to determine if an event should be reported.
Container signature: AnalogTimeSeries → DigitalEventSeries
Algorithm:
- Iterate through time series samples
- Check if value crosses threshold (based on direction)
- If crossed and outside lockout period from last event, record event
- Report progress and check for cancellation
function analogHilbertPhase
std::shared_ptr< AnalogTimeSeries > analogHilbertPhase(
AnalogTimeSeries const & input,
AnalogHilbertPhaseParams const & params,
ComputeContext const & ctx
)Calculate instantaneous phase or amplitude using Hilbert transform.
Parameters:
- input Input analog time series
- params Hilbert transform parameters
- ctx Compute context for progress/cancellation
Return: Shared pointer to analog time series containing phase (radians) or amplitude
This is a container-level transform because it operates on the entire time series and handles discontinuities, chunked processing, and FFT-based computation that requires global context.
Container signature: AnalogTimeSeries → AnalogTimeSeries
Algorithm:
- Detect discontinuities and split into chunks
- For each chunk: a. Optionally apply bandpass filter b. Compute FFT c. Create analytic signal by zeroing negative frequencies d. Compute inverse FFT e. Extract phase (atan2) or amplitude (magnitude)
- Stitch chunks back together
- Report progress and check for cancellation
function analogToTensor
std::shared_ptr< TensorData > analogToTensor(
std::vector< std::shared_ptr< AnalogTimeSeries const > > const & channels,
AnalogToTensorParams const & params,
ComputeContext const & ctx
)Pack multiple AnalogTimeSeries channels into a single 2D TensorData.
Parameters:
- channels Non-empty vector of channels to pack
- params Parameters (channel_keys used as column names if sizes match)
- ctx Compute context for progress/cancellation/logging
Return: 2D TensorData (time × channels), or nullptr on validation failure
Precondition:
- channels must not be empty
- All channels must have identical sample counts
- All channels must share the same TimeFrame (pointer identity)
All channels must share the same TimeFrame (by pointer identity) and have the same sample count. Uses viewValues() for mmap-safe iteration.
function eventToInterval
std::shared_ptr< DigitalIntervalSeries > eventToInterval(
DigitalEventSeries const & input,
EventToIntervalParams const & params,
ComputeContext const & ctx
)Expand each event in a DigitalEventSeries into a window interval.
Parameters:
- input Input event series
- params Pre/post expansion sizes in TimeFrameIndex units
- ctx Compute context for progress/cancellation
Return: Shared pointer to overlapping DigitalIntervalSeries
Precondition: params.pre_expansion and params.post_expansion must be non-negative
Container signature: DigitalEventSeries -> DigitalIntervalSeries
Each event at TimeFrameIndex T produces one interval: [T - pre_expansion, T + post_expansion]
The output uses IntervalLayout::Overlapping and preserves the input TimeFrame.
function eventTimeForInterval
TimeFrameIndex eventTimeForInterval(
TimeFrameInterval const & interval,
IntervalEventPoint point
)Compute the event time for an interval at the selected alignment point.
Parameters:
- interval Input interval in TimeFrameIndex space
- point Which point within the interval to use
Return: Event time as int64_t TimeFrameIndex value
function intervalToEvent
std::shared_ptr< DigitalEventSeries > intervalToEvent(
DigitalIntervalSeries const & input,
IntervalToEventParams const & params,
ComputeContext const & ctx
)Extract one event per interval from a DigitalIntervalSeries.
Parameters:
- input Input interval series
- params Which point within each interval becomes the event time
- ctx Compute context for progress/cancellation
Return: Shared pointer to DigitalEventSeries with one event per input interval
Container signature: DigitalIntervalSeries -> DigitalEventSeries
Each interval produces one event at start, end, or center (integer division). The output preserves the input TimeFrame and does not copy source entity IDs.
function calculateLineAngle
float calculateLineAngle(
Line2D const & line,
LineAngleParams const & params
)Calculate the angle at a specified position along a line.
Parameters:
- line The line to calculate angle from
- params Parameters controlling the calculation (call validate() first for batch)
Return: float Angle in degrees (-180 to 180), or NaN if line has fewer than 2 points
Precondition: When method is PolynomialFit, polynomial_order >= 0 (enforcement: none)
function calculateLineAngleWithContext
float calculateLineAngleWithContext(
Line2D const & line,
LineAngleParams const & params,
ComputeContext const & ctx
)Context-aware version with progress reporting.
function flipLineBase
Line2D flipLineBase(
Line2D const & line,
LineBaseFlipParams const & params
)Flip a line’s base if it’s farther from the reference point than the end.
Parameters:
- line The line to potentially flip
- params Parameters containing the reference point
Return: Line2D The line, possibly with reversed point order
This is a unary element-level transform that takes a Line2D as input and returns a Line2D (possibly reversed).
The transform compares the distance from both endpoints (base = first point, end = last point) to the reference point. If the base is farther from the reference than the end, the line is reversed so the closer endpoint becomes the new base.
Use cases:
- Ensuring consistent whisker orientation (base always near face)
- Normalizing line direction based on a landmark point
When applied to containers:
Edge cases:
- Empty lines: Returned unchanged
- Single-point lines: Returned unchanged (cannot determine orientation)
- Equal distances: Line is NOT flipped (keeps original orientation)
function flipLineBaseWithContext
Line2D flipLineBaseWithContext(
Line2D const & line,
LineBaseFlipParams const & params,
ComputeContext const & ctx
)Context-aware version with progress reporting.
function clipLineAtReference
Line2D clipLineAtReference(
Line2D const & line,
Line2D const & reference_line,
LineClipParams const & params
)Clip a line at its intersection with a reference line.
Parameters:
- line The line to clip
- reference_line The reference line to clip against
- params Parameters controlling the clipping
Return: Line2D The clipped line (or original if no intersection)
This is a binary element-level transform that takes a line and a reference line as separate inputs, then returns the clipped line.
The V2 system supports this natively via [BinaryElementTransform] and tuple inputs. Uses 1:1 matching - each Line2D is paired with one reference Line2D at the same time.
function clipLineAtReferenceWithContext
Line2D clipLineAtReferenceWithContext(
Line2D const & line,
Line2D const & reference_line,
LineClipParams const & params,
ComputeContext const & ctx
)Context-aware version with progress reporting.
function calculateLineCurvature
float calculateLineCurvature(
Line2D const & line,
LineCurvatureParams const & params
)Calculate the curvature at a specified position along a line.
Parameters:
- line The line to calculate curvature from
- params Parameters controlling the calculation (call validate() first for batch)
Return: float Curvature value, or NaN if calculation fails
This is a unary element-level transform that takes a Line2D as input and returns the curvature value at the specified position along the line.
Curvature is calculated using the formula: k = |x’y’’ - y’x’‘| / (x’^2 + y’2)(3/2)
where x’, y’ are first derivatives and x’‘, y’’ are second derivatives of a parametric polynomial fit to the line.
When applied to containers:
- LineData → AnalogTimeSeries (one curvature value per timestamp)
For batch processing, call params.validate() once before processing to pre-compute clamped parameters.
function calculateLineCurvatureWithContext
float calculateLineCurvatureWithContext(
Line2D const & line,
LineCurvatureParams const & params,
ComputeContext const & ctx
)Context-aware version with progress reporting.
function extendLineAtReference
Line2D extendLineAtReference(
Line2D const & line,
Line2D const & reference_line,
LineExtendParams const & params
)Extend a line along a smoothed tangent until it hits a reference polyline.
Parameters:
- line The line to extend
- reference_line Reference polyline to intersect
- params Extension parameters
Return: Extended line, or the original line if no valid intersection is found
function extendLineAtReferenceWithContext
Line2D extendLineAtReferenceWithContext(
Line2D const & line,
Line2D const & reference_line,
LineExtendParams const & params,
ComputeContext const & ctx
)Context-aware version with progress reporting.
function calculateLineLength
float calculateLineLength(
Line2D const & line,
LineLengthParams const & params
)Calculate the total arc length of a Line2D.
Parameters:
- line The line to measure
- params Parameters (currently unused)
Return: Total arc length as a float
Computes the sum of Euclidean distances between consecutive points. Returns 0 for lines with fewer than 2 points.
When applied to containers:
- LineData → AnalogTimeSeries (one length per timestamp per line)
function calculateLineLengthWithContext
float calculateLineLengthWithContext(
Line2D const & line,
LineLengthParams const & params,
ComputeContext const & ctx
)Context-aware version with progress reporting and cancellation.
function pointToLineSegmentDistance2
float pointToLineSegmentDistance2(
Point2D< float > const & point,
Point2D< float > const & line_start,
Point2D< float > const & line_end
)Calculate squared distance from point to line segment.
Returns the squared Euclidean distance from a point to the closest point on a line segment.
function pointToLineMinDistance2
float pointToLineMinDistance2(
Point2D< float > const & point,
Line2D const & line
)Calculate minimum squared distance from point to entire line.
function calculateLineMinPointDistance
float calculateLineMinPointDistance(
Line2D const & line,
Point2D< float > const & point,
LineMinPointDistParams const & params
)Calculate distance from a single point to a line.
Parameters:
- line The line to measure distance from
- point The point to measure distance to
- params Parameters controlling the calculation
Return: float Distance (or squared distance if configured)
This is a binary element-level transform that takes a line and a single point as separate inputs, then returns the distance from the point to the line.
The V2 system supports this natively via [BinaryElementTransform] and tuple inputs. Uses 1:1 matching - each Line2D is paired with one Point2D at the same index.
function calculateLineMinPointDistanceWithContext
float calculateLineMinPointDistanceWithContext(
Line2D const & line,
Point2D< float > const & point,
LineMinPointDistParams const & params,
ComputeContext const & ctx
)Context-aware version with progress reporting.
function extractLinePoint
Point2D< float > extractLinePoint(
Line2D const & line,
LinePointExtractionParams const & params
)Extract a point at a specified position along a line.
Parameters:
- line The line to extract a point from
- params Parameters controlling the extraction (call validate() first for batch)
Return: Point2D
This is a unary element-level transform that takes a Line2D as input and returns a Point2D
Two extraction methods are supported:
- Direct: Use distance-based interpolation along the line
- Parametric: Fit a polynomial and evaluate at the specified position
When applied to containers:
For batch processing, call params.validate() once before processing to pre-compute clamped parameter values.
function extractLinePointWithContext
Point2D< float > extractLinePointWithContext(
Line2D const & line,
LinePointExtractionParams const & params,
ComputeContext const & ctx
)Context-aware version with progress reporting.
function resampleLine
Line2D resampleLine(
Line2D const & line,
LineResampleParams const & params
)Resample or simplify a line based on the selected algorithm.
Parameters:
- line The line to resample/simplify
- params Parameters specifying algorithm and settings
Return: Line2D The resampled/simplified line
This is a unary element-level transform that takes a Line2D as input and returns a resampled/simplified Line2D.
Algorithm descriptions:
FixedSpacing: Iterates through the polyline, placing new points at target_spacing intervals. Interpolates between original points as needed. Preserves first and last points.
DouglasPeucker: Recursively simplifies a polyline by removing points that are within epsilon distance of the line segment between two endpoints. Preserves overall shape while reducing point count.
PolynomialSmooth: Fits parametric polynomials x(t), y(t) with arc-length parameterization, then generates evenly-spaced points along the fitted curve. Falls back to FixedSpacing resampling if fitting fails.
When applied to containers:
Edge cases:
- Empty lines: Returned unchanged (empty)
- Single-point lines: Returned unchanged (cannot resample)
- Two-point lines: Returned unchanged (minimal representation)
function resampleLineWithContext
Line2D resampleLineWithContext(
Line2D const & line,
LineResampleParams const & params,
ComputeContext const & ctx
)Context-aware version with progress reporting.
function extractLineSubsegment
Line2D extractLineSubsegment(
Line2D const & line,
LineSubsegmentParams const & params
)Extract a subsegment from a line between specified fractional positions.
Parameters:
- line The line to extract subsegment from
- params Parameters controlling the extraction
Return: Line2D The extracted subsegment
This is a unary element-level transform that takes a Line2D as input and returns a Line2D containing the extracted subsegment.
Two extraction methods are supported:
- Direct: Extracts points directly from the original line at the specified positions. With preserve_original_spacing=true, keeps original points within the range. With preserve_original_spacing=false, interpolates start/end points.
- Parametric: Fits a parametric polynomial to the line and generates a new set of uniformly-spaced points along the subsegment.
When applied to containers:
Edge cases:
- Empty lines: Returned unchanged (empty)
- Single-point lines: Returned unchanged (single point)
- Invalid range (start >= end): Returns empty line
- Insufficient points for polynomial: Falls back to Direct method
function extractLineSubsegmentWithContext
Line2D extractLineSubsegmentWithContext(
Line2D const & line,
LineSubsegmentParams const & params,
ComputeContext const & ctx
)Context-aware version with progress reporting.
function calculateMaskArea
float calculateMaskArea(
Mask2D const & mask,
MaskAreaParams const & params
)Calculate area of a single mask.
Parameters:
- mask Input mask
- params Parameters (currently unused)
Return: Area as number of pixels in the mask
This is the element-level transform: Mask2D → float
When applied to containers:
- MaskData (ragged) → RaggedAnalogTimeSeries
- SingleMaskData (hypothetical) → AnalogTimeSeries
The raggedness comes from the container structure, not the element output type.
function calculateMaskAreaWithContext
float calculateMaskAreaWithContext(
Mask2D const & mask,
MaskAreaParams const & params,
ComputeContext const & ctx
)Calculate area with context support.
Demonstrates progress reporting and cancellation checking.
function calculateMaskCentroid
Point2D< float > calculateMaskCentroid(
Mask2D const & mask,
MaskCentroidParams const & params
)Calculate the centroid (center of mass) of a single mask.
Parameters:
- mask Input mask containing pixel coordinates
- params Parameters (currently unused but available for future extensions)
Return: Centroid as Point2D
Note: For empty masks, returns Point2D
This is the element-level transform: Mask2D → Point2D
When applied to containers:
The centroid is calculated as the arithmetic mean of all pixel coordinates, assuming uniform density across the mask.
function calculateMaskCentroidWithContext
Point2D< float > calculateMaskCentroidWithContext(
Mask2D const & mask,
MaskCentroidParams const & params,
ComputeContext const & ctx
)Calculate the centroid with context support for progress/cancellation.
Parameters:
- mask Input mask
- params Parameters
- ctx Compute context for progress reporting and cancellation
Return: Centroid as Point2D
Demonstrates progress reporting and cancellation checking for long-running operations on large masks.
function applyMedianFilter
Mask2D applyMedianFilter(
Mask2D const & mask,
MaskMedianFilterParams const & params
)Apply median filtering to a single mask element.
Parameters:
- mask Input mask points
- params Window size and optional full-canvas dimensions
Return: Filtered mask, or empty mask if input is empty or filtering removes all pixels
Element-level transform: Mask2D → Mask2D
Rasterizes the mask to a binary image, applies median filtering to remove salt-and-pepper noise and smooth jagged boundaries, then converts back to mask points.
When canvas dimensions are omitted, the raster is sized to the mask bounding box plus background border padding derived from window_size.
When applied to containers:
function applyMedianFilterWithContext
Mask2D applyMedianFilterWithContext(
Mask2D const & mask,
MaskMedianFilterParams const & params,
ComputeContext const & ctx
)Apply median filtering with progress reporting and cancellation support.
Parameters:
- mask Input mask points
- params Window size and optional full-canvas dimensions
- ctx Compute context for progress and cancellation
Return: Filtered mask, or empty mask on cancellation or empty input
function skeletonizeMask
Mask2D skeletonizeMask(
Mask2D const & mask,
MaskSkeletonizeParams const & params
)Parameters for mask skeletonization.
Parameters:
- mask Input mask points
- params Optional full-canvas dimensions; when unset, canvas is sized to mask extents
Return: Skeletonized mask, or empty mask if input is empty or skeletonization yields no pixels
Uses reflect-cpp for automatic JSON serialization/deserialization.
Example JSON: ```json
{}
Optional canvas dimensions (when both are positive): ```json
{
"image_width": 640,
"image_height": 480
}
json { “method”: “MedialAxis”, “image_width”: 640, “image_height”: 480 } ``` */ struct MaskSkeletonizeParams { / Thinning algorithm to apply SkeletonizeMethod method = SkeletonizeMethod::ZhangSuen;
/ Canvas width in pixels; <= 0 derives size from mask point extents int image_width = -1;
/ Canvas height in pixels; <= 0 derives size from mask point extents int image_height = -1; };
/**
Skeletonize a single mask element
Element-level transform: Mask2D → Mask2D
Converts the mask to a binary image on a canvas, applies the selected skeletonization algorithm, and converts the result back to mask points.
When canvas dimensions are omitted, the raster is sized to the mask bounding box plus a one-pixel background border so thinning is not biased at the image edge.
When applied to containers:
function skeletonizeMaskWithContext
Mask2D skeletonizeMaskWithContext(
Mask2D const & mask,
MaskSkeletonizeParams const & params,
ComputeContext const & ctx
)Skeletonize a mask with progress reporting and cancellation support.
Parameters:
- mask Input mask points
- params Optional full-canvas dimensions; when unset, canvas is sized to mask extents
- ctx Compute context for progress and cancellation
Return: Skeletonized mask, or empty mask on cancellation or empty input
function maskToLine
Line2D maskToLine(
Mask2D const & mask,
MaskToLineParams const & params
)Order mask points into a directed line polyline.
Parameters:
- mask Input mask points
- params Reference point and subsampling settings
Return: Ordered line, or empty line if input is empty
Element-level transform: Mask2D → Line2D
Converts unordered mask pixels into an ordered Line2D using [order_line](/api_generated/Files/order__line_8hpp.md#function-order-line). For thick masks, chain with SkeletonizeMask first. For post-processing, chain with RemoveLineOutliers and/or ResampleLine.
When applied to containers:
function maskToLineWithContext
Line2D maskToLineWithContext(
Mask2D const & mask,
MaskToLineParams const & params,
ComputeContext const & ctx
)Order mask points into a line with progress reporting and cancellation support.
Parameters:
- mask Input mask points
- params Reference point and subsampling settings
- ctx Compute context for progress and cancellation
Return: Ordered line, or empty line on cancellation or empty input
function pointCoordinate
std::shared_ptr< RaggedAnalogTimeSeries > pointCoordinate(
PointData const & input,
PointCoordinateParams const & params,
ComputeContext const & ctx
)Project PointData x or y coordinates into RaggedAnalogTimeSeries.
Parameters:
- input Point data with one or more points at each time
- params Coordinate selection
- ctx Compute context for progress/cancellation
Return: Ragged analog series containing the selected coordinate values
Container signature: PointData -> RaggedAnalogTimeSeries. Each point at a time contributes one coordinate value at the same time.
function pointCoordinateReduction
std::shared_ptr< AnalogTimeSeries > pointCoordinateReduction(
PointData const & input,
PointCoordinateReductionParams const & params,
ComputeContext const & ctx
)Project PointData x or y coordinates into an AnalogTimeSeries, collapsing multiple points at a single time.
Parameters:
- input Point data with one or more points at each time
- params Coordinate selection and reduction method
- ctx Compute context for progress/cancellation
Return: Analog series containing the reduced coordinate values
Container signature: PointData -> AnalogTimeSeries.
function pruneOverlappingIntervals
std::shared_ptr< DigitalIntervalSeries > pruneOverlappingIntervals(
DigitalIntervalSeries const & input,
PruneOverlappingIntervalsParams const & params,
ComputeContext const & ctx
)Greedy keep-first pruning of overlapping intervals.
Parameters:
- input Input interval series (any layout)
- params Pruning parameters (currently unused)
- ctx Compute context for progress/cancellation
Return: Shared pointer to disjoint DigitalIntervalSeries with non-overlapping intervals
Container signature: DigitalIntervalSeries -> DigitalIntervalSeries
Uses a left-to-right scan: keeps the first interval, then for each subsequent interval checks whether its start overlaps or touches the end of the last kept interval. Overlapping intervals are skipped.
The output uses IntervalLayout::Disjoint and preserves the input TimeFrame. Intervals must be sorted by start time (guaranteed by DigitalIntervalSeries).
function removeLineOutliers
Line2D removeLineOutliers(
Line2D const & line,
RemoveLineOutliersParams const & params
)Remove geometric outlier points from an ordered line.
Parameters:
- line Input ordered line
- params Error threshold and polynomial order
Return: Filtered line, or input unchanged if too few points or line is empty
Element-level transform: Line2D → Line2D
Iteratively fits a parametric polynomial and removes points that deviate more than error_threshold pixels from the fitted curve. Requires at least (polynomial_order + 2) points; otherwise returns the input unchanged.
When applied to containers:
function removeLineOutliersWithContext
Line2D removeLineOutliersWithContext(
Line2D const & line,
RemoveLineOutliersParams const & params,
ComputeContext const & ctx
)Remove line outliers with progress reporting and cancellation support.
Parameters:
- line Input ordered line
- params Error threshold and polynomial order
- ctx Compute context for progress and cancellation
Return: Filtered line, or input unchanged on cancellation
function sincInterpolation
std::shared_ptr< AnalogTimeSeries > sincInterpolation(
AnalogTimeSeries const & input,
SincInterpolationParams const & params,
ComputeContext const & ctx
)Apply band-limited sinc interpolation to upsample an AnalogTimeSeries.
Parameters:
- input Input analog time series with N samples
- params Interpolation parameters
- ctx Compute context for progress/cancellation
Return: Shared pointer to a new AnalogTimeSeries with (N-1)*factor+1 samples, or nullptr if input is empty or params are invalid
Precondition: params.upsampling_factor >= 1
For each output sample position m in [0, M-1] where M = (N-1)*factor + 1:
- Compute fractional input position: x = m / factor
- For each input sample n in [floor(x) - K, floor(x) + K]: accumulate sinc(x - n) * window(x - n) * input[n]
- Output sample = weighted sum
Where K = kernel_half_width and sinc(t) = sin(pit) / (pit), sinc(0) = 1.
function sumReduction
std::vector< float > sumReduction(
std::span< float const > values,
SumReductionParams const & params
)Sum all floats at a given time point into a single float.
Parameters:
- values All float values at a single time point
- params Parameters (currently unused)
Return: Vector containing single summed value
This is a time-grouped transform: Range
Example:
- Input at time T: [10.0, 5.0, 3.0]
- Output at time T: [18.0]
Use case: Reducing RaggedAnalogTimeSeries → AnalogTimeSeries
function sumReductionWithContext
std::vector< float > sumReductionWithContext(
std::span< float const > values,
SumReductionParams const & params,
ComputeContext const & ctx
)Context-aware version with progress reporting.
function tensorCAR
std::shared_ptr< TensorData > tensorCAR(
TensorData const & input,
TensorCARParams const & params,
ComputeContext const & ctx
)Apply Common Average Reference to a multi-channel TensorData.
Parameters:
- input 2D TensorData (time × channels)
- params CAR parameters
- ctx Compute context for progress/cancellation/logging
Return: CAR-referenced TensorData with the same shape as input, or nullptr on failure
Precondition:
- input.ndim() == 2
- input.numRows() >= 1
- input.numColumns() >= 1
- exclude_channels does not exclude all channels
Container signature: TensorData → TensorData
For each time point t, computes a reference value r(t) as the mean or median across all non-excluded channels. The reference is then subtracted from every channel at every time point: result[t, c] = input[t, c] - r(t)
The input must be 2D with shape (time × channels). The RowDescriptor (TimeFrameIndex, Interval, or Ordinal) and TimeFrame are preserved intact.
function tensorCentralDifference
std::shared_ptr< TensorData > tensorCentralDifference(
TensorData const & input,
TensorCentralDifferenceParams const & params,
ComputeContext const & ctx
)Append central-difference columns to a time-indexed TensorData.
Parameters:
- input 2D time-indexed TensorData
- params Central-difference parameters
- ctx Compute context for progress/cancellation
Return: Augmented TensorData, or nullptr on validation failure
Precondition:
- input.ndim() == 2
- input.rowType() == RowType::TimeFrameIndex
Container signature: TensorData → TensorData
The input must be 2D with RowType::TimeFrameIndex. For each original column a new column is appended containing the central difference: delta_c[t] = (value_c[t+1] - value_c[t-1]) / 2
Output column layout (include_original=true): [original cols] [delta_col0] [delta_col1] …
Delta columns are named “{original_col}_delta” (e.g. “feat1_delta”).
function tensorICA
std::shared_ptr< TensorData > tensorICA(
TensorData const & input,
TensorICAParams const & params,
ComputeContext const & ctx
)Apply ICA (RADICAL) to a TensorData.
Parameters:
- input 2D TensorData (observations × features)
- params ICA parameters
- ctx Compute context for progress/cancellation
Return: Transformed TensorData, or nullptr on failure
Note:
- ICA does not reduce dimensionality — the output has the same number of features as the input. Each output column is an independent component.
- RADICAL scales quadratically in the number of dimensions. Consider reducing dimensionality with PCA first for high-dimensional data.
Container signature: TensorData → TensorData
The input must be 2D. The output has the same number of columns as the input, with columns named “IC1”, “IC2”, etc. The input’s RowDescriptor is preserved: if the input has TimeFrameIndex rows, the output also has TimeFrameIndex rows with the same time indices.
function tensorPCA
std::shared_ptr< TensorData > tensorPCA(
TensorData const & input,
TensorPCAParams const & params,
ComputeContext const & ctx
)Apply PCA dimensionality reduction to a TensorData.
Parameters:
- input 2D TensorData (observations × features)
- params PCA parameters
- ctx Compute context for progress/cancellation
Return: Reduced TensorData, or nullptr on failure
Container signature: TensorData → TensorData
The input must be 2D. The output has n_components columns named “PC1”, “PC2”, etc. The input’s RowDescriptor is preserved: if the input has TimeFrameIndex rows, the output also has TimeFrameIndex rows with the same time indices.
function tensorRobustPCA
std::shared_ptr< TensorData > tensorRobustPCA(
TensorData const & input,
TensorRobustPCAParams const & params,
ComputeContext const & ctx
)Apply Robust PCA dimensionality reduction to a TensorData.
Parameters:
- input 2D TensorData (observations x features)
- params Robust PCA parameters
- ctx Compute context for progress/cancellation
Return: Reduced TensorData, or nullptr on failure
Container signature: TensorData -> TensorData
The input must be 2D. The output has n_components columns named “RPCA1”, “RPCA2”, etc. The input’s RowDescriptor is preserved: if the input has TimeFrameIndex rows, the output also has TimeFrameIndex rows with the same time indices.
function tensorTemporalNeighbors
std::shared_ptr< TensorData > tensorTemporalNeighbors(
TensorData const & input,
TensorTemporalNeighborParams const & params,
ComputeContext const & ctx
)Augment a time-indexed TensorData with neighbor feature columns.
Parameters:
- input 2D time-indexed TensorData
- params Temporal neighbor parameters
- ctx Compute context for progress/cancellation
Return: Augmented TensorData, or nullptr on validation failure
Precondition:
- input.ndim() == 2
- input.rowType() == RowType::TimeFrameIndex
Container signature: TensorData → TensorData
The input must be 2D with RowType::TimeFrameIndex. Offsets are generated from the lag_range/lag_step and lead_range/lead_step parameters. For each offset, the features from the neighbor row at position (current_row + offset) in sorted time order are appended as new columns.
Output column layout: [original cols (if include_original)] [offset_1 cols] [offset_2 cols] … Shifted columns are named “{original_col}_lag{offset}” (e.g. “feat1_lag-1”).
function tensorToAnalog
std::vector< std::shared_ptr< AnalogTimeSeries > > tensorToAnalog(
TensorData const & input,
TensorToAnalogParams const & params,
ComputeContext const & ctx
)Extract columns from a 2D TensorData as independent AnalogTimeSeries.
Parameters:
- input 2D TensorData to extract columns from
- params Parameters (columns to extract, output prefix)
- ctx Compute context for progress/cancellation/logging
Return: Vector of AnalogTimeSeries (one per selected column), empty on failure
Precondition:
- input must be 2D
- All column indices in params.columns must be in [0, input.numColumns())
Each selected column is copied into a new owning AnalogTimeSeries. Time indices and TimeFrame are preserved from the source TensorData when the tensor has TimeFrameIndex rows.
function tensorTSNE
std::shared_ptr< TensorData > tensorTSNE(
TensorData const & input,
TensorTSNEParams const & params,
ComputeContext const & ctx
)Apply t-SNE dimensionality reduction to a TensorData.
Parameters:
- input 2D TensorData (observations × features)
- params t-SNE parameters
- ctx Compute context for progress/cancellation
Return: Reduced TensorData, or nullptr on failure
Container signature: TensorData → TensorData
The input must be 2D. The output has n_components columns named “tSNE1”, “tSNE2”, etc. The input’s RowDescriptor is preserved: if the input has TimeFrameIndex rows, the output also has TimeFrameIndex rows with the same time indices.
function tensorWhitening
std::shared_ptr< TensorData > tensorWhitening(
TensorData const & input,
TensorWhiteningParams const & params,
ComputeContext const & ctx
)Apply robust ZCA whitening to the included channels of a 2D tensor.
Parameters:
- input 2D TensorData with shape (time, channel)
- params Whitening parameters
- ctx Compute context for progress, logging, and cancellation
Return: Whitened TensorData on success, or nullptr on validation/backend failure
Precondition:
- input.ndim() == 2
- input.numRows() >= 2
- input.numColumns() >= 1
- epsilon > 0
- exclude_channels does not exclude all channels
The input is interpreted as time x channels. Included channels are median- centered, optionally filtered by a MAD-based clean-sample mask for covariance estimation, whitened with a ZCA matrix, and optionally rescaled in amplitude. Excluded channels are passed through unchanged.
The transform always uses the LibTorch compute/storage path so the result is LibTorch-backed on both CPU and GPU builds.
function loadParametersForTransform
std::any loadParametersForTransform(
std::string const & transform_name,
std::string const & json_str
)function loadParametersFromJson
template <typename ParamsT >
rfl::Result< ParamsT > loadParametersFromJson(
std::string const & json_str
)function loadParametersFromFile
template <typename ParamsT >
rfl::Result< ParamsT > loadParametersFromFile(
std::string const & file_path
)Load parameters from JSON file.
Parameters:
- file_path Path to JSON file
Template Parameters:
- ParamsT Parameter type
Return: Result containing parameters or error
function saveParametersToJson
template <typename ParamsT >
std::string saveParametersToJson(
ParamsT const & params
)Save parameters to JSON string.
Parameters:
- params Parameters to save
Template Parameters:
- ParamsT Parameter type
Return: JSON string representation
function saveParametersToFile
template <typename ParamsT >
bool saveParametersToFile(
ParamsT const & params,
std::string const & file_path,
bool pretty_print =true
)Save parameters to JSON file.
Parameters:
- params Parameters to save
- file_path Path to output file
- pretty_print Whether to pretty-print the JSON (default: true)
Template Parameters:
- ParamsT Parameter type
Return: true if saved successfully
function defaultUserPipelineDirectory
std::filesystem::path defaultUserPipelineDirectory(
std::filesystem::path const & config_dir
)Default subdirectory for user TransformsV2 pipelines under a config root.
Parameters:
- config_dir Application config directory (e.g. StateManager::configDir())
Return: config_dir / “pipelines” / “transforms_v2”
function ensureUserPipelineDirectory
rfl::Result< std::filesystem::path > ensureUserPipelineDirectory(
std::filesystem::path const & config_dir
)Create the user pipeline directory if it does not exist.
Parameters:
- config_dir Application config directory
Return: Success, or error message if creation failed
function sanitizePipelineFilename
std::string sanitizePipelineFilename(
std::string_view name
)Convert a human-readable name into a safe filename stem.
Parameters:
- name Proposed pipeline name (may contain spaces or punctuation)
Return: Non-empty filesystem-safe stem; falls back to “pipeline” if empty after sanitization
function listPipelineFiles
std::vector< PipelineLibraryEntry > listPipelineFiles(
std::filesystem::path const & directory
)List .json pipeline files in a directory.
Parameters:
- directory Directory to scan (need not exist; returns empty vector)
Return: Entries sorted by display_name then id
function loadPipelineDescriptorFromFile
rfl::Result< PipelineDescriptor > loadPipelineDescriptorFromFile(
std::filesystem::path const & filepath
)Read and parse a PipelineDescriptor from disk.
Parameters:
- filepath Path to a JSON file
Return: Parsed descriptor or error
function savePipelineDescriptorToFile
rfl::Result< rfl::Nothing > savePipelineDescriptorToFile(
std::filesystem::path const & filepath,
PipelineDescriptor const & descriptor
)Write a PipelineDescriptor to disk as JSON.
Parameters:
- filepath Destination path (parent directories are not created)
- descriptor Descriptor to serialize
Return: Success or error
function deletePipelineFile
rfl::Result< rfl::Nothing > deletePipelineFile(
std::filesystem::path const & filepath
)Remove a pipeline file from the library.
Parameters:
- filepath Path to delete
Return: Success or error
function createPipelineStepFromRegistry
PipelineStep createPipelineStepFromRegistry(
ElementRegistry const & registry,
std::string const & transform_name,
std::any const & params_any
)Create PipelineStep using the factory registry.
Parameters:
- registry Element registry (for metadata lookup)
- transform_name Transform name
- params_any Type-erased parameters
Return: PipelineStep with correctly typed parameters
Looks up the appropriate factory based on parameter type from metadata.
function loadStepFromDescriptor
rfl::Result< PipelineStep > loadStepFromDescriptor(
PipelineStepDescriptor const & descriptor
)Load a single pipeline step from JSON descriptor.
Parameters:
- descriptor Step descriptor from JSON
Return: rfl::Result
This function:
- Validates that transform_name exists in the registry
- Loads parameters using the registry’s automatic deserializer
- Creates a PipelineStep using the factory registry
function loadPreReductionFromDescriptor
rfl::Result< ReductionStep > loadPreReductionFromDescriptor(
PreReductionStepDescriptor const & descriptor
)Load a pre-reduction from JSON descriptor.
Parameters:
- descriptor Pre-reduction step descriptor from JSON
Return: rfl::Result
This function:
- Validates that reduction_name exists in RangeReductionRegistry
- Loads parameters using the registry’s automatic deserializer
- Returns a ReductionStep ready to be added to the pipeline
function loadRangeReductionFromDescriptor
rfl::Result< std::pair< std::string, std::any > > loadRangeReductionFromDescriptor(
RangeReductionStepDescriptor const & descriptor
)Load a range reduction from JSON descriptor.
Parameters:
- descriptor Range reduction descriptor from JSON
Return: rfl::Result containing (name, params_any) pair or error message
This function:
- Validates that reduction_name exists in RangeReductionRegistry
- Loads parameters using the registry’s automatic deserializer
- Returns metadata needed to configure the pipeline’s range reduction
function loadPipelineFromJson
rfl::Result< TransformPipeline > loadPipelineFromJson(
std::string const & json_str
)Load a complete pipeline from JSON string.
Parameters:
- json_str JSON string containing pipeline descriptor
Return: rfl::Result
This function parses the JSON, validates all steps, and creates a TransformPipeline with properly typed parameters.
Example usage: ```cpp
auto pipeline_result = loadPipelineFromJson(json_str); if (pipeline_result) { auto pipeline = pipeline_result.value(); // Use pipeline… } else { std::cerr << “Error:” << pipeline_result.error()->what() << std::endl; }
### function loadPipelineFromFile
```cpp
rfl::Result< TransformPipeline > loadPipelineFromFile(
std::string const & filepath
)
Load pipeline from JSON file.
Parameters:
- filepath Path to JSON file
Return: rfl::Result
function savePipelineToJson
std::string savePipelineToJson(
PipelineDescriptor const & descriptor
)Save pipeline descriptor to JSON string.
Parameters:
- descriptor Pipeline descriptor to save
Return: std::string JSON representation
Note: This saves the descriptor, not the executable pipeline. Parameter values are preserved but executor functions are not serialized.
function savePipelineToFile
rfl::Result< rfl::Nothing > savePipelineToFile(
std::string const & filepath,
PipelineDescriptor const & descriptor
)Save a pipeline descriptor to a JSON file.
Parameters:
- filepath Destination file path (parent directories are not created)
- descriptor Pipeline descriptor to write
Return: Success or error message
function loadPipelineDescriptorFromJsonFile
rfl::Result< PipelineDescriptor > loadPipelineDescriptorFromJsonFile(
std::string const & filepath
)Load a pipeline descriptor from a JSON file (parse only; does not build TransformPipeline).
Parameters:
- filepath Path to JSON file
Return: Parsed descriptor or error
function getPipelineStepFactoryRegistry
inline std::unordered_map< std::type_index, std::function< PipelineStep(std::string const &, std::any const &)> > & getPipelineStepFactoryRegistry()Registry of PipelineStep factory functions.
Maps type_index -> factory function that creates PipelineStep from std::any. Factories are registered automatically via static initialization when parameter types are used with RegisterTransform.
function registerPipelineStepFactoryFor
template <typename Params >
inline void registerPipelineStepFactoryFor()Helper to register a PipelineStep factory for a parameter type.
Call this once for each parameter type to register its factory. Template automatically deduces the parameter type.
Updated on 2026-11-13 at 20:25:41 +0000