Table of Contents

  • 1  Interdaily stability & intradaily variability

    • 1.1  Changing the resampling frequency

    • 1.2  Changing the threshold

    • 1.3  Without binarizing the data

  • 2  Relative amplitude

  • 3  Mean IS and IV

  • 4  IS, IV and RA per period

Non-parametric variables with pyActigraphy

Non-parametric variables such as:

  • Interdaily stability (IS)

  • Intradaily variability (IV)

  • Relative amplitude (RA)

can easily be calculated with the pyActigraphy package.

First import the pyActigraphy package and read your favorite actigraphy data file:

[1]:
import pyActigraphy
[2]:
import os
fpath = os.path.join(os.path.dirname(pyActigraphy.__file__),'tests/data/')
[3]:
# Read test file
raw = pyActigraphy.io.read_raw_awd(fpath+'example_01.AWD')

Interdaily stability & intradaily variability

For both variables, the default parameters are:

  • resampling frequency = ‘1H’

  • binarize data = True

  • threshold = 4

[4]:
raw.IS()
[4]:
0.527656245354158
[5]:
raw.IV()
[5]:
0.32913524895082263

However, it is possible to change these parameters.

Changing the resampling frequency

To calculate the IS&IV with a resampling frequency of 30 minutes, for example:

[6]:
raw.IS(freq='30min')
[6]:
0.49538299172546324
[7]:
raw.IV(freq='30min')
[7]:
0.314973337080311

Changing the threshold

To calculate IS&IV with a different threshold on the activity count when binarizing the data:

[8]:
raw.IS(threshold=10)
[8]:
0.5418567121727559
[9]:
raw.IV(threshold=10)
[9]:
0.33654319292100576

Without binarizing the data

It is also possible to calculate these variables without binarizing the data:

[10]:
raw.IS(binarize=False)
[10]:
0.46561431150973936
[11]:
raw.IV(binarize=False)
[11]:
0.7095292983583361

Relative amplitude

Similarly, the default parameters for the relative amplitude (RA) are:

  • binarize data = True

  • threshold = 4

It is not possible to specify a resampling frequency as the RA is independant of this parameter.

[12]:
raw.RA()
[12]:
0.7576503909857768
[13]:
raw.RA(binarize=False)
[13]:
0.9168632026873167

Mean IS and IV

In Nonparametric methods in actigraphy: An update, Gonçalves et al. introduced two new variables, ISm and IVm, as the mean of the IS and IV (respectively) values calculated as different resampling frequencies.

These two additional variables are also available in the pyActigraphy package. For both variables, the default parameters are:

  • resampling frequencies = [1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,30,32,36,40,45,48,60] (min)

  • binarize data = True

  • threshold = 4

[14]:
raw.ISm()
[14]:
0.47064337220625074
[15]:
raw.IVm()
[15]:
0.2706746158264432

To change the resampling frequencies:

[16]:
new_resampling_frequencies = ['5min','30min','1H']
[17]:
raw.ISm(freqs=new_resampling_frequencies)
[17]:
0.48841431777142963

IS, IV and RA per period

pyActigraphy introduces a new concept concerning the calculation of the non-parametric variables: it is now possible to calculate them per period.

The acquisition period is split in consecutive periods with the required length (if possible) and the non-parametric variable is then calculated for each period:

[18]:
raw.ISp()
[18]:
[0.6876777827182482]

By default, the period length is 7 days. But this parameter can easily be changed:

[19]:
# Period of 4 days for example
raw.ISp(period='4D')
[19]:
[0.629359516562714, 0.8780603587977001, 0.43948376768341835]

In order to find out how many periods were found in the actigraphy record:

[20]:
raw.ISp(period='4D', verbose=True)
Number of periods: 3
 Time unaccounted for: 0 days, 18h, 0m, 0s
[20]:
[0.629359516562714, 0.8780603587977001, 0.43948376768341835]

Et voilà!