Using E4tools to process EDA data

Evan Kleiman

2019-02-11

library(E4tools)

This vignette can be used demonstration data that are already in the correct folder strucutre. You can download it here on our lab’s website. Download the ZIP file on the page and unzip it. But, do not unzip any of the zip files within subfolders.

Step 0: Structure your files

Your files should be structured in a way such that you have one main folder that contains within in, a subfolder for each participant. The name of each participant folder should be their ID number. In each “participant” subfolder should be all zip files containing their data, using the naming convention that E4 Connect uses (starttime_serialnumber.zip).

Step 1: Extract and filter raw EDA

This step is where you extract and filter EDA data. It will output raw data, filtered data (using user-specified high and low pass filters + a butterworth filter), and filtered + feature-scaled ([0,1]) data. It will also provide summary data at the participant and session level.

Inputs: (1) List of participant numbers and (2) location where ZIP folders are stored.

Outputs: (1) one RDS file per participant with all data, (2) summary file that gives participant-level meta-data.

Code

Sample of RDS output file

Participant E4_serial ts EDA_raw EDA_FeatureScaled EDA_filtered EDA_FeatureScaled_Filtered
1002 A004AD 1509472714 0.008967 0.0038622 0 0.0545558
1002 A004AD 1509472714 0.008967 0.0038622 0 0.0545558
1002 A004AD 1509472714 0.008967 0.0038622 0 0.0545558
1002 A004AD 1509472714 0.010248 0.0044140 0 0.0545558
1002 A004AD 1509472715 0.008967 0.0038622 0 0.0545558
1002 A004AD 1509472715 0.008967 0.0038622 0 0.0545558

Step 2: Extract button presses

This steps is where you extract button presses and remove presses that are within a certain number of minutes before the end of a session or that are too close to another button press. If the participant has not pressed the button at all, it will give you a warning and continue with the other participants.

Inputs: (1) List of participant numbers, (2) Location where ZIP folders are stored.

Output (one file per study): RDS file with list of IDs and button press times.

Code

Sample of RDS output file

ID ts
1001 1516310123
1001 1516314828
1003 1486516909
1003 1507301829
1003 1524532918
1003 1524537812

Step 3: Match button presses to EDA

This function allows you to extract the data that are within X minutes before and/or after a button press. If there are no button pressess for a participant, it will issue a warning and continue with the next participant. Inputs: (1) List of participant numbers, (2) location of individual EDA files from step 1, (3) location of button presses from step 2. Outputs: (1) RDS file with EDA data before and/or after button presses (and control data), for each participant and combined.

Code

Sample of RDS output file

ID E4_serial PressTime BeforeAfter CaseControl Data_TS EDA_raw EDA_filtered EDA_FeatureScaled EDA_FeatureScaled_Filtered
1001 A012B6 1516310122.96 BEFORE CASE 1516308923 1.610196 1.2971455909933 0.141776801799025 0.119519875295303
1001 A012B6 1516310122.96 BEFORE CASE 1516308923 1.607634 1.29760982407035 0.141551219220129 0.119562650046158
1001 A012B6 1516310122.96 BEFORE CASE 1516308923 1.575618 1.29809506398853 0.138732229428577 0.119607360381614
1001 A012B6 1516310122.96 BEFORE CASE 1516308923 1.515428 1.29860167083214 0.133432535664412 0.119654039480085
1001 A012B6 1516310122.96 BEFORE CASE 1516308924 1.502622 1.29912999569342 0.132304974967554 0.119702719691445
1001 A012B6 1516310122.96 BEFORE CASE 1516308924 1.475729 1.29968038079753 0.129937062284389 0.119753432548556

Step 4: Put matched EDA in to bins

E4_EDA_Process.part4.BinMatchedEDA(participant_list=c(1001:1003),
                                   rdslocation.MatchedEDA="~/Documents/E4tools_demo_data/output/matched_EDA/",
                                   min.after = 20,min.before = 20,
                                   rdslocation.BinnedMatchedEDA="~/Documents/E4tools_demo_data/output/")
#> Starting participant 1001
#> Starting participant 1002
#> Starting participant 1003

Sample of RDS output file

Note: The values for “MinBeforeAfter” for “before” values will be negative, to facilate things like growth curve modeling. If you positive integers, just multiple this column by -1.
ID PressTime BeforeAfter CaseControl MinBeforeAfter EDA_raw EDA_filtered EDA_FeatureScaled NA
1001 1516310123 BEFORE CASE -20 2.328195 1.937228 0.2049962 0.1784975
1001 1516310123 BEFORE CASE -18 3.790364 3.478413 0.3337393 0.3205033
1001 1516310123 BEFORE CASE -16 4.786790 4.623852 0.4214740 0.4260448
1001 1516310123 BEFORE CASE -14 4.896088 4.789263 0.4310976 0.4412859
1001 1516310123 BEFORE CASE -12 5.376001 5.307053 0.4733537 0.4889954
1001 1516310123 BEFORE CASE -10 5.453753 5.454288 0.4801997 0.5025618