Sleep fragmentation via state transition probability

“Quantification of the Fragmentation of Rest-Activity Patterns in Elderly Individuals Using a State Transition Analysis”

Andrew S.P. Lim, MD, Lei Yu, PhD, Madalena D. Costa, PhD, Aron S. Buchman, MD, David A. Bennett, MD, Sue E. Leurgans, PhD, Clifford B. Saper, MD, PhD

Sleep, Volume 34, Issue 11, 1 November 2011, Pages 1569–1581, https://doi.org/10.5665/sleep.1400

[1]:
import pyActigraphy
[2]:
import plotly.graph_objs as go
[3]:
# create objects for layout and traces
layout = go.Layout(title="",xaxis=dict(title=""), showlegend=False)

Read an individual actigraphy file

[4]:
# retrieve path to example files
import os
fpath = os.path.join(os.path.dirname(pyActigraphy.__file__),'tests/data/')
[5]:
raw = pyActigraphy.io.read_raw_awd(fpath+'example_01.AWD', period='7 days')

Quantify the Rest-to-activity transition probability

help(raw.kRA)

Rest to activity (kRA)

Before calculating the ‘kRA’, let’s look at the distribution of the transition probabilities as a function of the length of the sustained rest periods:

[6]:
pRA, pRA_weights = raw.pRA(0, start='00:00:00', period='8H')
[7]:
layout.update(title="Rest->Activity transition probability",xaxis=dict(title="Time [min]"), showlegend=False);
[8]:
go.Figure(data=go.Scatter(x=pRA.index, y=pRA, name='', mode = 'markers'), layout=layout)

“The values kAR and kRA are metrics of the transition probabilities once sustained activity or rest have been attained”

In pyActigraphy, it is as simple as:

[9]:
raw.kRA(0)
[9]:
0.12337472433074494

To use the kRA (Rest-to-activity) as a a mesure of sleep fragmentation, it might be interesting to restrict the data to specific time windows (i.e. the night):

[10]:
raw.kRA(0, start='22:00:00', period='8H')
[10]:
0.1657160156790255

However, it might be tedious to estimate manually the correct time window.

The pyActigraphy package provide the users with a simple way to do this automatically;

it relies on the activity onset and offset times derived from the daily activity profile.

[11]:
raw.kRA(0, start='AoffT', freq='15min')
[11]:
0.15845745364361488

Activity to rest (kAR)

[12]:
raw.kAR(0)
[12]:
0.03592473838340913
[13]:
raw.kAR(0, start='AonT', freq='15min')
[13]:
0.03431133223136525

Et voilà! Easy, isn’t it?