API Reference

ACC

flirt.acc.get_acc_features(data: DataFrame, window_length: int = 60, window_step_size: float = 1, data_frequency: int = 32, num_cores: int = 0)[source]

Computes statistical ACC features based on the l2-norm of the x-, y-, and z- acceleration.

Parameters:
  • data (pd.DataFrame) – input ACC time series in x-, y-, and z- direction

  • window_length (int) – the window size in seconds to consider

  • window_step_size (int) – the time step to shift each window

  • data_frequency (int) – the frequency of the input signal

  • num_cores (int, optional) – number of cores to use for parallel processing, by default use all available

Returns:

ACC Features – A DataFrame containing statistical aggregation features.

Return type:

pd.DataFrame

Notes

DataFrame contains the following ACC features

  • Statistical Features: acc_entropy, acc_perm_entropy, acc_svd_entropy, acc_mean, acc_min, acc_max, acc_ptp, acc_sum, acc_energy, acc_skewness, acc_kurtosis, acc_peaks, acc_rms, acc_lineintegral, acc_n_above_mean, acc_n_below_mean, acc_iqr, acc_iqr_5_95, acc_pct_5, acc_pct_95

Examples

>>> import flirt.reader.empatica
>>> acc = flirt.reader.empatica.read_acc_file_into_df("ACC.csv")
>>> acc_features = flirt.get_acc_features(acc, 60)

HRV

flirt.hrv.get_hrv_features(data: Series, window_length: int = 180, window_step_size: int = 1, domains: List[str] = ['td', 'fd', 'stat'], threshold: float = 0.2, clean_data: bool = True, num_cores: int = 0)[source]

Computes HRV features for different domains (time-domain, frequency-domain, non-linear, statistical).

Parameters:
  • data (pd.Series) – input IBIs in milliseconds

  • window_length (int) – the epoch width (aka window size) in seconds to consider

  • window_step_size (int) – the step size for the sliding window in seconds

  • domains (List[str]) – domains to calculate (possible values: “td”, “fd”, “nl”, “stat”)

  • threshold (float) – the relative portion of IBIs that need to be present in a window for processing. Otherwise, the window is dropped

  • clean_data (bool, optional) – whether obviously invalid IBIs should be removed before processing, by default True

  • num_cores (int, optional) – number of cores to use for parallel processing, by default use all available

Returns:

HRV Features – A DataFrame containing all chosen features (i.e., time domain, frequency domain, non-linear features, and/or statistical features)

Return type:

pd.DataFrame

Notes

DataFrame contains the following HRV features

  • Time Domain: rmssd, sdnn, sdsd, nni_50, pnni_50, nni_20, pnni_20, mean_hr, max_hr, min_hr, std_hr, cvsd, cvnni

  • Frequency Domain: tital_power, hf, vlf, lf, lf_hf_ratio, lfnu, hfnu

  • Non-Linear Features: SD1, SD2, SD2SD1, CSI, CVI, CSI_Modified

  • Statistical Features: ibi_entropy, ibi_perm_entropy, ibi_svd_entropy, ibi_ibi_mean, ibi_min, ibi_max, ibi_ptp, ibi_sum, ibi_energy, ibi_skewness, ibi_kurtosis, ibi_peaks, ibi_rms, ibi_lineintegral, ibi_n_above_mean, ibi_n_below_mean, ibi_iqr, ibi_iqr_5_95, ibi_pct_5, ibi_pct_95

Examples

>>> import flirt.reader.empatica
>>> ibis = flirt.reader.empatica.read_ibi_file_into_df("IBI.csv")
>>> hrv_features = flirt.get_hrv_features(ibis['ibi'], 60, 1, ["td", "fd", "stat"], 0.8)

EDA

flirt.eda.get_eda_features(data: Series, window_length: int = 60, window_step_size: int = 1, data_frequency: int = 4, num_cores: int = 0)[source]

Computes statistical EDA features based on the signal decompositon into phasic/tonic components of the skin conductivity.

Parameters:
  • data (pd.Series) – input EDA time series

  • window_length (int) – the window size in seconds to consider

  • window_step_size (int) – the time step to shift each window

  • data_frequency (int) – the frequency of the input signal

  • num_cores (int, optional) – number of cores to use for parallel processing, by default use all available

Returns:

EDA Features – A DataFrame containing statistical aggregation features of the tonic/phasic EDA components.

Return type:

pd.DataFrame

Examples

>>> import flirt.reader.empatica
>>> eda = flirt.reader.empatica.read_eda_file_into_df("EDA.csv")
>>> acc_features = flirt.get_eda_features(eda['eda'], 180, 1)

Reader

flirt.reader.empatica.read_acc_file_into_df(filepath_or_buffer) DataFrame[source]

Warning

function ‘flirt.reader.empatica.read_acc_file_into_df’ is undocumented

flirt.reader.empatica.read_bvp_file_into_df(filepath_or_buffer) DataFrame[source]

Warning

function ‘flirt.reader.empatica.read_bvp_file_into_df’ is undocumented

flirt.reader.empatica.read_eda_file_into_df(filepath_or_buffer) DataFrame[source]

Warning

function ‘flirt.reader.empatica.read_eda_file_into_df’ is undocumented

flirt.reader.empatica.read_hr_file_into_df(filepath_or_buffer) DataFrame[source]

Warning

function ‘flirt.reader.empatica.read_hr_file_into_df’ is undocumented

flirt.reader.empatica.read_ibi_file_into_df(filepath_or_buffer) DataFrame[source]

Reads an Empatica IBI file into a DataFrame.

Parameters:

filepath_or_buffer – filepath as string or buffer (file)

Returns:

IBIs – a pd.DataFrame with an ‘ibi’ columns, IBIs in milliseconds

Return type:

pd.DataFrame

flirt.reader.empatica.read_temp_file_into_df(filepath_or_buffer) DataFrame[source]

Warning

function ‘flirt.reader.empatica.read_temp_file_into_df’ is undocumented

flirt.reader.garmin.read_acc_file_into_df(file: str) DataFrame[source]

Reads a Garmin accelerometer data file (as exported from the Android data logger application) into a pandas DataFrame

Parameters:

file (str) – file path

Returns:

a pandas DataFrame representing the file contents

Return type:

pd.DataFrame

flirt.reader.garmin.read_data_file_into_df(file: str, filter_type: Optional[str] = None) DataFrame[source]

Reads a Garmin data file (as exported from the Android data logger application) into a pandas DataFrame

Parameters:
  • file (str) – file path

  • filter_type (str, optional) – filter the values by type and return only matching values (e.g. ‘hrv’, ‘hr’, ‘steps’), by default None

Returns:

a pandas DataFrame representing the file contents

Return type:

pd.DataFrame

flirt.reader.holter.get_starttime_from_holter(holter_path: str) datetime[source]

Reads the start time of a holter file

Parameters:

holter_path (str) – path to the holter file

Returns:

the start datetime of the Holter file

Return type:

datetime

flirt.reader.holter.read_holter_ibi_file_into_df(start_time: datetime, ibi_file: str) DataFrame[source]

Reads a Holter IBI file (from Lifecard CF) into a pandas DataFrame

Parameters:
  • start_time (datetime) – starttime of the file (should be retrieved from Holter file)

  • ibi_file (str) – path to the IBI file

Returns:

DataFrame containing the IBIs

Return type:

pd.DataFrame

Simple

flirt.simple.get_features_for_empatica_archive(zip_file_path: str, window_length: int = 180, window_step_size: int = 1, hrv_features: bool = True, eda_features: bool = True, acc_features: bool = True, debug: bool = False, num_cores: int = 0) DataFrame[source]

This function provides a standard set of HRV, EDA, ACC features for a given Empatica archive (e.g. downloaded from E4 connect)

Parameters:
  • zip_file_path (str) – path to the Empatica zip file

  • window_length (int) – the epoch width (window size) in seconds, for which features should be calculated

  • window_step_size (int) – the step size for the sliding window in seconds

  • hrv_features (bool) – whether HRV features should be calculated from the archive

  • eda_features (bool) – whether EDA features should be calculated from the archive

  • acc_features (bool) – whether ACC features should be calculated from the archive

  • debug (bool) – whether debug output should be printed

  • num_cores (int, optional) – number of cores to use for parallel processing, by default use all available

Returns:

a pandas DataFrame containing a standard set of features for Empatica

Return type:

pd.DataFrame

Examples

>>> import flirt.simple
>>> features = flirt.simple.get_features_for_empatica_archive("1560460372_A12345.zip")

Stats

flirt.stats.get_stat_features(data: DataFrame, window_length: int = 60, window_step_size: int = 1, data_frequency: int = 32, entropies: bool = True, num_cores: int = 0)[source]

Computes several statistical and entropy-based time series features for each column in the provided DataFrame.

Parameters:
  • data (pd.DataFrame) – input time series

  • window_length (int) – the epoch width (aka window size) in seconds to consider

  • entropies (bool) – whether to calculate entropy features

  • num_cores (int, optional) – number of cores to use for parallel processing, by default use all available

Returns:

TS Features – A DataFrame containing all ststistical and entropy-based features.

Return type:

pd.DataFrame

Notes

DataFrame contains the following stat features

  • Statistical Features: entropy (optional), perm_entropy (optional), svd_entropy (optional), mean, min, max, ptp, sum, energy, skewness, kurtosis, peaks, rms, lineintegral, n_above_mean, n_below_mean, iqr, iqr_5_95, pct_5, pct_95

Examples

>>> import flirt.reader.empatica
>>> acc = flirt.reader.empatica.read_acc_file_into_df("ACC.csv")
>>> acc_features = flirt.get_stat_features(acc, 60, 1, entropies=False)