biopsykit.signals.icg.event_extraction package

Module for ICG event extraction.

class biopsykit.signals.icg.event_extraction.BPointExtractionArbol2017IsoelectricCrossings(handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionArbol2017IsoelectricCrossings algorithm instance.

Parameters

handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

How to handle failing event extraction. Must be one of:

  • "warn": issue a warning and set the event to NaN,

  • "raise": raise an EventExtractionError, or

  • "ignore": continue silently.

Default: "warn".

extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

This algorithm extracts B-points based on the last isoelectric crossing before the C-point.

The results are saved in the points_ attribute of the super class.

Parameters
  • icg (DataFrame) – ICG derivative signal

  • heartbeats (DataFrame) – Segmented heartbeats. Each row contains start, end, and R-peak location (in samples from beginning of signal) of that heartbeat, index functions as id of heartbeat

  • c_points (DataFrame) – Extracted C-points. Each row contains the C-point location (in samples from beginning of signal) for each heartbeat, index functions as id of heartbeat. C-point locations can be NaN if no C-points were detected for certain heartbeats

  • sampling_rate_hz (int) – sampling rate of ICG derivative signal in hz

Return type

self

Raises

EventExtractionError – If the event extraction fails and handle_missing is set to “raise”

class biopsykit.signals.icg.event_extraction.BPointExtractionArbol2017SecondDerivative(search_window_start_ms=150, window_size_ms=50, handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionArbol2017SecondDerivative algorithm instance.

Parameters
  • search_window_start_ms (int, optional) – Start of the search window in which the algorithm searches for the B-point, relative to the C-point. Default: 150 ms (see Arbol 2017).

  • window_size_ms (str, int) – Size of the search window in which the algorithm searches for the B-point. Default: 50 ms (see Arbol 2017).

  • handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

    How to handle failing event extraction. Must be one of:

    • "warn": issue a warning and set the event to NaN,

    • "raise": raise an EventExtractionError, or

    • "ignore": continue silently.

    Default: "warn".

correct_outliers: bool
search_window_start_ms: int
window_size_ms: int
extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

This algorithm extracts B-points based on the maximum of the second derivative of the ICG signal in a 50ms window, starting 150ms before the C-point.

The results are saved in the points_ attribute of the super class.

Parameters
  • icg (DataFrame) – ICG derivative signal

  • heartbeats (DataFrame) – Segmented heartbeats. Each row contains start, end, and R-peak location (in samples from beginning of signal) of that heartbeat, index functions as id of heartbeat

  • c_points (DataFrame) – Extracted C-points. Each row contains the C-point location (in samples from beginning of signal) for each heartbeat, index functions as id of heartbeat. C-point locations can be NaN if no C-points were detected for certain heartbeats

  • sampling_rate_hz (int) – sampling rate of ICG derivative signal in hz

Return type

self

Raises

EventExtractionError – If the event extraction fails and handle_missing is set to “raise”

class biopsykit.signals.icg.event_extraction.BPointExtractionArbol2017ThirdDerivative(search_window_start_ms=300, handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionArbol2017ThirdDerivative algorithm instance.

Parameters
  • search_window_start_ms (int or str, optional) – Start of the window in which the algorithm searches for the B-point, relative to the C-point. Use "R" to search between the R-peak and the C-point, or pass an integer offset in milliseconds (for example 300; see Arbol 2017, third-derivative-based algorithm).

  • handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

    How to handle failing event extraction. Must be one of:

    • "warn": issue a warning and set the event to NaN,

    • "raise": raise an EventExtractionError, or

    • "ignore": continue silently.

    Default: "warn".

correct_outliers: bool
search_window_start_ms: str | int
extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

This algorithm extracts B-points based on the maximum of the third derivative of the ICG signal within a 300ms window before the C-point.

The results are saved in the points_ attribute of the super class.

Parameters
  • icg (DataFrame) – ICG derivative signal

  • heartbeats (DataFrame) – Segmented heartbeats. Each row contains start, end, and R-peak location (in samples from beginning of signal) of that heartbeat, index functions as id of heartbeat

  • c_points (DataFrame) – Extracted C-points. Each row contains the C-point location (in samples from beginning of signal) for each heartbeat, index functions as id of heartbeat. C-point locations can be NaN if no C-points were detected for certain heartbeats

  • sampling_rate_hz (int) – sampling rate of ICG derivative signal in hz

Return type

self

Raises

EventExtractionError – If the event extraction fails and handle_missing is set to “raise”

class biopsykit.signals.icg.event_extraction.BPointExtractionDebski1993SecondDerivative(correct_outliers=False, handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionDebski1993SecondDerivative instance.

Parameters
  • correct_outliers (bool, optional) – Indicates whether to perform outlier correction (True) or not (False). Default: False.

  • handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

    How to handle failing event extraction. Must be one of:

    • "warn": issue a warning and set the event to NaN,

    • "raise": raise an EventExtractionError, or

    • "ignore": continue silently.

    Default: "warn".

correct_outliers: bool
extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

This algorithm extracts B-points based on the last reversal (local minimum) of the second derivative of the ICG signal before the C-point.

The results are saved in the points_ attribute of the super class.

Parameters
  • icg (DataFrame) – ICG derivative signal

  • heartbeats (DataFrame) – Segmented heartbeats. Each row contains start, end, and R-peak location (in samples from beginning of signal) of that heartbeat, index functions as id of heartbeat

  • c_points (DataFrame) – Extracted C-points. Each row contains the C-point location (in samples from beginning of signal) for each heartbeat, index functions as id of heartbeat. C-point locations can be NaN if no C-points were detected for certain heartbeats

  • sampling_rate_hz (int) – sampling rate of ICG derivative signal in hz

Return type

self

Raises

EventExtractionError – If the event extraction fails and handle_missing is set to “raise”

class biopsykit.signals.icg.event_extraction.BPointExtractionDrost2022(handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionDrost2022 instance.

Parameters

handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

How to handle failing event extraction. Must be one of:

  • "warn": issue a warning and set the event to NaN,

  • "raise": raise an EventExtractionError, or

  • "ignore": continue silently.

Default: "warn".

extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

This algorithm extracts B-points based on the maximum distance of the dZ/dt curve and a straight line fitted between the C-Point and the Point on the dZ/dt curve 150 ms before the C-Point.

The results are saved in the points_ attribute of the super class.

Parameters
  • icg (DataFrame) – ICG derivative signal

  • heartbeats (DataFrame) – Segmented heartbeats. Each row contains start, end, and R-peak location (in samples from beginning of signal) of that heartbeat, index functions as id of heartbeat

  • c_points (DataFrame) – Extracted C-points. Each row contains the C-point location (in samples from beginning of signal) for each heartbeat, index functions as id of heartbeat. C-point locations can be NaN if no C-points were detected for certain heartbeats

  • sampling_rate_hz (int) – sampling rate of ICG derivative signal in hz

Return type

self

Raises

EventExtractionError – If the event extraction fails and handle_missing is set to “raise”

class biopsykit.signals.icg.event_extraction.BPointExtractionForouzanfar2018(scaling_factor=2000, correct_outliers=False, handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionForouzanfar2018 instance.

In the original paper, the authors report the sampling frequency of the ICG signal as the scaling factor. Since this would change the algorithm behavior depending on the sampling rate of the ICG signal, this implementation introduces a scaling factor that can be set by the user. By default, the scaling factor is set to 2000 (corresponding to a sampling rate of the original data of 2000 Hz) instead of using the sampling rate of the ICG signal.

Parameters
  • scaling_factor (float, optional) – Scaling factor for the B-point extraction algorithm. Default: 2000.

  • correct_outliers (bool, optional) – True to correct outliers, False to set the B-point to NaN if no monotonic segment is found. Default: False.

  • handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

    How to handle failing event extraction. Must be one of:

    • "warn": issue a warning and set the event to NaN,

    • "raise": raise an EventExtractionError, or

    • "ignore": continue silently.

    Default: "warn".

scaling_factor: float
correct_outliers: bool
extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

The algorithm extracts B-points based on the detection of the most prominent monotonic increasing segment between the A-Point (the local minimum within one third of the beat-to-beat interval prior to the C-Point) and the C-Point. The B-Point is then detected as the last zero crossing or local maximum of the third derivative of the ICG signal within the segment.

The results are saved in the points_ attribute of the super class.

Parameters
  • icg (DataFrame) – ICG derivative signal

  • heartbeats (DataFrame) – Segmented heartbeats. Each row contains start, end, and R-peak location (in samples from beginning of signal) of that heartbeat, index functions as id of heartbeat

  • c_points (DataFrame) – Extracted C-points. Each row contains the C-point location (in samples from beginning of signal) for each heartbeat, index functions as id of heartbeat. C-point locations can be NaN if no C-points were detected for certain heartbeats

  • sampling_rate_hz (int) – sampling rate of ICG derivative signal in hz

Return type

self

Raises

EventExtractionError – If the event extraction fails and handle_missing is set to “raise”

class biopsykit.signals.icg.event_extraction.BPointExtractionLozano2007LinearRegression(moving_average_window=1, handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionLozano2007LinearRegression instance.

Parameters
  • moving_average_window (int, optional) – Window size for moving average filter (in heartbeats, centered around the current heartbeat) to compute the R-C interval. Default: 1 (no moving average).

  • handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

    How to handle failing event extraction. Must be one of:

    • "warn": issue a warning and set the event to NaN,

    • "raise": raise an EventExtractionError, or

    • "ignore": continue silently.

    Default: "warn".

moving_average_window: int
extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

This algorithm extracts B-points using linear regression based on the relationship between the R-C interval and the B-point.

The results are saved in the points_ attribute of the super class.

Parameters
  • icg (DataFrame) – ICG derivative signal

  • heartbeats (DataFrame) – Segmented heartbeats. Each row contains start, end, and R-peak location (in samples from beginning of signal) of that heartbeat, index functions as id of heartbeat

  • c_points (DataFrame) – Extracted C-points. Each row contains the C-point location (in samples from beginning of signal) for each heartbeat, index functions as id of heartbeat. C-point locations can be NaN if no C-points were detected for certain heartbeats

  • sampling_rate_hz (int) – sampling rate of ICG derivative signal in hz

Return type

self

Raises

EventExtractionError – If the event extraction fails and handle_missing is set to “raise”

class biopsykit.signals.icg.event_extraction.BPointExtractionLozano2007QuadraticRegression(moving_average_window=1, handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionLozano2007QuadraticRegression instance.

Parameters
  • moving_average_window (int, optional) – Window size for moving average filter (in heartbeats, centered around the current heartbeat) to compute the R-C interval. Default: 1 (no moving average).

  • handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

    How to handle failing event extraction. Must be one of:

    • "warn": issue a warning and set the event to NaN,

    • "raise": raise an EventExtractionError, or

    • "ignore": continue silently.

    Default: "warn".

extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

This algorithm extracts B-points using quadratic regression based on the relationship between the R-C interval and the B-point.

The results are saved in the points_ attribute of the super class.

Parameters
  • icg (DataFrame) – ICG derivative signal

  • heartbeats (DataFrame) – Segmented heartbeats. Each row contains start, end, and R-peak location (in samples from beginning of signal) of that heartbeat, index functions as id of heartbeat

  • c_points (DataFrame) – Extracted C-points. Each row contains the C-point location (in samples from beginning of signal) for each heartbeat, index functions as id of heartbeat. C-point locations can be NaN if no C-points were detected for certain heartbeats

  • sampling_rate_hz (int) – sampling rate of ICG derivative signal in hz

Return type

self

Raises

EventExtractionError – If the event extraction fails and handle_missing is set to “raise”

class biopsykit.signals.icg.event_extraction.BPointExtractionMiljkovic2022(handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionMiljkovic2022 instance.

Parameters

handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

How to handle failing event extraction. Must be one of:

  • "warn": issue a warning and set the event to NaN,

  • "raise": raise an EventExtractionError, or

  • "ignore": continue silently.

Default: "warn".

extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

This algorithm extracts B-points by transforming the ICG signal using a weighted time window applied to the segment preceding the maximal ICG peak (C-point). This transformation amplifies the characteristics of the B-point, facilitating B-point identification.

Parameters
  • icg (IcgRawDataFrame) – The raw ICG signal data.

  • heartbeats (HeartbeatSegmentationDataFrame) – The heartbeat segmentation data.

  • c_points (CPointDataFrame) – The C-point data.

  • sampling_rate_hz (float) – The sampling rate of the ICG signal in Hz.

Returns

The extracted B-point data.

Return type

BPointDataFrame

class biopsykit.signals.icg.event_extraction.BPointExtractionPale2021(c_point_amplitude_fraction=0.5, b_point_slope_threshold_01=0.11, b_point_slope_threshold_02=0.08, handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionPale2021 instance.

Parameters
  • handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

    How to handle failing event extraction. Must be one of:

    • "warn": issue a warning and set the event to NaN,

    • "raise": raise an EventExtractionError, or

    • "ignore": continue silently.

    Default: "warn".

  • c_point_amplitude_fraction (float) –

  • b_point_slope_threshold_01 (float) –

  • b_point_slope_threshold_02 (float) –

c_point_amplitude_fraction: float
b_point_slope_threshold_01: float
b_point_slope_threshold_02: float
extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

This algorithm extracts B-points by transforming the ICG signal using a weighted time window applied to the segment preceding the maximal ICG peak (C-point). This transformation amplifies the characteristics of the B-point, facilitating B-point identification.

Parameters
  • icg (IcgRawDataFrame) – The raw ICG signal data.

  • heartbeats (HeartbeatSegmentationDataFrame) – The heartbeat segmentation data.

  • c_points (CPointDataFrame) – The C-point data.

  • sampling_rate_hz (float) – The sampling rate of the ICG signal in Hz.

Returns

The extracted B-point data.

Return type

BPointDataFrame

class biopsykit.signals.icg.event_extraction.BPointExtractionSherwood1990(handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionSherwood1990 instance.

Parameters

handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

How to handle failing event extraction. Must be one of:

  • "warn": issue a warning and set the event to NaN,

  • "raise": raise an EventExtractionError, or

  • "ignore": continue silently.

Default: "warn".

extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

This algorithm extracts B-points based on the last zero crossing of the ICG signal before the C-point.

The results are stored in the points_ attribute of this class.

Parameters
  • icg (DataFrame) – ICG derivative signal

  • heartbeats (DataFrame) – Segmented heartbeats. Each row contains start, end, and R-peak location (in samples from beginning of signal) of that heartbeat, index functions as id of heartbeat

  • c_points (DataFrame) – Extracted C-points. Each row contains the C-point location (in samples from beginning of signal) for each heartbeat, index functions as id of heartbeat. C-point locations can be NaN if no C-points were detected for certain heartbeats

  • sampling_rate_hz (int) – sampling rate of ICG derivative signal in hz

Return type

self

Raises

EventExtractionError – If the event extraction fails and handle_missing is set to “raise”

class biopsykit.signals.icg.event_extraction.BPointExtractionStern1985(handle_missing_events='warn')[source]

Bases: BaseBPointExtraction, CanHandleMissingEventsMixin

Initialize new BPointExtractionStern1985 instance.

Parameters

handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

How to handle failing event extraction. Must be one of:

  • "warn": issue a warning and set the event to NaN,

  • "raise": raise an EventExtractionError, or

  • "ignore": continue silently.

Default: "warn".

extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]

Extract B-points from given ICG derivative signal.

This algorithm extracts B-points based on the last local minimum of the dZ/dt curve before the C-point.

The results are saved in the points_ attribute of the super class.

Parameters
  • icg (DataFrame) – ICG derivative signal

  • heartbeats (DataFrame) – Segmented heartbeats. Each row contains start, end, and R-peak location (in samples from beginning of signal) of that heartbeat, index functions as id of heartbeat

  • c_points (DataFrame) – Extracted C-points. Each row contains the C-point location (in samples from beginning of signal) for each heartbeat, index functions as id of heartbeat. C-point locations can be NaN if no C-points were detected for certain heartbeats

  • sampling_rate_hz (int) – sampling rate of ICG derivative signal in hz

Return type

self

Raises

EventExtractionError – If the event extraction fails and handle_missing is set to “raise”

class biopsykit.signals.icg.event_extraction.BaseBPointExtraction[source]

Bases: BaseExtraction

Base class for B-point extraction algorithms.

points_: biopsykit.utils.dtypes._BPointDataFrame | pandas.core.frame.DataFrame
extract(*, icg, heartbeats, c_points, sampling_rate_hz)[source]
Parameters
  • icg (biopsykit.utils.dtypes._IcgRawDataFrame | pandas.core.frame.DataFrame) –

  • heartbeats (biopsykit.utils.dtypes._HeartbeatSegmentationDataFrame | pandas.core.frame.DataFrame) –

  • c_points (biopsykit.utils.dtypes._CPointDataFrame | pandas.core.frame.DataFrame) –

  • sampling_rate_hz (float | None) –

class biopsykit.signals.icg.event_extraction.BaseCPointExtraction[source]

Bases: BaseExtraction

Base class for C-point extraction algorithms.

points_: biopsykit.utils.dtypes._CPointDataFrame | pandas.core.frame.DataFrame
extract(*, icg, heartbeats, sampling_rate_hz)[source]
Parameters
  • icg (biopsykit.utils.dtypes._IcgRawDataFrame | pandas.core.frame.DataFrame) –

  • heartbeats (biopsykit.utils.dtypes._HeartbeatSegmentationDataFrame | pandas.core.frame.DataFrame) –

  • sampling_rate_hz (float | None) –

class biopsykit.signals.icg.event_extraction.CPointExtractionScipyFindPeaks(window_c_correction=3, handle_missing_events='warn')[source]

Bases: BaseCPointExtraction, CanHandleMissingEventsMixin

Initialize new CPointExtractionScipyFindPeaks instance.

Parameters
  • window_c_correction (int, optional) – Number of preceding heartbeats taken into account for C-point correction (using mean R-C-distance). Default: 3.

  • handle_missing_events (one of {"warn", "raise", "ignore"}, optional) –

    How to handle failing event extraction. Must be one of:

    • "warn": issue a warning and set the event to NaN,

    • "raise": raise an EventExtractionError, or

    • "ignore": continue silently.

    Default: "warn".

window_c_correction: int
extract(*, icg, heartbeats, sampling_rate_hz)[source]

Extract C-points from given cleaned ICG derivative signal using find_peaks().

The C-point is detected as the maximum of the most prominent peak in the ICG derivative signal within each segmented heartbeat.

The resulting C-points are saved in the points_ attribute of the class instance.

Parameters
  • icg (DataFrame) – cleaned ICG derivative signal

  • heartbeats (DataFrame) – Dataframe containing one row per segmented heartbeat, each row contains start, end, and R-peak. Result from HeartbeatSegmentationNeurokit.

  • sampling_rate_hz (int) – Sampling rate of ICG derivative signal in Hz. Not used in this function.

Return type

self