Skip to main content
`Ctrl`+`K`

# ada.long.nonparametric

## Classes

`DFA` | A class for estimating Hurst exponent of the data using Detrended Fluctuation Analysis.
`DFAResults` | A container for results of fitting DFA model to the actigraphic data. Do not construct manually! The following parameters are available in the fit_params:
`SimpleNonparametric` | A class for estimating basic metrics reflecting 24 hour periodicity in the data. These are:
`SimpleNonparametricResults` | Container for simple nonparametric metrics. Do not construct manually! Following fields are available in fit params (coresponding to the fitted metrics):

## Module Contents

class DFA(n_windows=200, scale_range=(1 / 6, 48), trend_degree=1, n_crossovers=1)

  A class for estimating Hurst exponent of the data using Detrended Fluctuation Analysis.

  n_windows

  Number of scales that will be taken into account during computation. Defaults to 200.

  Type:

    int

  Parameters:

    - n_windows (int)

    - scale_range (Tuple[float, float])

    - trend_degree (int)

    - n_crossovers (int | None)

  scale_range

  Range of scales in hours. Defaults to (1 / 6, 48).

  Type:

    Tuple[float, float]

  Parameters:

    - n_windows (int)

    - scale_range (Tuple[float, float])

    - trend_degree (int)

    - n_crossovers (int | None)

  trend_degree

  Degree of polynomial function describing trend in the integrated data (degree of trend in original data is equal to degree of trend in integrated data - 1). Defaults to 1.

  Type:

    int

  Parameters:

    - n_windows (int)

    - scale_range (Tuple[float, float])

    - trend_degree (int)

    - n_crossovers (int | None)

  n_crossovers

  Number of crossover points expected in the fluctuation graphs, assuming that the data is described by n_crossovers + 1 fractals. If None, optimal number of crossovers in the range 0-10 will be found using Bayes Inforation Crieteria. Defaults to 1.

  Type:

    int | None

  Parameters:

    - n_windows (int)

    - scale_range (Tuple[float, float])

    - trend_degree (int)

    - n_crossovers (int | None)

  fit(data, ch_name=None)

    Fits the specified by the object fractal model to provided data.

    Parameters:

      - data (_ActiData) – Actigraphic data to be fitted with cosinor method.

      - ch_name (str | None, optional) – Channel to which model will be fitted. If None, it will be to_score in case of Raw or Epoched data and score in case of ScoredShort data. Defaults to None.

    Returns:

      Object containing fitting results.

    Return type:

      DFAResults

class DFAResults(scales, fluctuations, exponent, scale_range, crossovers, degree, id)

  A container for results of fitting DFA model to the actigraphic data. Do not construct manually! The following parameters are available in the fit_params:

  - exponent: the exponent of the whole data over all fluctuation range;

  - exponent error: the error of exponent estimation;

  - scale range: range of scales used during the fitting;

  - segments: segments in which the data was divided;

  - trend degree: trend degree used during the detrending prior to fitting model.

  Parameters:

    - scales (numpy.ndarray)

    - fluctuations (numpy.ndarray)

    - exponent (Tuple[float, float])

    - scale_range (Tuple[float, float])

    - crossovers (Tuple[dict | None, numpy.ndarray])

    - degree (int)

    - id (str)

  export(out_path)

    Save data (both parameters of model and fluctuations data) to compressed generic file.

    Parameters:

      out_path (str) – Path to the out file.

  static load_file(path)

    Load model fitting results from .ada.long file (created via export method).

    Parameters:

      path (str) – Path to file.

    Returns:

      Object containing fitted model.

    Return type:

      DFAResults

  plot(out_path=None)

    Plot the semi-logarithmic fluctuations plot.

    Parameters:

      out_path (str | None, optional) – Path to save the figure. If None, it will be shown in interactive mode. Defaults to None.

  save_csv(out_path)

    Save parameters of fitted model to human-readable csv.

    Parameters:

      out_path (str) – Path to the out file.

  property crossovers: Tuple[list[float], list[Tuple[float, float]]]

    List with positions of crossovers (in hours) and list of their confidence intervals.

    Return type:

      Tuple[list[float], list[Tuple[float, float]]]

  property exponents: Tuple[list[float], list[float]]

    List with exponents and list of their errors.

    Return type:

      Tuple[list[float], list[float]]

  property fit_params: dict

    Parameters of the fitted model.

    Return type:

      dict

  property fluctuations: numpy.ndarray

    Array of obtained fluctuations at different scales.

    Return type:

      numpy.ndarray

  property id: str

    ID of a recording to which long estimate was fit.

    Return type:

      str

  property piecewise_fit: numpy.ndarray

    Array with reconstruction of fitted piecewise linear function.

    Return type:

      numpy.ndarray

  property scales: numpy.ndarray

    Array of scale for which fluctuations were computed.

    Return type:

      numpy.ndarray

class SimpleNonparametric

  A class for estimating basic metrics reflecting 24 hour periodicity in the data. These are:

  - Interdaily stability (IS): reflects how similar days are to each other in 24 hour windows. Contained in [0, 1] with higher values meaning higher regularity.

  - Intradaily variability (IV): reflects variability of activity levels during the day; higher values mean higher fragmentation (potential circadian disturbances).

  - M10: mean activity in the most active 10 hours during each day.

  - L5: mean activity in the least active 5 hours during each day.

  For details see Witting W, Kwa IH, Eikelenboom P, Mirmiran M, Swaab DF. Alterations in the circadian rest-activity rhythm in aging and Alzheimer’s disease. Biol Psychiatry. 1990 Mar 15;27(6):563-72.

  fit(data, ch_name=None)

    Computes basic nonparametric metrics estimating 24 hour periodicity in the data.

    Parameters:

      - data (_ActiData) – Input data.

      - ch_name (str | None, optional) – Channel on which computation will be done. If None, default will be used. Defaults to None.

    Returns:

      Container with all the results.

    Return type:

      SimpleNonparametricResults

  window_size = 60

class SimpleNonparametricResults(interdaily_stability, intradaily_variability, m10, l5, id)

  Container for simple nonparametric metrics. Do not construct manually! Following fields are available in fit params (coresponding to the fitted metrics):

  - IS

  - IV

  - M10

  - L5

  export(out_path)

    Save data to compressed generic file.

    Parameters:

      out_path (str) – Path to the out file.

  static load_file(path)

    Load model fitting results from .ada.long file (created via export method).

    Parameters:

      path (str) – Path to file.

    Returns:

      Object containing fitted model.

    Return type:

      SimpleNonparametricResults

  plot(out_path=None)

    There is absolutely nothing to plot when it comes to this metrics.

    Parameters:

      out_path (str | None)

  save_csv(out_path)

    Save parameters of fitted model to human-readable csv.

    Parameters:

      out_path (str) – Path to the out file.

  property fit_params: dict

    Parameters of the fitted model.

    Return type:

      dict

  property id: str

    ID of a recording to which long estimate was fit.

    Return type:

      str