OBM package¶
OBM.ComplexityMeasures class¶
-
class
OBM.ComplexityMeasures.
ComplexityMeasures
(CTM_Threshold=0.25, DFA_Window=20, M_Sampen=3, R_Sampen=0.2)[source]¶ Bases:
object
Class that calculates Complexity Features from spo2 time series. Suppose that the data has been preprocessed.
- :param
- signal: 1-d array, of shape (N,) where N is the length of the signal CTM_Threshold: Radius of Central Tendency Measure. DFA_Window: Length of window to calculate DFA biomarker. M_Sampen: Embedding dimension to compute SampEn. R_Sampen: Tolerance to compute SampEn.
-
compute
(signal) → OBM._ResultsClasses.ComplexityMeasuresResults[source]¶ Parameters: signal – 1-d array, of shape (N,) where N is the length of the signal Returns: - ComplexityMeasuresResults class containing the following features:
- ApEn: Approximate Entropy.
- LZ: Lempel-Ziv complexity.
- CTM: Central Tendency Measure.
- SampEn: Sample Entropy.
- DFA: Detrended Fluctuation Analysis.
OBM.DesaturationsMeasures class¶
-
class
OBM.DesaturationsMeasures.
DesaturationsMeasures
(begin, end)[source]¶ Bases:
object
Class that calculates the Desaturation Features from spo2 time series. Suppose that the data has been preprocessed.
Parameters: - begin – List of indices of beginning of each desaturation event.
- end – List of indices of end of each desaturation event.
-
compute
(signal) → OBM._ResultsClasses.DesaturationsMeasuresResults[source]¶ Parameters: signal – 1-d array, of shape (N,) where N is the length of the signal Returns: - DesaturationsMeasuresResults class containing the following features:
- DL_u: Mean of desaturation length
- DL_sd: Standard deviation of desaturation length
- DA100_u: Mean of desaturation area using 100% as baseline.
- DA100_sd: Standard deviation of desaturation area using 100% as baseline
- DAmax_u: Mean of desaturation area using max value as baseline.
- DAmax_sd: Standard deviation of desaturation area using max value as baseline
- DD100_u: Mean of depth desaturation from 100%.
- DD100_sd: Standard deviation of depth desaturation from 100%.
- DDmax_u: Mean of depth desaturation from max value.
- DDmax_sd: Standard deviation of depth desaturation from max value.
- DS_u: Mean of the desaturation slope.
- DS_sd: Standard deviation of the desaturation slope.
- TD_u: Mean of time between two consecutive desaturation events.
- TD_sd: Standard deviation of time between 2 consecutive desaturation events.
OBM.HypoxicBurdenMeasures class¶
-
class
OBM.HypoxicBurdenMeasures.
HypoxicBurdenMeasures
(begin, end, CT_Threshold=90, CA_Baseline=None)[source]¶ Bases:
object
Class that calculates Hypoxic Burden Features from spo2 time series. Suppose that the data has been preprocessed.
Parameters: - begin – List of indices of beginning of each desaturation event.
- end – List of indices of end of each desaturation event.
- CT_Threshold – Percentage of the time spent below the “CT_Threshold” % oxygen saturation level.
- CA_Baseline – Baseline to compute the CA feature. Default value is mean of the signal.
-
compute
(signal)[source]¶ Parameters: signal – 1-d array, of shape (N,) where N is the length of the signal Returns: - HypoxicBurdenMeasuresResults class containing the following features:
- CA: Integral SpO2 below the xx SpO2 level normalized by the total recording time
- CT: Percentage of the time spent below the xx% oxygen saturation level
- POD: Percentage of oxygen desaturation events
- AODmax: The area under the oxygen desaturation event curve, using the maximum SpO2 value as baseline and normalized by the total recording time
- AOD100: Cumulative area of desaturations under the 100% SpO2 level as baseline and normalized by the total recording time
OBM.ODIMeasure class¶
-
class
OBM.ODIMeasure.
ODIMeasure
(ODI_Threshold=3)[source]¶ Bases:
object
Class that calculates the ODI from spo2 time series. Suppose that the data has been preprocessed.
Parameters: ODI_Threshold – Threshold to compute Oxygen Desaturation Index. -
compute
(signal) → OBM._ResultsClasses.ODIMeasureResult[source]¶ Parameters: signal – The SpO2 signal, of shape (N,) Returns: - ODIMeasureResult class containing the following features:
- ODI: the average number of desaturation events per hour.
- begin: List of indices of beginning of each desaturation event.
- end: List of indices of end of each desaturation event.
-
OBM.OverallGeneralMeasures class¶
-
class
OBM.OverallGeneralMeasures.
OverallGeneralMeasures
(ZC_Baseline=None, percentile=1, M_Threshold=2, DI_Window=12)[source]¶ Bases:
object
Class that calculates Overall General Features from spo2 time series. Suppose that the data has been preprocessed.
Parameters: - ZC_Baseline – Baseline for calculating number of zero-crossing points.
- percentile – Percentile to perform. For example, for percentile 1, the argument should be 1
- M_Threshold – Percentage of the signal M_Threshold % below median oxygen saturation. Typically use 1,2 or 5
-
compute
(signal) → OBM._ResultsClasses.OverallGeneralMeasuresResult[source]¶ Parameters: signal – 1-d array, of shape (N,) where N is the length of the signal Returns: - OveralGeneralMeasuresResult class containing the following features:
- AV: Average of the signal.
- MED: Median of the signal.
- Min: Minimum value of the signal.
- SD: Std of the signal.
- RG: SpO2 range (difference between the max and min value).
- P: percentile.
- M: Percentage of the signal x% below median oxygen saturation.
- ZC: Number of zero-crossing points.
- DI: Delta Index.
OBM.PeriodicityMeasures class¶
-
class
OBM.PeriodicityMeasures.
PRSAMeasures
(PRSA_Window=10, K_AC=2)[source]¶ Bases:
object
Function that calculates PRSA Features from spo2 time series. Suppose that the data has been preprocessed.
- :param
- PRSA_Window: Fragment duration of PRSA. K_AC: Number of values to shift when computing autocorrelation
-
compute
(signal) → OBM._ResultsClasses.PRSAResults[source]¶ Parameters: signal – 1-d array, of shape (N,) where N is the length of the signal Returns: - PRSAResults class containing the following features:
- PRSAc: PRSA capacity.
- PRSAad: PRSA amplitude difference.
- PRSAos: PRSA overall slope.
- PRSAsb: PRSA slope before the anchor point.
- PRSAsa: PRSA slope after the anchor point.
- AC: Autocorrelation.
-
class
OBM.PeriodicityMeasures.
PSDMeasures
[source]¶ Bases:
object
Function that calculates PSD Features from spo2 time series. Suppose that the data has been preprocessed.
-
compute
(signal) → OBM._ResultsClasses.PSDResults[source]¶ - :param
- signal: The SpO2 signal, of shape (N,)
Returns: - PSDResults class containing the following features:
- PSD_total: The amplitude of the spectral signal.
- PSD_band: The amplitude of the signal multiplied by a band-pass filter between 0.014 and 0.033 Hz.
- PSD_ratio: The ratio between PSD_total and PSD_band.
- PDS_peak: The max value of the FFT into the band 0.014-0.033 Hz.
-
OBM.Preprocessing class¶
-
OBM.Preprocessing.
block_data
(signal, treshold=50)[source]¶ Apply a block data filter to the SpO2 signal.
Parameters: - signal – 1-d array, of shape (N,) where N is the length of the signal
- (Optional) (treshold) – treshold parameter for block data filter.
Returns: preprocessed signal, 1-d numpy array.
-
OBM.Preprocessing.
dlta_filter
(signal, Diff=4)[source]¶ Apply Delta Filter to the signal.
Parameters: - signal – 1-d array, of shape (N,) where N is the length of the signal
- Diff – parameter of the delta filter.
Returns: preprocessed signal, 1-d numpy array.
-
OBM.Preprocessing.
median_spo2
(signal_spo2, FilterLength=9)[source]¶ Apply a median filter to the SpO2 signal. Median filter used to smooth the spo2 time series and avoid sporadic increase/decrease of spo2 which could affect the detection of the desaturations. Assumption: any missing/abnormal values are represented as ‘np.nan’
Parameters: - signal – 1-d array, of shape (N,) where N is the length of the signal
- (Optional) (FilterLength) – The length of the filter.
Returns: preprocessed signal, 1-d numpy array.
-
OBM.Preprocessing.
resamp_spo2
(signal, OriginalFreq)[source]¶ Resample the SpO2 signal to 1Hz. Assumption: any missing/abnormal values are represented as ‘np.nan’
Parameters: - signal – 1-d array, of shape (N,) where N is the length of the signal
- OriginalFreq – the original frequency.
Returns: resampled signal, 1-d numpy array, the resampled spo2 time series at 1Hz