def ecg_hrv_assessment(hrv, age=None, sex=None, position=None):
    """
    Correct HRV features based on normative data from Voss et al. (2015).

    Parameters
    ----------
    hrv : dict
        HRV features obtained by :function:`neurokit.ecg_hrv`.
    age : float
        Subject's age.
    sex : str
        Subject's gender ("m" or "f").
    position : str
        Recording position. To compare with data from Voss et al. (2015), use "supine".


    Returns
    ----------
    hrv_adjusted : dict
        Adjusted HRV features.

    Example
    ----------
    >>> import neurokit as nk
    >>> hrv = nk.bio_ecg.ecg_hrv(rpeaks=rpeaks)
    >>> ecg_hrv_assessment = nk.bio_ecg.ecg_hrv_assessment(hrv)

    Notes
    ----------
    *Authors*

    - `Dominique Makowski <https://dominiquemakowski.github.io/>`_

    *Details*

    - **Adjusted HRV**: The raw HRV features are normalized :math:`(raw - Mcluster) / sd` according to the participant's age and gender. In data from Voss et al. (2015), HRV analysis was performed on 5-min ECG recordings (lead II and lead V2 simultaneously, 500 Hz sampling rate) obtained in supine position after a 5–10 minutes resting phase. The cohort of healthy subjects consisted of 782 women and 1124 men between the ages of 25 and 74 years, clustered into 4 groups: YF (Female, Age = [25-49], n=571), YM (Male, Age = [25-49], n=744), EF (Female, Age = [50-74], n=211) and EM (Male, Age = [50-74], n=571).


    References
    -----------
    - Voss, A., Schroeder, R., Heitmann, A., Peters, A., & Perz, S. (2015). Short-term heart rate variability—influence of gender and age in healthy subjects. PloS one, 10(3), e0118308.
    """
    hrv_adjusted = {}

    if position == "supine":
        if sex == "m":
            if age <= 49:
                hrv_adjusted["meanNN_Adjusted"] = (hrv["meanNN"]-930)/133
                hrv_adjusted["sdNN_Adjusted"] = (hrv["sdNN"]-45.8)/18.8
                hrv_adjusted["RMSSD_Adjusted"] = (hrv["RMSSD"]-34.0)/18.3

                hrv_adjusted["LF_Adjusted"] = (hrv["LF"]-203)/262
                hrv_adjusted["HF_Adjusted"] = (hrv["HF"]-101)/143
                hrv_adjusted["LF/HF_Adjusted"] = (hrv["LF/HF"]-3.33)/3.47
            else:
                hrv_adjusted["meanNN_Adjusted"] = (hrv["meanNN"]-911)/128
                hrv_adjusted["sdNN_Adjusted"] = (hrv["sdNN"]-33.0)/14.8
                hrv_adjusted["RMSSD_Adjusted"] = (hrv["RMSSD"]-20.5)/11.0

                hrv_adjusted["LF_Adjusted"] = (hrv["LF"]-84)/115
                hrv_adjusted["HF_Adjusted"] = (hrv["HF"]-29.5)/36.6
                hrv_adjusted["LF/HF_Adjusted"] = (hrv["LF/HF"]-4.29)/4.06
        if sex == "f":
            if age <= 49:
                hrv_adjusted["meanNN_Adjusted"] = (hrv["meanNN"]-901)/117
                hrv_adjusted["sdNN_Adjusted"] = (hrv["sdNN"]-44.9)/19.2
                hrv_adjusted["RMSSD_Adjusted"] = (hrv["RMSSD"]-36.5)/20.1

                hrv_adjusted["LF_Adjusted"] = (hrv["LF"]-159)/181
                hrv_adjusted["HF_Adjusted"] = (hrv["HF"]-125)/147
                hrv_adjusted["LF/HF_Adjusted"] = (hrv["LF/HF"]-2.75)/2.93
            else:
                hrv_adjusted["meanNN_Adjusted"] = (hrv["meanNN"]-880)/115
                hrv_adjusted["sdNN_Adjusted"] = (hrv["sdNN"]-31.6)/13.6
                hrv_adjusted["RMSSD_Adjusted"] = (hrv["RMSSD"]-22.0)/13.2

                hrv_adjusted["LF_Adjusted"] = (hrv["LF"]-66)/83
                hrv_adjusted["HF_Adjusted"] = (hrv["HF"]-41.4)/72.1
                hrv_adjusted["LF/HF_Adjusted"] = (hrv["LF/HF"]-2.09)/2.05

    return(hrv_adjusted)
def ecg_hrv_assessment ( hrv , age = None , sex = None , position = None ) : hrv_adjusted = { } if position == "supine" : if sex == "m" : if age <= 49 : hrv_adjusted [ "meanNN_Adjusted" ] = ( hrv [ "meanNN" ] - 930 ) / 133 hrv_adjusted [ "sdNN_Adjusted" ] = ( hrv [ "sdNN" ] - 45.8 ) / 18.8 hrv_adjusted [ "RMSSD_Adjusted" ] = ( hrv [ "RMSSD" ] - 34.0 ) / 18.3 hrv_adjusted [ "LF_Adjusted" ] = ( hrv [ "LF" ] - 203 ) / 262 hrv_adjusted [ "HF_Adjusted" ] = ( hrv [ "HF" ] - 101 ) / 143 hrv_adjusted [ "LF/HF_Adjusted" ] = ( hrv [ "LF/HF" ] - 3.33 ) / 3.47 else : hrv_adjusted [ "meanNN_Adjusted" ] = ( hrv [ "meanNN" ] - 911 ) / 128 hrv_adjusted [ "sdNN_Adjusted" ] = ( hrv [ "sdNN" ] - 33.0 ) / 14.8 hrv_adjusted [ "RMSSD_Adjusted" ] = ( hrv [ "RMSSD" ] - 20.5 ) / 11.0 hrv_adjusted [ "LF_Adjusted" ] = ( hrv [ "LF" ] - 84 ) / 115 hrv_adjusted [ "HF_Adjusted" ] = ( hrv [ "HF" ] - 29.5 ) / 36.6 hrv_adjusted [ "LF/HF_Adjusted" ] = ( hrv [ "LF/HF" ] - 4.29 ) / 4.06 if sex == "f" : if age <= 49 : hrv_adjusted [ "meanNN_Adjusted" ] = ( hrv [ "meanNN" ] - 901 ) / 117 hrv_adjusted [ "sdNN_Adjusted" ] = ( hrv [ "sdNN" ] - 44.9 ) / 19.2 hrv_adjusted [ "RMSSD_Adjusted" ] = ( hrv [ "RMSSD" ] - 36.5 ) / 20.1 hrv_adjusted [ "LF_Adjusted" ] = ( hrv [ "LF" ] - 159 ) / 181 hrv_adjusted [ "HF_Adjusted" ] = ( hrv [ "HF" ] - 125 ) / 147 hrv_adjusted [ "LF/HF_Adjusted" ] = ( hrv [ "LF/HF" ] - 2.75 ) / 2.93 else : hrv_adjusted [ "meanNN_Adjusted" ] = ( hrv [ "meanNN" ] - 880 ) / 115 hrv_adjusted [ "sdNN_Adjusted" ] = ( hrv [ "sdNN" ] - 31.6 ) / 13.6 hrv_adjusted [ "RMSSD_Adjusted" ] = ( hrv [ "RMSSD" ] - 22.0 ) / 13.2 hrv_adjusted [ "LF_Adjusted" ] = ( hrv [ "LF" ] - 66 ) / 83 hrv_adjusted [ "HF_Adjusted" ] = ( hrv [ "HF" ] - 41.4 ) / 72.1 hrv_adjusted [ "LF/HF_Adjusted" ] = ( hrv [ "LF/HF" ] - 2.09 ) / 2.05 return ( hrv_adjusted )
Correct HRV features based on normative data from Voss et al. (2015).

    Parameters
    ----------
    hrv : dict
        HRV features obtained by :function:`neurokit.ecg_hrv`.
    age : float
        Subject's age.
    sex : str
        Subject's gender ("m" or "f").
    position : str
        Recording position. To compare with data from Voss et al. (2015), use "supine".


    Returns
    ----------
    hrv_adjusted : dict
        Adjusted HRV features.

    Example
    ----------
    >>> import neurokit as nk
    >>> hrv = nk.bio_ecg.ecg_hrv(rpeaks=rpeaks)
    >>> ecg_hrv_assessment = nk.bio_ecg.ecg_hrv_assessment(hrv)

    Notes
    ----------
    *Authors*

    - `Dominique Makowski <https://dominiquemakowski.github.io/>`_

    *Details*

    - **Adjusted HRV**: The raw HRV features are normalized :math:`(raw - Mcluster) / sd` according to the participant's age and gender. In data from Voss et al. (2015), HRV analysis was performed on 5-min ECG recordings (lead II and lead V2 simultaneously, 500 Hz sampling rate) obtained in supine position after a 5–10 minutes resting phase. The cohort of healthy subjects consisted of 782 women and 1124 men between the ages of 25 and 74 years, clustered into 4 groups: YF (Female, Age = [25-49], n=571), YM (Male, Age = [25-49], n=744), EF (Female, Age = [50-74], n=211) and EM (Male, Age = [50-74], n=571).


    References
    -----------
    - Voss, A., Schroeder, R., Heitmann, A., Peters, A., & Perz, S. (2015). Short-term heart rate variability—influence of gender and age in healthy subjects. PloS one, 10(3), e0118308.