XTOS / OPEN SOURCE REAL-TIME SYSTEMOPEN SOURCE · VERSION 0.9.0 · BUILD FROM SOURCE
libxtos-signalxtos_signal_p300_quality_gate

xtos_signal_p300_quality_gate

Validates P300 trial fields and summarizes detection rate, mean z, latency deviation, and passed.

On this page

Declaration

c
#include <xtos/signal.h>

int xtos_signal_p300_quality_gate(const struct xtos_p300_feature *trials,
                                  size_t trial_count,
                                  size_t min_valid_trials,
                                  double min_detection_rate,
                                  double min_mean_z_score,
                                  double max_latency_stddev_ms,
                                  struct xtos_p300_quality *result);

Parameters

ParameterTypeDescription
trialsconst struct xtos_p300_feature *Non-NULL trial array with at least trial_count entries.
trial_countsize_tNumber of trials, greater than zero.
min_valid_trialssize_tMinimum valid trials required to pass, greater than zero.
min_detection_ratedoubleFinite threshold in [0,1].
min_mean_z_scoredoubleFinite lower bound for mean z score; negative values are allowed.
max_latency_stddev_msdoubleFinite nonnegative latency standard-deviation limit in milliseconds.
resultstruct xtos_p300_quality *Non-NULL caller-provided output structure.

Output fields

FieldTypeMeaning
trials_totalsize_tTotal number of input trials.
trials_validsize_tNumber of trials that pass field-consistency checks.
trials_detectedsize_tNumber of valid trials whose detected flag is 1.
trials_rejectedsize_tNumber of trials rejected by validity checks.
detection_ratedoubletrials_detected / trials_valid; 0 when there are no valid trials.
mean_peak_z_scoredoubleMean peak_z_score across valid trials.
mean_peak_latency_msdoubleMean peak latency across valid trials, in milliseconds.
peak_latency_stddev_msdoublePopulation standard deviation of valid-trial latency, in milliseconds.
passedintWhether all gate conditions pass; 1 when passed, otherwise 0.

Return value

Returns 0 when arguments are valid and statistics complete, even when passed=0; returns -1 for invalid arguments.

Errors

errnoCondition
EINVALtrials or result is NULL, a count is zero, min_detection_rate is outside [0,1], any threshold is non-finite, or max_latency_stddev_ms is negative.

Notes

  • Each trial is checked for finite fields, stddev, z consistency with amplitude/stddev, energy lower bound, and detected=0/1; any rejected trial makes passed=0.
  • Statistics use population latency standard deviation among valid trials; with no valid trial the function still returns 0 with passed=0.
  • The function allocates no memory and does not modify trials; the caller owns result.

Example

Source

This reference describes headers and implementation at OpenXTOS commit dd313955ad57542bcd2af8827157d1bbd0cf5e83.