ada.long.ar

ada.long.ar#

Classes#

ARResults

A class for storing results of AR model fitting. Do not construct manually! The fit_params gives access to the following fields:

Spectrum

A class for fitting an autoregressive (AR) model to the actigraphic data, and estimating circadian rhythm on this basis.

Module Contents#

class ARResults(a, sigma, f, s, filter, ci, id)[source]#

A class for storing results of AR model fitting. Do not construct manually! The fit_params gives access to the following fields:

  • coefficients: of fitted model

  • noise std: standard deviations of model noise

  • order: order of the model

  • peak: position of the main peak near to the 24 hours

  • preprocessing: whether it was used

  • period ci: confidence interval of the peak position estimated using bootstrap or None.

Parameters:
  • a (numpy.ndarray)

  • sigma (float)

  • f (numpy.ndarray)

  • s (numpy.ndarray)

  • filter (bool)

  • ci (Tuple[float, float] | None)

  • id (str)

export(out_path)[source]#

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

Parameters:

out_path (str) – Path to the out file.

static load_file(path)[source]#

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:

ARResults

plot(out_path=None)[source]#

Plot the power spectrum in the low frequency range together with the position of the main peak.

Parameters:

out_path (str | None) – Path to save the plot. If None, the plot will be opened in interactive window. Defaults to None.

save_csv(out_path)[source]#

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 freq: numpy.ndarray#

Frequency vector (x-axis of spectrum).

Return type:

numpy.ndarray

property id: str#

ID of a recording to which long estimate was fit.

Return type:

str

property spectrum: numpy.ndarray#

Power density calculated for given frequencies.

Return type:

numpy.ndarray

class Spectrum(order=None, preprocessing=False, use_bootstrap=False)[source]#

A class for fitting an autoregressive (AR) model to the actigraphic data, and estimating circadian rhythm on this basis.

Parameters:
  • order (int | None, optional) – Order of the model. If None, it will be selected automatically based on a heuristic (order = number of samples spanning 30 hours in the data). Defaults to None.

  • preprocessing (bool, optional) – Whether to filter data before model fitting. Defaults to False.

  • use_bootstrap (bool, optional) – Whether to estimate period confidence interval using bootrstrap. Might take some time, especially for shorter epoch lenghts. Defaults to False.

fit(data, ch_name=None)[source]#

Fit an AR model to the provided actiraphic data. It is highly recomended to epoch them using Downsampler, as other methods might not work at all with AR.

Parameters:
  • data (_ActiData) – Actigraphic data.

  • ch_name (str | None, optional) – Channel to which model will be fitted. to_score channel, when None. Defaults to None.

Returns:

Object containing results of the model fitting.

Return type:

ARResults