skdh.io.ReadEmpaticaAvro#

class skdh.io.ReadEmpaticaAvro(trim_keys=None, resample_to_accel=True)#

Read Empatica data from an avro file.

Parameters:
trim_keys{None, tuple}, optional

Trim keys provided in the predict method. Default (None) will not do any trimming. Trimming of either start or end can be accomplished by providing None in the place of the key you do not want to trim. If provided, the tuple should be of the form (start_key, end_key). When provided, trim datetimes will be assumed to be in the same timezone as the data (ie naive if naive, or in the timezone provided).

resample_to_accelbool, optional

Resample any additional data streams to match the accelerometer data stream. Default is True.

Methods

convert_timestamps(t)

Convert a timestamp/array of timestamps to a datetime object

get_accel(raw_accel_dict, results_dict, key)

Get the raw acceleration data from the avro file record.

get_datastreams(raw_record)

Get the various data streams from the raw avro file record.

get_gyroscope(raw_gyro_dict, results_dict, key)

Get the raw gyroscope data from the avro file record.

get_steps(raw_dict, results_dict, key)

Get the raw steps data from the avro file record.

get_systolic_peaks(raw_dict, results_dict, key)

Get the systolic peaks data from the avro file record.

get_values_1d(raw_dict, results_dict, key)

Get the raw 1-dimensional values data from the avro file record.

handle_resampling(streams)

Handle resampling of data streams.

predict(*, file[, tz_name])

Read the input .avro file.

save_results(results, file_name)

Save the results of the processing pipeline to a csv file

trim_data(trim_start_factor, start_key, ...)

Trim data based on either a start factor or start/end keys

trim_data_factor(trim_start_factor, *, time, ...)

Trim raw data based on a factor of seconds.

trim_data_time(start_key, end_key, tz_name, ...)

Trim raw data based on provided date-times

get_accel(raw_accel_dict, results_dict, key)#

Get the raw acceleration data from the avro file record.

Parameters:
raw_accel_dictdict

The record from the avro file for a raw data stream.

results_dictdict

Dictionary where the results will go.

keystr

Name for the results in results_dict.

get_datastreams(raw_record)#

Get the various data streams from the raw avro file record.

Parameters:
raw_recorddict

The raw avro file record

Returns:
data_streamsdict

Dictionary containing the data streams

get_gyroscope(raw_gyro_dict, results_dict, key)#

Get the raw gyroscope data from the avro file record.

Parameters:
raw_gyro_dictdict

The record from the avro file for a raw gyroscope data stream.

results_dictdict

Dictionary where the results will go.

keystr

Name for the results in results_dict.

get_steps(raw_dict, results_dict, key)#

Get the raw steps data from the avro file record.

Parameters:
raw_dictdict

The record from the avro file for raw steps data.

results_dictdict

Dictionary where the results will go.

keystr

Name for the results in results_dict.

static get_systolic_peaks(raw_dict, results_dict, key)#

Get the systolic peaks data from the avro file record.

Parameters:
raw_dictdict

The record from the avro file for systolic peaks data.

results_dictdict

Dictionary where the results will go.

keystr

Name for the results in results_dict.

get_values_1d(raw_dict, results_dict, key)#

Get the raw 1-dimensional values data from the avro file record.

Parameters:
raw_dictdict

The record from the avro file for a raw 1-dimensional values data stream.

results_dictdict

Dictionary where the results will go.

keystr

Name for the results in results_dict.

handle_resampling(streams)#

Handle resampling of data streams. Data will be resampled to match the accelerometer data stream.

Parameters:
streamsdict

Dictionary containing the data streams

Returns:
rs_streamsdict

Dictionary containing the resampled data streams

predict(*, file, tz_name=None, **kwargs)#

Read the input .avro file.

Parameters:
file{path-like, str}

The path to the input file.

tz_name{None, optional}

IANA time-zone name for the recording location. If not provided, timestamps will represent local time naively. This means they will not account for any time changes due to Daylight Saving Time.

Returns:
resultsdict

Dictionary containing the data streams from the file. See Notes for different output options.

Notes

There are two output formats, based on if resample_to_accel is True or False. If True, all available data streams except for systolic_peaks and steps are resampled to match the accelerometer data stream, which results in their values being present in the top level of the results dictionary, ie results[‘gyro’], etc.

If False, everything except accelerometer will be present in dictionaries containing the keys time, fs, and values, and the top level will be these dictionaries plus the accelerometer data (keys time, fs, and accel).

systolic_peaks will always be a dictionary of the form {‘systolic_peaks’: array}.