sqatools

signal_quality

check_morph(sig, peaks_locs, troughs_locs, sampling_rate)[source]

Checks for ranges of morphological features.

Rule 1: Systolic phase duration(rise time): 0.08 to 0.49 s Rule 2: Ratio of systolic phase duration to diastolic phase duration: max 1.1 Rule 3: Pulse wave duration: 0.27 to 2.4 s Rule 4: Variation in PWD and SP: 33-300% Rule 5: Variation in PWA: 25-400% (Pulse wave amplitude: a threshold which was set heuristically)

Parameters:
  • peaks_locs (Array) – Array of peak locations.

  • peaks_amps (Array) – Array of peak amplitudes.

  • troughs_locs (Array) – Array of trough locations.

  • troughs_amps (Array) – Array of trough amplitudes.

  • sampling_rate (float) – Sampling rate of the input signal.

  • sig (_SupportsArray[dtype] | _NestedSequence[_SupportsArray[dtype]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) –

Returns:

Dictionary of decisions.

Return type:

dict

check_phys(peaks_locs, sampling_rate)[source]

Checks for physiological viability.

Rule 1: Average HR should be between 40-180 bpm (up to 300 bpm in the case of exercise) Rule 2: Maximum P-P interval: 1.5 seconds. Allowing for a single missing beat, it is 3 seconds Rule 3: Maximum P-P interval / minimum P-P interval ratio: 10 of the signal length for a short signal.

For 10 seconds signal, it is 1.1; allowing for a single missing beat, it is 2.2

Parameters:
  • peaks_locs (ArrayLike) – Array of peak locations.

  • sampling_rate (float) – Sampling rate of the input signal.

Returns:

Dictionary of decisions.

Return type:

dict

detect_clipped_segments(sig, threshold_pos, threshold_neg=None)[source]

Detects clipped segments in a signal.

Parameters:
  • sig (ArrayLike) – Signal to be analyzed (ECG or PPG).

  • threshold_pos (float) – Threshold for positive clipping

  • threshold_neg (float, optional) – Threshold for negative clipping. Defaults to None.

Returns:

Dictionary of boundaries of clipped segments.

Return type:

list

detect_flatline_segments(sig, min_duration, change_threshold)[source]

Detects flatline segments in a signal.

Parameters:
  • sig (ArrayLike) – Signal to be analyzed (ECG or PPG).

  • min_duration (float) – Mimimum duration of flat segments for flatline detection.

  • change_threshold (float) – Threshold for change in signal amplitude.

Returns:

List of boundaries of flatline segments.

Return type:

list

template_matching(sig, peaks_locs, corr_th=0.9)[source]

Applies template matching method for signal quality assessment.

Parameters:
  • sig (ArrayLike) – Signal to be analyzed.

  • peaks_locs (ArrayLike) – Peak locations (Systolic peaks for PPG signal, R peaks for ECG signal).

  • corr_th (float, optional) – Threshold for the correlation coefficient above which the signal is considered to be valid. Defaults to CORR_TH.

Returns:

Correlation coefficient and the decision

Return type:

Tuple[float,bool]