Note: The code provided was strictly created for this study. The authors are not coding experts and we understand a lot of what is writted could easily be shortened for
efficiency. Regardless, the code has been provided for transparency. If the code in this study is used for your research, please cite this paper



Preprocessing ERP Data:
To use the following code, you need to have downloaded the BIDS dataset (https://doi.org/10.5061/dryad.6wwpzgmx4), MATLAB and the EEGLAB plugin.

The "preprocdat" files are the preprocessing scripts to create epochs for each of the derivatives (grand average, cloze probability, linguistic division, order and time).
This code was adjusted after data analysis to suit the BIDS format because data was reorganized into BIDS format after data analysis. Preprocessing files were tested to 
assure that they worked, however, again, the code was not initially written for this format. Chanlocs (channel locations) was provided for the preprocessing files. 

To use the preprocessing code, one needs to convert the raw bdf files into .mat files using the provided "bdf2mat" code. This can be done via EEGMaster. Additionally, 
all preprocessing can be done via EEGMaster. EEGMaster needs to be adjusted to your computer. Paths for the BIDS folder need to be adjusted. Additionally, EEGmaster is 
where you select the folder from which you are processing data from (datadir=uigetdir). Select the entirety of the BIDS folder if you would like the subsequent code to
work. If you would like to walk through each individual derivative code, just make sure to specify the datadir folder. Preprocessing files will tell you if the file has 
not been converted into .mat. It will also tell you if preprocessing was already done for that particular derivative.

Preprocessing files filters the data before channel rejection. It then shifts the trigger timing to the onset of the final word in the sentence (the target word that is 
either congruent or incongruent with the prior context. To epoch the data, the stimuli is first grouped into corresponding conditions (incongruent and congruent) and then 
derivative groups if applicable (linguistic divsion 1 vs 2 per condition). Epochs per group are made. Baseline and threshold rejection is applied to the Epoch groups 
before saving the the sub-## folder. The ERP file is saved along with t (time) and fs (sample frequency). Any other variable of interest can be added to the saved file.



Running the N400 Task:
To use the following code, you need to have downloaded Presentation (Neurobehavioral Systems) and the stimulus set (https://doi.org/10.5061/dryad.9ghx3ffkg) or the dataset 
that includes the stimulus set (https://doi.org/10.5061/dryad.6wwpzgmx4).

Provided are the SCE (scenario) and EXP (experiment) files. The EXP file is for general experiment settings (display, audio, response buttons etc) while the SCE file 
contains the code for the actual experiment. You will need to change file locations in the EXP file (stimuli and scenario locations) for the SCE file to work. Additionally, 
you will need to change the output computer (whatever computer is running the EEG experiment) so that port codes can be sent to mark the EEG data, and likely the display, 
audio, and response outputs. Response output is currently set to a L/R arrow key and space bar press on a standard keyboard.

Although the participants were presented all stimuli in the stimulus set, the stimuli included in the scenario file do not include the 20 removed stimuli. Eventhough the 
authors do not reccomend the use of these stimuli, researchers can add them back at their own discretion. 