# Using E4tools to process EDA data

#### Evan Kleiman

#### 2019-07-07

    library(E4tools)

## 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

    E4_EDA_Process.part1.ExtractRawEDA(participant_list=c(1001),
                                       ziplocation="~/extdata/E4_demo_data/",
                                       rdslocation.EDA="~/extdata/output/raw_EDA/",
                                       summarylocation="~/extdata/output/summaries/",
                                       EDA_low_cut=0.001,LowPctCutoff=.75,
                                       EDA_high_cut=25,HighPctCutoff=.75)

#### Console output

#### Sample of RDS output file

## 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

    E4_EDA_Process.part2.ExtractButtonPresses(participant_list=c(1001),
                                              ziplocation="~/extdata/E4_demo_data/",
                                              rdslocation.buttonpress="~/extdata/output/presses/",
                                              summarylocation="~/extdata/output/summaries/",
                                              cutoff.ends=2,
                                              cutoff.overlap=20)

#### Console output

#### Sample of RDS output file

## 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

    E4_EDA_Process.part3.MatchPressesToEDA(participant_list=c(1001),
                                           rdslocation.buttonpress="~/extdata/output/presses/",
                                            rdslocation.MatchedEDA="~/extdata/output/matched_EDA/",
                                          rdslocation.EDA="~/extdata/output/raw_EDA/",
                                           min.before=20,min.after=20,control=T)

#### Console output

#### Sample of RDS output file

## Step 4: Put matched EDA in to bins

This is the final step where everything gets put into one file.

    E4_EDA_Process.part4.BinMatchedEDA(participant_list=c(1001),
                                        rdslocation.MatchedEDA="~/extdata/output/matched_EDA/",
                                        rdslocation.BinnedMatchedEDA="~/extdata/output/binned_matched_EDA/",
                                       min.after = 20,min.before = 20)

#### Console output

#### Sample of RDS output file

Note: The values for “MinBeforeAfter” for “before” values will be negative, to use with things like growth curve modeling. If you positive integers, just multiple this column by -1.