## Instructions for Use ##
This component contains the data and analysis scripts for Experiment 3 reported in our Journal of Neurophysiology paper.
**Exp3_SubjectExclusionLog** is a record of which subjects were excluded from our final sample (and were therefore replaced).
**SpatialWM_ChangeDetect.m** is the script used to run the experiment (this script requires PsychToolbox; see http://psychtoolbox.org/; Brainard, 1997; Pelli, 1997).
**AnalysisScripts** – this folder contains all analysis scripts needed to reproduce the analyses in the paper.
**Data** – this folder contains the behavior data files. This folder is also the destination for all files generated by the analysis scripts.
**EEG** – this folder contains the segmented EEG data.
You can find more detailed descriptions of the contents of each of these folders in the sections below.
You should download these three folders and save them in the same place. All scripts in the ‘AnalysisScripts’ folder will run from within that folder as long as it is saved in the same folder as the ‘Data’ and ‘EEG’ folders.
## 'AnalysisScripts' folder ##
This folder contains the analysis and plotting scripts used for our paper. Here is a brief description of what each script does:
**changeDetectAcc:** Creates a summary file of change detection accuracy across subjects.
**SpatialEM:** Runs the spatial encoding model on alpha-band (8-12 Hz) activity.
**SpatiaEM_AllFs:** Runs the spatial encoding model on 1-Hz frequency bands from 4-29 Hz.
**SpatialEM_HighFs:** Run the spatial encoding model on 1-Hz frequency bands from 30-50 Hz.
**SpatialEM..._Permute:** SpatialEM scripts ending in ‘Permute’ runs the relevant spatial encoding model routine 1000 times, each time with the location bin labels permuted within each analysis block. The output of these scripts is the basis for the permutation tests we report in the paper.
**calculateSlopes_...** Calculate CTF slope metric for the both the unpermuted (output of the SpatialEM…) and permuted (output of SpatialEM_...Permute) data.
**PermTest_...** Use the output of the calculateSlopes scripts to run the permutation test using the CTF slope metric.
**plotTFs:** plot the time-resolved CTF reconstructed from total alpha power. Used output of SpatialEM and PermTest_Alpha.
**plotTimexFreq:** plot the results of the time x frequency search (see Fig 2 in the paper). Uses output of permTest_AllFs and permTest_HighFreqs.
**eegfilt:** EEGLAB’s filtering function (http://sccn.ucsd.edu/eeglab/; Delorme & Makeig, 2004).
## 'Data' folder ##
This folder contains the behavior data for each subject. The file for each subject includes the following variables:
**beh.trial.pos:** the exact angular location of the sample stimulus (0-359 degrees) for each trial. 0 degrees is 3 O’Clock.
**beh.trial.posBin:** the location bin the stimulus was drawn from for each trial. Each bin spanned 45 degrees. Bins were centered at 0 degrees, 45 degrees, 90 degrees, etc.
**beh.trial.acc:** change detection accuracy (1 is correct, 0 is incorrect).
For the subjects that were included in the final sample, the filenames end in “_ChangeDetect_Behavior.mat”
For the subject that were excluded from the final sample, the filenames end in “_Behavior_REJECT.mat”
### Update (6.8.2018) ####
On June 8, 2018 I posted new behavior files with the suffix "Fixed" (i.e., ChangeDetect_Behavior_Fixed.mat). These files correct the following issues:
1. In the original files there were some errors in `beh.trial.pos` variable in the "ChangeDetect_Behavior.mat". Note that this variable was not used in the analyses reported in the paper.
2. I mistakenly reported above that the stimulus position began at 3 O'Clock and go clockwise (as they do in Exp 1 and Exp 2). This is incorrect. For this experiment, the stimulus positions start at 6 O'Clock and go counterclockwise (see updated info below about the variables).
3. Subject 9 had one too many trials in the behavior file (because did not record EEG for the 1st trial by mistake). Thus we had 960 trials in the behavior file and 959 trials in the EEG file. This meant that the position bin index in the behavior was misaligned with the EEG data (so the position labels were random with respect to the EEG data). Oops! We have corrected this error in the new fixed behavior files.
Finally, I have also included some additional variables in these new files that were requested by a colleague (which trials where change trials and the location of the probe stimulus).
The variables in the new files are:
**beh.trial.sampArc:** the exact angular location of the sample stimulus (0-359 degrees) for each trial. 0 degrees is 6 O'Clock, and values go counterclockwise (e.g. 90 degrees = 3 O'Clock).
**beh.trial.testArc:** the exact angular location of the probe stimulus (0-359 degrees) for each trial. Again, 0 degrees is 6 O'Clock and values go counterclockwise.
**beh.trial.angDiff:** the angular difference between the probe stimulus and the sample stimulus. Positive values indicate the probe was counterclockwise relative to the sample. e.g., sampArc = 36, testArc = 56 --> angDiff = +20.
**beh.trial.posBin:** the location bin the sample stimulus was drawn from for each trials. Each bin spanned 45 degrees. Bin 1 centered at 0 degrees (6 O'Clock), Bin 2 centered at 45 degrees, Bin 3 centered at 90 degrees (i.e., 3 O'Clock).
**beh.change:** whether or not the trials was a change or no-change trials (1 = change, 0 = no-change).
**beh.acc:** change detection accuracy (1 is correct, 0 is incorrect).
## 'EEG' folder ##
This folder contains the EEG data for each subject. The file for each subject includes the following variables:
**eeg.data:** a Trials x Electrodes x Samples matrix of segmented EEG data.
**eeg.chanLabels:** the names of the electrodes recorded from.
**eeg.arf.artIndCleaned:** index of trials with artifacts (1 = artifact, 0 = clean trial).
**eeg.preTime:** the start of the segment in milliseconds relative to onset of the sample stimulus.
**eeg.postTime:** the end of the segment in milliseconds relative to onset of the sample stimulus.
**eeg.sampRate:** sampling rate in Hz.
A brief note on our artifact rejection procedures…
In these experiments, participants were replaced if more than 25% of trials were lost due to recording or ocular artifacts, and/or if the participant did not complete all trials during the session.
Our artifact rejection procedure involved two steps:
**Step 1:** We applied an automated artifact detection algorithm.
**Step 2:** We manually inspected the data to ensure that automatic routine was catching artifacts and was not throwing away clean trials. Usually, we inspect all trials and correct any errors the automatic routine made. However, for some subjects with a lot of artifacts, we did not inspect all trials because it was clear early on that the automated routine correctly identified a lot of artifacts. These subjects are marked as “not fully hand cleaned” in the subject exclusion log files.