Module processing_utils

Source
Expand description

A module providing functionality for detecting and handling outliers and ectopic beats in a series of RR intervals.

It defines the RRIntervals struct which contains a vector of RR intervals, and optional fields to store indices of detected outliers and ectopic beats. The module also provides a trait DetectOutliers which can be implemented to detect outliers and ectopic beats using custom methods, while default implementations for detecting outliers and ectopic beats using common algorithms are also provided. The module includes methods for removing detected outliers and ectopics from the RR intervals data.

§Key Components:

  • RRIntervals: The main struct representing a collection of RR intervals and optional outlier/ectopic detections.
  • DetectOutliers: A trait for detecting outliers and ectopics with customizable implementations.
  • EctopicMethod: An enum that defines different methods for detecting ectopic beats in RR intervals.

§Features:

  • Detecting Outliers: Outliers in the RR intervals are detected by comparing each interval to a provided range (lowest_rr, highest_rr).
  • Detecting Ectopics: Ectopic beats are detected using methods like the Karlsson method, which compares the mean of adjacent intervals.
  • Flexible Customization: Users can implement their own methods for detecting outliers and ectopics by implementing the DetectOutliers trait.
  • Removing Outliers and Ectopics: Detected outliers and ectopics can be removed from the data using the remove_outliers_ectopics method, leaving only the valid RR intervals.

§Example Usage:

use cardio_rs::processing_utils::{RRIntervals, EctopicMethod, DetectOutliers};

let mut rr_intervals = RRIntervals::new(vec![800.0, 850.0, 3000.0, 600.0, 800.0]);
rr_intervals.detect_outliers(&300.0, &2000.0);  // Detect outliers based on specified range
rr_intervals.detect_ectopics(EctopicMethod::Karlsson);  // Detect ectopic beats using the Karlsson method
rr_intervals.remove_outliers_ectopics();  // Remove outliers and ectopics from the RR intervals data

§Trait and Struct Documentation:

  • RRIntervals<T>: A struct representing a sequence of RR intervals along with optional detected outliers and ectopics.
  • DetectOutliers<T>: A trait for detecting outliers and ectopics. Custom implementations can be provided by the user.
  • EctopicMethod: An enum for specifying different methods to detect ectopic beats (currently only Karlsson is supported).

Structs§

RRIntervals
Struct representing RR intervals and associated outlier and ectopic detection results.

Enums§

EctopicMethod
Enum representing different methods for detecting ectopic beats in RR intervals.

Traits§

AnalysisPipeline
A trait for processing HRV data through an analysis pipeline.
DetectOutliers
Trait for detecting outliers and ectopics in RR intervals.