Start guide for the devicely package

To install devicely locally just run pip install devicely

Use devicely

[43]:
import os

import devicely

write_dir = 'New'

if not os.path.isdir(write_dir):
    os.makedirs(write_dir)

Empatica E4

The Empatice E4 wristband can be used to obtain data from inter-beat intervals, electrodermal activity, heart rate, temperature and blood volume pulse. The wristband uses this directory structure for its measurement data.

Read the data

Create an EmpaticaReader object:

[44]:
empatica_reader = devicely.EmpaticaReader('Empatica')

Access the sampling frequencies and starting times for all signals:

[45]:
empatica_reader.start_times
[45]:
{'ACC': Timestamp('2020-10-16 17:04:29'),
 'BVP': Timestamp('2020-10-16 17:04:29'),
 'EDA': Timestamp('2020-10-16 17:04:29'),
 'HR': Timestamp('2020-10-16 17:04:39'),
 'TEMP': Timestamp('2020-10-16 17:04:29'),
 'IBI': Timestamp('2020-10-16 17:04:29')}
[46]:
empatica_reader.sample_freqs
[46]:
{'ACC': 32.0, 'BVP': 64.0, 'EDA': 4.0, 'HR': 1.0, 'TEMP': 4.0}

Access the individual dataframes via the attributes ACC, BVP, EDA, HR, TEMP, IBI and tags:

[47]:
empatica_reader.HR.head()
[47]:
2020-10-16 17:04:39    51.00
2020-10-16 17:04:40    51.50
2020-10-16 17:04:41    51.00
2020-10-16 17:04:42    52.75
2020-10-16 17:04:43    64.00
Name: HR, dtype: float64

Access a joined dataframe of all signals:

[48]:
empatica_reader.data.head()
[48]:
ACC_X ACC_Y ACC_Z BVP EDA HR TEMP
2020-10-16 17:04:29.000000 -3.0 11.0 60.0 -0.0 0.0 NaN 31.13
2020-10-16 17:04:29.015625 NaN NaN NaN -0.0 NaN NaN NaN
2020-10-16 17:04:29.031250 -3.0 11.0 60.0 -0.0 NaN NaN NaN
2020-10-16 17:04:29.046875 NaN NaN NaN -0.0 NaN NaN NaN
2020-10-16 17:04:29.062500 -2.0 11.0 60.0 -0.0 NaN NaN NaN

The dataframe contains nan values because the individual signals have different sampling frequencies.

Timeshift the data

Apply a timeshift:

[49]:
empatica_reader.timeshift()
empatica_reader.start_times
[49]:
{'ACC': Timestamp('2019-05-18 22:02:53.817793664'),
 'BVP': Timestamp('2019-05-18 22:02:53.817793664'),
 'EDA': Timestamp('2019-05-18 22:02:53.817793664'),
 'HR': Timestamp('2019-05-18 22:03:03.817793664'),
 'TEMP': Timestamp('2019-05-18 22:02:53.817793664'),
 'IBI': Timestamp('2019-05-18 22:02:53.817793664')}

By providing no parameter to timeshift the data is shifted by a random time interval between one month and two years to the past. You can also provide a pandas.Timedelta object to shift the data by that timedelta or a pandas.Timestamp object to shift the data such that this timestamp is the earliest entry.

Write the data

[50]:
empatica_write_path = os.path.join(write_dir, 'Empatica')
empatica_reader.write(empatica_write_path)
os.listdir(empatica_write_path)
[50]:
['EDA.csv', 'HR.csv', 'IBI.csv', 'TEMP.csv', 'tags.csv', 'BVP.csv', 'ACC.csv']

Spacelabs Blood Pressure Monitor

Spacelabs uses a single file to output its metadata as well as the actual signals.

Read the data

Create a SpacelabsReader object:

[51]:
spacelabs_reader = devicely.SpacelabsReader(os.path.join('Spacelabs', 'spacelabs.abp'))

Acess the metadata:

[52]:
spacelabs_reader.subject
[52]:
'001V0'
[53]:
spacelabs_reader.metadata
[53]:
{'PATIENTINFO': {'DOB': None, 'RACE': None},
 'REPORTINFO': {'PHYSICIAN': None,
  'NURSETECH': 'admin',
  'STATUS': 'NOTCONFIRMED',
  'CALIPERSUMMARY': {'COUNT': '0'}}}

Access the signal dataframe:

[54]:
spacelabs_reader.data.head()
[54]:
date time SYS(mmHg) DIA(mmHg) UNKNOW_1 UNKNOW_2 UNKNOW_3 CODE
timestamp
2019-03-01 16:18:00 2019-03-01 16:18:00 107 76 78.0 78.0 NaN NaN
2019-03-01 16:19:00 2019-03-01 16:19:00 96 62 63.0 63.0 NaN NaN
2019-03-01 16:22:00 2019-03-01 16:22:00 100 68 64.0 64.0 NaN NaN
2019-03-01 16:23:00 2019-03-01 16:23:00 103 68 68.0 68.0 NaN NaN
2019-03-01 16:25:00 2019-03-01 16:25:00 101 67 65.0 65.0 NaN NaN

Timeshift the data

Apply a timeshift:

[55]:
spacelabs_reader.timeshift()
spacelabs_reader.data.head()
[55]:
date time SYS(mmHg) DIA(mmHg) UNKNOW_1 UNKNOW_2 UNKNOW_3 CODE
timestamp
2018-02-28 18:14:00 2018-02-28 18:14:00 107 76 78.0 78.0 NaN NaN
2018-02-28 18:15:00 2018-02-28 18:15:00 96 62 63.0 63.0 NaN NaN
2018-02-28 18:18:00 2018-02-28 18:18:00 100 68 64.0 64.0 NaN NaN
2018-02-28 18:19:00 2018-02-28 18:19:00 103 68 68.0 68.0 NaN NaN
2018-02-28 18:21:00 2018-02-28 18:21:00 101 67 65.0 65.0 NaN NaN

By providing no parameter to timeshift the data is shifted by a random time interval between one month and two years to the past. You can also provide a pandas.Timedelta object to shift the data by that timedelta or a pandas.Timestamp object to shift the data such that this timestamp is the earliest entry.

Remove metadata

[56]:
spacelabs_reader.deidentify('001')
spacelabs_reader.metadata
[56]:
{'PATIENTINFO': {'DOB': '', 'RACE': ''},
 'REPORTINFO': {'PHYSICIAN': '',
  'NURSETECH': '',
  'STATUS': '',
  'CALIPERSUMMARY': {'COUNT': ''}}}

Write the data

[57]:
spacelabs_write_path = os.path.join(write_dir, 'Spacelabs')

if not os.path.isdir(spacelabs_write_path):
    os.makedirs(spacelabs_write_path)

spacelabs_reader.write(os.path.join(spacelabs_write_path, 'spacelabs.abp'))
os.listdir(spacelabs_write_path)
[57]:
['spacelabs.abp']

Bittium Faros

The Faros device outpus data in EDF files. These are specifically made for health sensor data and not human-readable.

Read the data

[58]:
faros_reader = devicely.FarosReader(os.path.join('Faros', 'faros.EDF'))

Access metadata:

[59]:
faros_reader.start_time
[59]:
Timestamp('2019-03-01 16:12:43')
[60]:
faros_reader.sample_freqs
[60]:
{'ECG': 1000.0, 'ACC': 100.0, 'Marker': 1.0, 'HRV': 5.0}
[61]:
faros_reader.units
[61]:
{'ECG': 'uV', 'ACC': 'mg', 'HRV': 'ms'}

You can access the individual signals via the ECG, ACC, HRV and Marker attributes:

[62]:
faros_reader.ACC.head()
[62]:
X Y Z
2019-03-01 16:12:43.000 164.0 23.0 -1172.0
2019-03-01 16:12:43.010 152.0 23.0 -1172.0
2019-03-01 16:12:43.020 152.0 -24.0 -1079.0
2019-03-01 16:12:43.030 117.0 11.0 -985.0
2019-03-01 16:12:43.040 -47.0 246.0 -1125.0

Join the dataframes:

[63]:
faros_reader.join_dataframes()
faros_reader.data.head()
[63]:
ECG ACC_X ACC_Y ACC_Z ACC_mag Marker HRV
2019-03-01 16:12:43.000 26.0 164.0 23.0 -1172.0 NaN 0.0 0.0
2019-03-01 16:12:43.001 -6.0 NaN NaN NaN NaN NaN NaN
2019-03-01 16:12:43.002 -31.0 NaN NaN NaN NaN NaN NaN
2019-03-01 16:12:43.003 -39.0 NaN NaN NaN NaN NaN NaN
2019-03-01 16:12:43.004 -17.0 NaN NaN NaN NaN NaN NaN

Timeshift the data

Apply a timeshift:

[64]:
faros_reader.timeshift()
faros_reader.data.head()
[64]:
ECG ACC_X ACC_Y ACC_Z ACC_mag Marker HRV
2018-02-22 09:32:12.000 26.0 164.0 23.0 -1172.0 NaN 0.0 0.0
2018-02-22 09:32:12.001 -6.0 NaN NaN NaN NaN NaN NaN
2018-02-22 09:32:12.002 -31.0 NaN NaN NaN NaN NaN NaN
2018-02-22 09:32:12.003 -39.0 NaN NaN NaN NaN NaN NaN
2018-02-22 09:32:12.004 -17.0 NaN NaN NaN NaN NaN NaN

By providing no parameter to timeshift the data is shifted by a random time interval between one month and two years to the past. You can also provide a pandas.Timedelta object to shift the data by that timedelta or a pandas.Timestamp object to shift the data such that this timestamp is the earliest entry.

Write the data

You can write back the data in the original EDF format or to a directory of individual signal files. Writing to a directory is the preferred method. You can find out why this is the case in our module reference.

[65]:
faros_write_path = os.path.join(write_dir, 'Faros')
faros_reader.write(faros_write_path)
os.listdir(faros_write_path)
[65]:
['Marker.csv', 'ECG.csv', 'HRV.csv', 'faros.edf', 'meta.json', 'ACC.csv']

You can also create a FarosReader from a written directory:

[66]:
new_faros_reader = devicely.FarosReader(faros_write_path)
new_faros_reader.ECG.head()
[66]:
2019-03-01 16:12:43.000    26.0
2019-03-01 16:12:43.001    -6.0
2019-03-01 16:12:43.002   -31.0
2019-03-01 16:12:43.003   -39.0
2019-03-01 16:12:43.004   -17.0
Freq: L, Name: ECG, dtype: float64

You can also save files as EDF if the necessary metadata are still present.

[67]:
faros_write_new_path = os.path.join(write_dir, 'Faros', 'faros.edf')
faros_reader.write(faros_write_new_path, file_format='edf')
os.listdir(faros_write_path)
[67]:
['Marker.csv', 'ECG.csv', 'HRV.csv', 'faros.edf', 'meta.json', 'ACC.csv']

Biovotion Everion

The Everion device outputs data in multiple csv files. Each csv file has a tag column which specifies the type of measurement. You can see the different tags and what they mean by looking at EverionReader.SIGNAL_TAGS, EverionReader.SENSOR_TAGS and EverionReader.FEATURE_TAGS.

[68]:
devicely.EverionReader.FEATURE_TAGS
[68]:
{14: 'inter_pulse_interval',
 17: 'pis',
 18: 'pid',
 77: 'inter_pulse_deviation',
 78: 'pis_quality',
 79: 'pid_quality'}

Read the data

[69]:
everion_reader = devicely.EverionReader('Everion')

If you would like to specify which tags to keep, you can specify this when initializing the reader.

Access the individual dataframes via aggregates, analytics_events, attributes_dailys, everion_events, features, sensors and signals attributes:

[70]:
everion_reader.signals.head()
[70]:
count streamType tag time values quality
0 806132 2 71 2019-03-01 15:39:58 0.000000 NaN
1 806132 2 13 2019-03-01 15:39:58 21.864220 100.0
2 806132 2 6 2019-03-01 15:39:58 65.000000 85.0
3 806132 2 66 2019-03-01 15:39:58 1.568628 NaN
4 806132 2 12 2019-03-01 15:39:58 18.000000 93.0

Access a joined dataframe of all signals:

[71]:
everion_reader.data.head()
[71]:
heart_rate heart_rate_quality oxygen_saturation oxygen_saturation_quality heart_rate_variability heart_rate_variability_quality respiration_rate respiration_rate_quality ctemp ctemp_quality ... inter_pulse_interval inter_pulse_interval_deviation led1_data led2_data led3_data led4_data accx_data accy_data accz_data acc_mag
time
2019-03-01 13:23:05.000000000 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN 3028.0 2989.0 2924.0 3340.0 368.0 2096.0 -3536.0 4126.976617
2019-03-01 13:23:05.019607808 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN 3309.0 3336.0 3231.0 3417.0 256.0 2016.0 -3808.0 4316.324362
2019-03-01 13:23:05.039215872 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN 3454.0 3443.0 3390.0 3492.0 144.0 2288.0 -3728.0 4376.489918
2019-03-01 13:23:05.058823680 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN 3207.0 3217.0 3126.0 3543.0 96.0 2352.0 -3600.0 4301.292829
2019-03-01 13:23:05.078431488 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN 3079.0 3092.0 2994.0 3538.0 0.0 2384.0 -3904.0 4574.349353

5 rows × 25 columns

Timeshift the data

Apply a timeshift:

[72]:
everion_reader.timeshift()
everion_reader.data.head()
[72]:
heart_rate heart_rate_quality oxygen_saturation oxygen_saturation_quality heart_rate_variability heart_rate_variability_quality respiration_rate respiration_rate_quality ctemp ctemp_quality ... inter_pulse_interval inter_pulse_interval_deviation led1_data led2_data led3_data led4_data accx_data accy_data accz_data acc_mag
time
2017-04-01 20:53:51.000000000 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN 3028.0 2989.0 2924.0 3340.0 368.0 2096.0 -3536.0 4126.976617
2017-04-01 20:53:51.019607808 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN 3309.0 3336.0 3231.0 3417.0 256.0 2016.0 -3808.0 4316.324362
2017-04-01 20:53:51.039215872 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN 3454.0 3443.0 3390.0 3492.0 144.0 2288.0 -3728.0 4376.489918
2017-04-01 20:53:51.058823680 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN 3207.0 3217.0 3126.0 3543.0 96.0 2352.0 -3600.0 4301.292829
2017-04-01 20:53:51.078431488 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN 3079.0 3092.0 2994.0 3538.0 0.0 2384.0 -3904.0 4574.349353

5 rows × 25 columns

By providing no parameter to timeshift the data is shifted by a random time interval between one month and two years to the past. You can also provide a pandas.Timedelta object to shift the data by that timedelta or a pandas.Timestamp object to shift the data such that this timestamp is the earliest entry.

Write the data

Write the data to a directory while keeping the same format as the original. If you used only a subset of tags when initializing the reader, only these tags will be written.

[73]:
everion_write_path = os.path.join(write_dir, 'Everion')
everion_reader.write(everion_write_path)
os.listdir(everion_write_path)
[73]:
['sensor_data.csv',
 'analytics_events.csv',
 'aggregates.csv',
 'everion_events.csv',
 'attributes_dailys.csv',
 'signals.csv',
 'features.csv']

Shimmer

Shimmer uses a single CSV file, indexed by time of measurement.

Read the data

[74]:
shimmer_reader = devicely.ShimmerPlusReader(os.path.join('Shimmer', 'shimmer.csv'))
shimmer_reader.data.head()
[74]:
Shimmer_40AC_Timestamp_Unix_CAL Shimmer_40AC_Accel_LN_X_CAL Shimmer_40AC_Accel_LN_Y_CAL Shimmer_40AC_Accel_LN_Z_CAL Shimmer_40AC_Accel_WR_X_CAL Shimmer_40AC_Accel_WR_Y_CAL Shimmer_40AC_Accel_WR_Z_CAL Shimmer_40AC_Battery_CAL Shimmer_40AC_Ext_Exp_A15_CAL Shimmer_40AC_GSR_Range_CAL ... Shimmer_40AC_Gyro_X_CAL Shimmer_40AC_Gyro_Y_CAL Shimmer_40AC_Gyro_Z_CAL Shimmer_40AC_Int_Exp_A12_CAL Shimmer_40AC_Mag_X_CAL Shimmer_40AC_Mag_Y_CAL Shimmer_40AC_Mag_Z_CAL Shimmer_40AC_Pressure_BMP280_CAL Shimmer_40AC_Temperature_BMP280_CAL Shimmer_40AC_Accel_LN_mag
0 2020-07-28 10:56:50.034 -1.434783 10.0 0.554348 -3.930580 8.421305 -1.620586 4139.194139 1684.981685 2.0 ... 0.137405 1.877863 -0.183206 1680.586081 -0.112444 -0.916042 -0.047976 100.435379 33.365878 10.117604
1 2020-07-28 10:56:50.057 -1.402174 10.0 0.554348 -3.923399 8.442849 -1.599042 4137.728938 1673.260073 2.0 ... 0.183206 1.328244 -0.412214 1703.296703 -0.109445 -0.913043 -0.047976 100.429731 33.365878 10.113031
2 2020-07-28 10:56:50.074 -1.434783 10.0 0.554348 -3.897068 8.428486 -1.603830 4111.355311 1901.098901 2.0 ... 0.274809 1.282443 -0.198473 1687.179487 -0.107946 -0.910045 -0.049475 100.441027 33.365878 10.117604
3 2020-07-28 10:56:50.099 -1.413043 10.0 0.521739 -3.932974 8.421305 -1.589467 4140.659341 1722.344322 2.0 ... 0.229008 1.450382 -0.122137 1650.549451 -0.106447 -0.901049 -0.050975 100.441027 33.365878 10.112809
4 2020-07-28 10:56:50.111 -1.445652 10.0 0.510870 -3.944943 8.428486 -1.661281 4134.798535 1678.388278 2.0 ... 0.137405 1.511450 -0.473282 1701.831502 -0.113943 -0.904048 -0.037481 100.438203 33.365878 10.116862

5 rows × 22 columns

Timeshift the data

Apply a timeshift:

[75]:
shimmer_reader.timeshift()
shimmer_reader.data.head()
[75]:
Shimmer_40AC_Timestamp_Unix_CAL Shimmer_40AC_Accel_LN_X_CAL Shimmer_40AC_Accel_LN_Y_CAL Shimmer_40AC_Accel_LN_Z_CAL Shimmer_40AC_Accel_WR_X_CAL Shimmer_40AC_Accel_WR_Y_CAL Shimmer_40AC_Accel_WR_Z_CAL Shimmer_40AC_Battery_CAL Shimmer_40AC_Ext_Exp_A15_CAL Shimmer_40AC_GSR_Range_CAL ... Shimmer_40AC_Gyro_X_CAL Shimmer_40AC_Gyro_Y_CAL Shimmer_40AC_Gyro_Z_CAL Shimmer_40AC_Int_Exp_A12_CAL Shimmer_40AC_Mag_X_CAL Shimmer_40AC_Mag_Y_CAL Shimmer_40AC_Mag_Z_CAL Shimmer_40AC_Pressure_BMP280_CAL Shimmer_40AC_Temperature_BMP280_CAL Shimmer_40AC_Accel_LN_mag
0 2019-06-20 19:45:55.894 -1.434783 10.0 0.554348 -3.930580 8.421305 -1.620586 4139.194139 1684.981685 2.0 ... 0.137405 1.877863 -0.183206 1680.586081 -0.112444 -0.916042 -0.047976 100.435379 33.365878 10.117604
1 2019-06-20 19:45:55.917 -1.402174 10.0 0.554348 -3.923399 8.442849 -1.599042 4137.728938 1673.260073 2.0 ... 0.183206 1.328244 -0.412214 1703.296703 -0.109445 -0.913043 -0.047976 100.429731 33.365878 10.113031
2 2019-06-20 19:45:55.934 -1.434783 10.0 0.554348 -3.897068 8.428486 -1.603830 4111.355311 1901.098901 2.0 ... 0.274809 1.282443 -0.198473 1687.179487 -0.107946 -0.910045 -0.049475 100.441027 33.365878 10.117604
3 2019-06-20 19:45:55.959 -1.413043 10.0 0.521739 -3.932974 8.421305 -1.589467 4140.659341 1722.344322 2.0 ... 0.229008 1.450382 -0.122137 1650.549451 -0.106447 -0.901049 -0.050975 100.441027 33.365878 10.112809
4 2019-06-20 19:45:55.971 -1.445652 10.0 0.510870 -3.944943 8.428486 -1.661281 4134.798535 1678.388278 2.0 ... 0.137405 1.511450 -0.473282 1701.831502 -0.113943 -0.904048 -0.037481 100.438203 33.365878 10.116862

5 rows × 22 columns

By providing no parameter to timeshift the data is shifted by a random time interval between one month and two years to the past. You can also provide a pandas.Timedelta object to shift the data by that timedelta or a pandas.Timestamp object to shift the data such that this timestamp is the earliest entry.

Write the data

[76]:
shimmer_write_path = os.path.join(write_dir, 'Shimmer')

if not os.path.isdir(shimmer_write_path):
    os.makedirs(shimmer_write_path)

shimmer_reader.write(os.path.join(shimmer_write_path, 'shimmer_write.csv'))
os.listdir(shimmer_write_path)
[76]:
['shimmer_write.csv']

Muse

The devicely.MuseReader can be used for reading data generated by the Muse S headband.

Read the data

[77]:
muse_reader = devicely.MuseReader(os.path.join('Muse', 'data.csv'))
muse_reader.data.head()
[77]:
Delta_TP9 Delta_AF7 Delta_AF8 Delta_TP10 Theta_TP9 Theta_AF7 Theta_AF8 Theta_TP10 Alpha_TP9 Alpha_AF7 ... Gyro_X Gyro_Y Gyro_Z HeadBandOn HSI_TP9 HSI_AF7 HSI_AF8 HSI_TP10 Battery Elements
TimeStamp
2021-05-24 20:26:20.103 0.735186 0.752212 0.714283 1.023466 0.251417 0.205159 0.208760 0.428435 0.493829 0.269544 ... 3.416901 0.605621 3.768311 1.0 2.0 1.0 1.0 2.0 100.0 NaN
2021-05-24 20:26:20.588 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN /muse/elements/blink
2021-05-24 20:26:21.161 1.063671 0.915956 0.734191 1.023466 1.120400 0.367509 0.303293 0.428435 0.974990 0.348580 ... 4.643097 2.355194 2.026215 1.0 1.0 1.0 1.0 1.0 100.0 NaN
2021-05-24 20:26:22.174 1.226523 0.791329 0.685841 0.550056 1.289343 0.647703 0.187995 0.070321 0.726045 0.420135 ... 4.239349 0.635529 3.484192 1.0 1.0 1.0 1.0 1.0 100.0 NaN
2021-05-24 20:26:23.184 1.009649 0.822014 0.677420 0.801944 1.035277 0.500738 -0.049515 0.673528 0.805443 0.446498 ... 4.366455 -0.052338 1.525269 1.0 1.0 1.0 1.0 1.0 100.0 NaN

5 rows × 38 columns

Timeshift the data

Apply a random timeshift:

[78]:
muse_reader.timeshift()
muse_reader.data.head()
[78]:
Delta_TP9 Delta_AF7 Delta_AF8 Delta_TP10 Theta_TP9 Theta_AF7 Theta_AF8 Theta_TP10 Alpha_TP9 Alpha_AF7 ... Gyro_X Gyro_Y Gyro_Z HeadBandOn HSI_TP9 HSI_AF7 HSI_AF8 HSI_TP10 Battery Elements
TimeStamp
2020-05-30 05:03:58.183587364 0.735186 0.752212 0.714283 1.023466 0.251417 0.205159 0.208760 0.428435 0.493829 0.269544 ... 3.416901 0.605621 3.768311 1.0 2.0 1.0 1.0 2.0 100.0 NaN
2020-05-30 05:03:58.668587364 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN /muse/elements/blink
2020-05-30 05:03:59.241587364 1.063671 0.915956 0.734191 1.023466 1.120400 0.367509 0.303293 0.428435 0.974990 0.348580 ... 4.643097 2.355194 2.026215 1.0 1.0 1.0 1.0 1.0 100.0 NaN
2020-05-30 05:04:00.254587364 1.226523 0.791329 0.685841 0.550056 1.289343 0.647703 0.187995 0.070321 0.726045 0.420135 ... 4.239349 0.635529 3.484192 1.0 1.0 1.0 1.0 1.0 100.0 NaN
2020-05-30 05:04:01.264587364 1.009649 0.822014 0.677420 0.801944 1.035277 0.500738 -0.049515 0.673528 0.805443 0.446498 ... 4.366455 -0.052338 1.525269 1.0 1.0 1.0 1.0 1.0 100.0 NaN

5 rows × 38 columns

Write the data

[79]:
muse_write_path = os.path.join(write_dir, 'muse_write_data.csv')

if os.path.isfile(muse_write_path):
    os.remove(muse_write_path)

muse_reader.write(muse_write_path)
os.listdir(write_dir)
[79]:
['Spacelabs',
 'Everion',
 'muse_write_data.csv',
 'Empatica',
 'Faros',
 'Tags',
 'Shimmer']

Tags

You can use the TimeStampReader to read data created by the Android app TimeStamp. Researchers use this app to mark important times during experiments. The format simple, as can be seen in this example file.

Read the data

[80]:
timestamp_reader = devicely.TimeStampReader(os.path.join('Tags', 'tags.csv'))
timestamp_reader.data.head()
[80]:
tag_number tag
time
2019-03-01 16:16:37 1 Shake
2019-03-01 16:17:43 2 Start
2019-03-01 16:18:20 3 BP Measurement
2019-03-01 16:19:51 4 BP Measurement
2019-03-01 16:22:00 5 BP Measurement

Timeshif the data

Apply a timeshift:

[81]:
timestamp_reader.timeshift()
timestamp_reader.data.head()
[81]:
tag_number tag
time
2017-09-12 21:26:48 1 Shake
2017-09-12 21:27:54 2 Start
2017-09-12 21:28:31 3 BP Measurement
2017-09-12 21:30:02 4 BP Measurement
2017-09-12 21:32:11 5 BP Measurement

By providing no parameter to timeshift the data is shifted by a random time interval between one month and two years to the past. You can also provide a pandas.Timedelta object to shift the data by that timedelta or a pandas.Timestamp object to shift the data such that this timestamp is the earliest entry.

Write the data

[82]:
tags_write_path = os.path.join(write_dir, 'Tags')

if not os.path.isdir(tags_write_path):
    os.makedirs(tags_write_path)

timestamp_reader.write(os.path.join(tags_write_path, 'tags_write.csv'))
os.listdir(tags_write_path)
[82]:
['tags_write.csv']