BaseRaw class

class pyActigraphy.io.BaseRaw(name, uuid, format, axial_mode, start_time, period, frequency, data, light, fpath=None)[source]

Base class for raw data.

property activity_report

Activity report accessor

property axial_mode

Acquistion mode (mono-axial or tri-axial)

binarized_data(threshold)[source]

Boolean thresholding of Pandas Series

create_activity_report(cut_points, labels=None, threshold=None, start_time=None, stop_time=None, oformat=None, verbose=False)[source]

Activity report.

Create an activity report with aggregated statistics on activity levels and time spent between the specified cut-points.

Parameters
  • cut_points (array) – Activity cut-points. If all the values are below 1, they are interpreted as percentiles of the activity counts. Lower (i.e -infinity count) and upper (i.e infinity count) boundaries are automatically added.

  • labels (array, optional) – Labels for the intervals defined by the cut points. The number of labels should be N+1 for N cut-points. If set to None, the cut points are used to define the labels. Default is None.

  • threshold (float, optional) – If not set to None, discard data below threshold before computing activity ranges. Default is None.

  • start_time (str, optional) – If not set to None, discard data before start time, on a daily basis. Supported time string: ‘HH:MM:SS’ Default is None.

  • stop_time (str, optional) – If not set to None, discard data after stop time, on a daily basis. Supported time string: ‘HH:MM:SS’ Default is None.

  • oformat (str, optional) – Output format. Available formats: ‘minute’ or ‘timedelta’. If set to ‘minute’, the result is in number of minutes. If set to ‘timedelta’, the result is a pd.Timedelta. If set to None, the result is in number of epochs. Default is None.

  • verbose (bool, optional) – If set to True, print out info about the cut points. Default is False.

create_sleep_report(states=['NIGHT'], state_scoring={'NIGHT': 1}, convert_td_to_num_min=True, verbose=False, scoring_algo='Scripps', *args, **kwargs)[source]

Sleep report.

Create an sleep report using the periods reported in the sleep diary as periods of interest.

Parameters
  • states (list) – List of types of periods of interest. Should match the types reported in the sleep diary file.

  • state_scoring (dict) – Expected scores from the sleep algorithm for the states of interest.

  • convert_dt_to_num_min (bool, optional) – If set to True, all durations are reported in minutes instead of pd.Timedelta.

  • verbose (bool, optional) – If set to True, print out info about periods found in the sleep diary. Default is False.

  • scoring_algo (str, optional) – Sleep/wake scoring algorithm to use. Default is ‘Scripps’.

  • *args – Variable length argument list passed to the scoring algorithm.

  • **kwargs – Arbitrary keyword arguments passed to the scoring algorithm.

property data

Indexed data extracted from the raw file. If mask_inactivity is set to true, the mask is used to filter out inactive data.

property display_name

Name to be used for display.

duration()[source]

Duration (in days, hours, etc) of the data acquistion period

property exclude_if_mask

Boolean to exclude partially masked data when resampling

property format

Format of the raw data file (AWD,RPX,MTN,…)

property fpath

Absolute path of the raw input file.

property frequency

Acquisition frequency as extracted from the raw file.

property inactivity_length

Length of the inactivity mask.

length()[source]

Number of data acquisition points

property light

Light measurement performed by the device

property mask

Mask used to filter out inactive data.

mask_fraction(start=None, stop=None)[source]

Fraction of masked data

mask_fraction_period(period='7D', verbose=False)[source]

Mask fraction per consecutive periods

property mask_inactivity

Switch to mask inactive data.

property name

Study name as extracted from the raw file.

property period

Period of data acquistion as extracted from the raw file or specified by the user.

property raw_data

Indexed data extracted from the raw file.

property raw_light

Light measurement performed by the device

read_sleep_diary(input_fname, header_size=2, state_index={'ACTIVE': 2, 'NAP': 1, 'NIGHT': 0, 'NOWEAR': -1}, state_colour={'NAP': '#7bc043', 'NIGHT': '#d3d3d3', 'NOWEAR': '#ee4035'})[source]

Reader function for sleep diaries.

Parameters
  • input_fname (str) – Path to the sleep diary file.

  • header_size (int) – Header size (i.e. number of lines) of the sleep diary. Default is 2.

  • state_index (dict) – The dictionnary of state’s indices. Default is ACTIVE=2, NAP=1, NIGHT=0, NOWEAR=-1.

  • state_color (dict) – The dictionnary of state’s colours. Default is NAP=’#7bc043’, NIGHT=’#d3d3d3’, NOWEAR=’#ee4035’.

resampled_data(freq, binarize=False, threshold=0)[source]

Data resampled at the specified frequency. If mask_inactivity is True, the mask is used to filter inactive data.

resampled_light(freq)[source]

Light measurement, resampled at the specified frequency.

property sleep_diary

SleepDiary class instanciation.

property sleep_report

Sleep report accessor

property start_time

Start time of data acquistion as extracted from the raw file or specified by the user.

time_range()[source]

Range (in days, hours, etc) of the data acquistion period

property uuid

UUID of the device used to acquire the data