The Stroop test is a well-known psychology task used to study how the brain processes conflicting information. In the classic version of the task, participants are asked to name the ink color of a word rather than read the word itself. This becomes difficult when the word meaning and the ink color do not match. This conflict is called the Stroop effect.
​
The emotional Stroop test is a variation of the original task that uses emotionally charged words instead of neutral ones.
​
Using the chi-square test for independence I tested whether there is a relationship (that was statistically significant) between the number of congruent question and incongruent questions correct and the average time taken per question. The data was based on a study I conducted, where I created a game that was sent out to students, mentors, and teaching assistants within the program.

Introduction

The Stroop Test is a neuropsychological test that is used for both experimental and clinical purposes. Psychologists use it to study attention control, inhibition, executive functioning and reading speed. The Stroop test (or Stroop Color and Word Test) is a classic psychology assessment that measures cognitive flexibility, processing speed, and executive function. It demonstrates your brain’s struggle to handle conflicting information, a phenomenon known as the Stroop effect. This test has two cases: 1) the Congruent case is where the word is written as the same color in which the word is displayed in. For example, the word displayed is blue and it is written in the same color blue. 2) The Incongruent case here the word written is a color but the the color the word is displayed in is different. In this case an example can be that the word written is blue but it is written in different color, so the person has to read the color of the word not the word itself which creates conflicting information.
The Stroop test was discovered in the 1930s by John Ridley Stroop while he was studying how interference affects reaction time. He published the task in 1935, and it became one of the most famous tests in psychology for studying cognitive interference.
I completed this project in three main stages:
◼
  • In the first phase, I designed and built the Stroop tests in Wolfram Language. I created one normal Stroop test and one emotional Stroop test so I could compare how neutral words and emotional words affect participant performance. During this stage, I focused on making the tests interactive, recording the correct responses, and making sure the data could be collected properly for later analysis. This part gave the project its foundation and made the experiment work properly.
  • ◼
  • In the second phase, I collected participant data by having people complete both versions of the test. While they responded, I recorded important information such as accuracy, reaction time, congruent and incongruent responses, and overall performance. This step gave me the raw results that I later used to compare patterns between the two Stroop tests. I also wanted to collect enough data from different sessions so the graphs would show real patterns. The data collection phase helped me see how participants reacted differently depending on the type of words they were shown.
  • ◼
  • In the third phase, I analyzed the data using graphs to compare the results from the normal Stroop test and the emotional Stroop test. I looked at accuracy across sessions, average response time across sessions, and the distribution of correct congruent and incongruent responses. This allowed me to identify patterns, such as which test produced higher accuracy, slower responses, or more interference. The graphs made it easier to understand the relationship between word type and performance.
  • In this project, I created both a normal Stroop test and an emotional Stroop test in Wolfram Language, collected participant data, and compared the results using graphs. This allowed me to study how emotion affects attention, reaction time, and accuracy in a simple but meaningful experiment.

    Stroop Test (Color and Word Test)

    The Color and Word Test version of the Stroop test was the first version I made. In this test, participants were shown words in different colors and had to name the color of the word instead of reading it. The words were neutral, so this version gave me a baseline before I moved on to the emotional Stroop test. In this section, I made an interactive Stroop test in the Wolfram Language. It displays words in different colors and asks the participant to click the button that matches the color of the word, not the word itself. It tracks the trial type, score, errors, reaction time, average time, accuracy, and correct congruent and incongruent responses. It also includes Start, Reset, and Submit buttons so the test can begin, be restarted, and the final data can be saved to a databin. Overall, this creates a full Stroop test that records performance and reaction speed.
    These variables hold a list of text names for the colors and visual colors what would be displayed on the screen:
    colorWords={"RED","GREEN","BLUE","ORANGE","YELLOW","PINK","BROWN","GRAY"};​​colors={Red,Orange,Yellow,Green,Blue,Pink,Brown,Gray};
    Here I build an association by pairing each item in words with its correct corresponding color:
    colorMap=AssociationThread[colorWords->colors];
    This whole code builds an interactive Stroop test in Wolfram Language that displays words in color, records the user’s responses and reaction times, updates live performance stats, and saves the final results to a databin.
    I defined these variables each with a default value and used it in my Dynamic Module where these variables were localized and are updated continuously. In the variable trialType, I stored data about whether each trial was congruent or incongruent. The variables correctColor, wrongColor, chosenColor, and outputColor store the values for the correct, wrong, output color and chosen color of what the player put. I set the default color as Light Gray for all. The score and errors variables store the changing values of the score and errors between each trial and the final result. trialCount keeps track of what trial we are in with the max trial value in each session is 20. answeredTrials keeps track of how many trials the player answered. startTime shows the time, and reactionTime records the time taken for each trial. Total time taken is the time taken to do 1 session, which includes 20 total trials. The congruentCorrect and IncongruentCorrect records the congruent and incongruent responses that they got correct and updates at each trial in a session.
    This code sets the default values into the variable and initializes the Stroop Test:
    trialType="";​​word="READY";​​correctColor=LightGray;​​wrongColor=LightGray;​​outputColor=LightGray;​​score=0;​​errors=0;​​chosenColor=LightGray;​​trialCount=0;​​maxTrials=20;​​gameOver=False;​​startTime=0;​​reactionTime=0;​​totalTime=0;​​answeredTrials=0;​​congruentCorrect=0;​​incongruentCorrect=0;​​submitted=False;
    The Databin connected the program to a specific online databin, which I used to store the experimental results collected during the Stroop test:
    In[]:=
    bin=Databin["1FxWTtTv3"];
    In this piece of code I have used the function Panel that helps me display the instructions of the game at the start. These instruction helps the player understand how to take the test and what button to use where and what each of them do.
    Style sets the Instructions text as Bold and size as 14 with the Background as LightYellow and column stacks the text vertically:
    Panel[​​Column[{​​Style["Instructions",Bold,14],​​"This is a Stroop test. Click the button that matches the COLOR of the word, not the word itself.",​​"Start: Begins the test.",​​"Reset: Clears everything and starts over.",​​"Color buttons: Choose the color in which the word is displayed.",​​"Submit: Saves the final data after all the trials are completed."}],​​Background->LightYellow​​]
    Out[]=
    Instructions
    This is a Stroop test. Click the button that matches the COLOR of the word, not the word itself.
    Start: Begins the test.
    Reset: Clears everything and starts over.
    Color buttons: Choose the color in which the word is displayed.
    Submit: Saves the final data after all the trials are completed.
    This line of code updates the results based on how the player did. It takes into considerations elements like errors they made, how many congruent and incongruent they got correct, average time with the final accuracy, all resulting in the final score they got.
    I used it to check whether the game had ended, and if it had, a summary of the participant’s performance was shown:
    If[gameOver,​​Column[{Row[{"Final Score:",score}],​​Row[{"Final Errors:",errors}],​​Row[{"Final Trials:",answeredTrials}],​​Row[{"Final Congruent Correct:",congruentCorrect}],​​Row[{"Final Incongruent Correct:",incongruentCorrect}],​​Row[{"Final Average Time:",If[answeredTrials>0,NumberForm[totalTime/answeredTrials,{4,2}],0],"s"}],​​Row[{"Final Accuracy:",If[answeredTrials>0,NumberForm[100score/answeredTrials,{4,1}],​​0​​],"%"}]​​}],​​""​​];
    This piece of code is for the submit button in the game. After players have finished the game and the button is pressed, the results and data of the test (like score, error, answeredTrials, accuracy, totalTime, congruentCorrrect, incongruentCorrect) gets stored and added as an entry into the data bin so the data can be collected and analyzed later on for a particular population.
    After the the submit button is pressed by the player and the data is stored in the data bin it shows a confirmation message in the form of a pop up at the end so the player gets to know that there response was successfully submitted.
    The Submit button saves the final test data to the databin only after all trials are finished, then marks it as submitted and displays a confirmation message:
    If[answeredTrials==maxTrials,DatabinAdd[bin,<|"Score"->score,"Errors"->errors,"AnsweredTrials"->answeredTrials,"Accuracy"->100.0score/answeredTrials,"AverageTime"->totalTime/answeredTrials,"TotalTime"->totalTime,"CongruentCorrect"->congruentCorrect,"IncongruentCorrect"->incongruentCorrect,"GameOver"->gameOver|>];​​submitted=True;​​CreateDialog​​[Column[{"Successfully submitted!",DefaultButton[]}]]];
    Here is the code for the part when the player presses the submit button. After the data is stored in the data bin already, it then removes the start button and keeps only the reset button so that the player can restart the test and take it again.
    This code shows the Start button until submission and, when pressed, begins the first trial by choosing the word, trial type, display color, and start time:
    If[submitted,Nothing,​​Button["Start",If[word==="READY"&&!gameOver,trialType=RandomChoice[{0.2,0.8}->{"Congruent","Incongruent"}];​​word=RandomChoice[colorWords];​​correctColor=colorMap[word];​​wrongColor=RandomChoice[DeleteCases[colors,correctColor]];​​outputColor=If[trialType==="Congruent",correctColor,wrongColor];​​trialCount=1;​​startTime=AbsoluteTime[];]]​​];
    This row creates a Red color-response button that records the reaction time, checks if the answer is correct, updates the score or errors, and then either starts the next trial or ends the test:
    If[!gameOver&&startTime=!=0,chosenColor=Red;reactionTime=AbsoluteTime[]-startTime;totalTime+=reactionTime;answeredTrials++;​​​​If[chosenColor===outputColor,score++;​​If[trialType==="Congruent",congruentCorrect++,incongruentCorrect++],​​errors++];​​If[answeredTrials<maxTrials,trialType=RandomChoice[{0.2,0.8}->{"Congruent","Incongruent"}];word=RandomChoice[colorWords];correctColor=colorMap[word];wrongColor=RandomChoice[DeleteCases[colors,correctColor]];outputColor=If[trialType==="Congruent",correctColor,wrongColor];​​startTime=AbsoluteTime[],gameOver=True;word="DONE";outputColor=LightGray];]
    The remaining color buttons follow the same logic as the Red button, with the only difference being the specific response color that is recorded when the participant clicks each one:

    Working code (Complete):

    The code was divided into smaller parts above so each section could be explained more clearly, and the complete DynamicModule was included again at the end in one cell so the full program can be run from there.
    This code creates an interactive Stroop test that displayed colored words, records responses and reaction times, and saves the final results:
    In[]:=
    DynamicModule[
    ]
    Out[]=
    READY
    Instructions
    This is a Stroop test. Click the button that matches the COLOR of the word, not the word itself.
    Start: Begins the test.
    Reset: Clears everything and starts over.
    Color buttons: Choose the color in which the word is displayed.
    Submit: Saves the final data after all the trials are completed.
    Score: 0
    Errors: 0
    Trial:0/20
    Last Time:0s
    Current Time:0s
    Average Time:0s
    Accuracy:0%
    Congruent Correct:0
    Incongruent Correct:0
    Trial Type:
    Submit
    Start
    Reset
    Red
    Orange
    Yellow
    Green
    Blue
    Pink
    Brown
    Gray

    Data Collection

    The data collection let me record participant responses from both the color and word test version of the Stroop test and the emotional Stroop test. During this stage, participants identified the color of each word instead of reading the word itself. As they responded, I collected information such as accuracy, reaction time, congruent and incongruent correct responses, and total performance for each session. I then organized the data so I could use it for graph analysis. Collecting the data carefully made it possible to compare the two tests and see how emotional words may have affected attention and reaction time.
    Dataset[bin] displays the databin contents in a structured table so you can view each saved Stroop-test session as a row of results:

    Data Analysis

    The data analysis is the third phase of my project, where I analyzed the data I collected from participants’ responses in the Stroop test. I created three graphs for both types of Stroop tests, the normal and the emotional, and compared the results across these graphs.
    Graphs:
    ◼
  • Accuracy Across Sessions: This is a bar chart where I plotted accuracy (in percentage) across sessions. A session refers to the total number of trials completed by a participant, which is 20 trials per person.
  • ◼
  • Average Response Time Across Sessions: This graph is a line plot that displays the average response time for each participant in a session. It represents how long, on average, a person took to respond during each session.
  • ◼
  • Distribution of Correct Congruent and Incongruent Responses (grouped by performance class): This graph is important because it provides a deeper analysis of participant performance. It compares the number of correct responses by separating them into congruent and incongruent trials. Each bar represents the total correct responses in one session for a participant, further divided into correct congruent and correct incongruent responses.
  • The code creates graphs to show accuracy, average response time, and congruent versus incongruent performance across sessions in the word and color Stroop test. It stores the results in lists and then uses bar charts and plots to compare how participants performed over time.
    This obtains data from the data bin:
    This line extracts the accuracy values from data and stores them in accuracyData for later graphing or analysis:
    Here, I manually extracted the list of Accuracy values from the dataset and stored it directly in the variable accuracyData. I did this because assigning the variable straight from the Lookup function, I was not able to get the correct graph as Wolfram was not interpreting the data correctly:
    This code makes a bar chart of accuracy across sessions, where each bar displays one session’s accuracy percentage, and the label at the bottom explains that the x-axis represents each session:
    This line extracts the Average time values from data and stores them in averageTimeData for later graphing or analysis:
    Here, I manually extracted the list of AverageTime values from the dataset and stored it directly in the variable averageTimeData. I did this because assigning the variable straight from the Lookup function, I was not able to get the correct graph as Wolfram was not interpreting the data correctly:
    This code makes a red line plot of the average response time across sessions, with each point showing one session’s average time:
    This line extracts the Congruent Correct and Incongruent Correct values from data and stores them in congruentData, incongruentData for later graphing or analysis:
    In this piece of code I paired the congruent and incongruent data and formatted it for graphing:
    This code groups the correct congruent and incongruent results by performance level and then draws a stacked bar chart to compare how many of each type appeared in each group:

    Emotional Stroop Test

    The emotional Stroop test is the second version of the Stroop test that I created. In this test, participants were shown both neutral and emotionally charged words in different colors and had to identify the color of the word rather than read the word itself. This version was designed to measure how emotional content affects attention, reaction time, and accuracy. By comparing it with the normal Stroop test, I was able to see whether emotional words caused more interference during the task.
    This code creates an emotional Stroop test in Wolfram Language using emotionally charged and neutral words shown in different colors. It records score, errors, reaction time, accuracy, and congruent or incongruent responses, then saves the final results to a databin for later analysis.
    Coding-wise, the emotional Stroop test uses the same code structure as the previous Stroop test, with only the words and the Databin name being changed:

    Data Collection (Emotional Stroop Test)

    The data analysis for the emotional Stroop test follows the same method as the normal Stroop test. However, since the data collected is different, the graphs and results also change accordingly. This section focuses on analyzing the participants’ responses, accuracy, and reaction times in the emotional Stroop test and comparing the patterns shown in the graphs.

    Chi - Square Test of Independence

    The chi-square test checks whether the observed counts in my contingency table are different enough from the expected counts to suggest the variables are not independent.
    Displays the data in bin2 as a structured dataset, and stores the data from bin2 as a dataset in data4:
    Converts the dataset into plain data and saves it in data2:
    This creates a dataset-style contingency table that organizes congruent and incongruent correct counts by category, with row totals and overall column totals included:
    The contingency table was found manually, adding up the number of observed values in each time class.
    This function calculates the chi-square statistic by comparing the observed counts in each category with what the expected counts would be if congruent and incongruent results were independent:
    This code runs the chi-square test on the table you give it and returns the test statistic used to check whether the two variables are independent:

    Result (Chi-square test)

    The chi-square test compared the observed counts with the expected counts under the assumption of independence. The degrees of freedom for this test are (r-1)(c-1). Since r=6 and c=2, the degrees of freedom are 5. For an alpha level of 0.05 and 5 degrees of freedom, the critical value is 11.07. Since the test statistic was 4.33283, which is below the critical value of 11.07 at the 0.05 significance level, the result was not statistically significant, suggesting that congruent and incongruent correct responses did not vary enough across the time categories to show a strong relationship.

    Data Analysis (Emotional Stroop Test)

    Similar to the word and color Stroop test, diagrams were produced in order to do a comparison of the two forms of the Stroop test and the results obtained from each.
    This obtains data from the data bin:
    This line extracts the accuracy values from data2 and stores them in accuracyData2 for later graphing or analysis:
    The data was then analyzed and represented through graphs to show accuracy across sessions and compare participant performance:
    This line extracts the average Time values from data2 and stores them in averageTimeData for later graphing or analysis:
    This code calculates the average response time for each session and plots it as a red list graph with the session number on the x-axis and the average time on the y-axis:
    This line extracts the Congruent Correct and Incongruent Correct values from data2 and stores them in congruentData2 and incongruentData2 for later graphing or analysis:
    In this piece of code I paired the congruent and incongruent data and formatted it for graphing:
    This code groups the correct congruent and incongruent responses, totals for each performance class, and displays the results in a stacked bar chart:

    Graph Comparison

    I compared the results from the normal Stroop test and the emotional Stroop test.
    ​
    In the first graph, which displayed accuracy across sessions, the emotional Stroop test generally had higher and more consistent accuracy, with most sessions staying close to 100 percent. The normal Stroop test also had strong accuracy in several sessions, but it showed a little more variation and some lower points, which suggests that the different colored words in the normal Stroop test caused more interference. This means participants were usually more accurate when the words had emotional meaning than when the words were neutral in the normal Stroop test.
    ​
    In the second graph, which displayed average response time across sessions, the emotional Stroop test stayed more steady, while the normal Stroop test showed more variation. This indicates that participants were able to respond more consistently in the emotional test, but the neutral incongruent words sometimes slowed them down. As they had to process the color and the word at the same time, the brain would naturally read the word first and then identify what color the word was written in.
    ​
    In the third graph, which compares congruent and incongruent correct responses, incongruent responses were higher overall in both tests, but the normal Stroop test showed a stronger difference between the two. This suggests that normal content made it harder for participants to focus on the ink color and respond without being distracted by the meaning of the word.
    ​
    Overall, the comparison showed that the emotional Stroop test and the normal Stroop test affected performance differently, with the emotional test showing slightly stronger consistency and the normal test showing more interference.

    Limitations

    One limitation of this project is that the data came from a limited number of sessions, which may have affected the strength of the result. Another limitation is that reaction times were grouped into categories, which can simplify the data but also remove some detail. In addition, differences in participant focus, timing, or testing conditions may have influenced the results.

    Conclusion

    Overall, this project showed that the normal Stroop test and the emotional Stroop test affected participant performance in different ways. The graphs suggested that the emotional Stroop test had slightly stronger and more consistent accuracy, while the normal Stroop test showed more variation and interference in some sessions. The comparison of response times and congruent versus incongruent responses also showed that word meaning and color information can influence how quickly and accurately participants respond. This project demonstrated that emotional content can affect attention and cognitive control, and it helped show how the Stroop effect works in a real experiment.

    Future Directions

    I would expand this project by collecting more data and testing more participants to make the results more reliable. I would also explore and research on how trial history affects reaction time and performance consistency, since previous trials may influence how participants respond on later trials. In addition, I would compare results across a larger number of sessions to see whether accuracy and reaction time change over time. This would help me better understand the patterns in the Stroop task and improve the strength of my conclusions.

    Acknowledgment

    I would like to thank my mentor, Carolyn Applebaum, for her support, guidance, and help throughout this project. I also want to thank Stephen Wolfram and the directors Megan, Rory, Cyrus, and Eryn for providing the opportunity and resources that made this project possible. I am especially grateful to all the teaching assistants, especially Gloria, Aanya, and Kaavya and my advocate Peter Barendse for his support during the initial stages, as well as to everyone who took part in my test and helped me collect data and responses.

    References

    1) American Psychological Association. “The Stroop effect’s long (and colorful) influence.”
    https://www.apa.org/research-practice/conduct-research/stroop-effect
    2) JMP Statistical Discovery. “Chi-square test of independence.”
    https://www.jmp.com/en/statistics-knowledge-portal/linear-models/chi-square-test/chi-square-test-of-independence
    3) PubMed Central. “The Emotional Stroop Task: Assessing Cognitive Performance under Exposure to Emotional Content.”
    https://pmc.ncbi.nlm.nih.gov/articles/PMC4993290/
    4) Wolfram Research. “Dynamic Interactivity Language.”
    https://reference.wolfram.com/language/guide/DynamicInteractivityLanguage.html
    5) Wolfram Research. “Creating and Organizing Interfaces.”
    https://reference.wolfram.com/language/workflowguide/CreatingAndOrganizingInterfaces.html
    6) Wikipedia. “Stroop effect.”
    https://en.wikipedia.org/wiki/Stroop_effect

    CITE THIS NOTEBOOK

    Investigating cognitive interference using a Wolfram language Stroop test​
    by Vedika Gautam​
    Wolfram Community, STAFF PICKS, July 9, 2026
    https://community.wolfram.com/groups/-/m/t/3754216