Stroop
In [ ]:
Copied!
"""
A fixation cross is followed by a blank screen, followed by a Stroop stimulus, followed by another
blank screen. The fixation cross is shown for 1000ms. The soa and iti durations are indicated by
the experimental design. The color of the Stroop task and its words are also indicated by the
experimental design. The correct response to a red word is f, and the correct response to a
green word is j.
"""
"""
A fixation cross is followed by a blank screen, followed by a Stroop stimulus, followed by another
blank screen. The fixation cross is shown for 1000ms. The soa and iti durations are indicated by
the experimental design. The color of the Stroop task and its words are also indicated by the
experimental design. The correct response to a red word is f, and the correct response to a
green word is j.
"""
In [ ]:
Copied!
from sweetbean import Block, Experiment
from sweetbean.stimulus import Text
from sweetbean.variable import DataVariable, FunctionVariable, TimelineVariable
from sweetbean import Block, Experiment
from sweetbean.stimulus import Text
from sweetbean.variable import DataVariable, FunctionVariable, TimelineVariable
In [ ]:
Copied!
timeline = [
{"color": "red", "word": "RED", "so_s": 200, "so_f": 1000},
{"color": "green", "word": "GREEN", "so_s": 1000, "so_f": 100},
{"color": "green", "word": "RED", "so_s": 100, "so_f": 2000},
{"color": "red", "word": "GREEN", "so_s": 1000, "so_f": 1000},
]
timeline = [
{"color": "red", "word": "RED", "so_s": 200, "so_f": 1000},
{"color": "green", "word": "GREEN", "so_s": 1000, "so_f": 100},
{"color": "green", "word": "RED", "so_s": 100, "so_f": 2000},
{"color": "red", "word": "GREEN", "so_s": 1000, "so_f": 1000},
]
EVENT SEQUENCE
In [ ]:
Copied!
color = TimelineVariable("color")
word = TimelineVariable("word")
so_s_duration = TimelineVariable("so_s")
so_f_duration = TimelineVariable("so_f")
color = TimelineVariable("color")
word = TimelineVariable("word")
so_s_duration = TimelineVariable("so_s")
so_f_duration = TimelineVariable("so_f")
In [ ]:
Copied!
def correct_key_fct(color, word):
if color.lower() == word.lower():
return "f"
return "j"
def correct_key_fct(color, word):
if color.lower() == word.lower():
return "f"
return "j"
In [ ]:
Copied!
correct_key = FunctionVariable("correct_key", correct_key_fct, [color, word])
correct_key = FunctionVariable("correct_key", correct_key_fct, [color, word])
In [ ]:
Copied!
last_correct = DataVariable("correct", 1)
last_correct = DataVariable("correct", 1)
In [ ]:
Copied!
feedback_text = FunctionVariable(
"feedback_text",
lambda lc: "Correct!" if lc else "False!",
[last_correct],
)
feedback_text = FunctionVariable(
"feedback_text",
lambda lc: "Correct!" if lc else "False!",
[last_correct],
)
In [ ]:
Copied!
fixation = Text(800, "+")
so_s = Text(so_s_duration)
stroop = Text(2000, word, color, choices=["f", "j"], correct_key=correct_key)
feedback = Text(800, feedback_text)
so_f = Text(so_f_duration)
fixation = Text(800, "+")
so_s = Text(so_s_duration)
stroop = Text(2000, word, color, choices=["f", "j"], correct_key=correct_key)
feedback = Text(800, feedback_text)
so_f = Text(so_f_duration)
BLOCK DESIGN
In [ ]:
Copied!
block = Block([fixation, so_s, stroop, feedback, so_f], timeline)
block = Block([fixation, so_s, stroop, feedback, so_f], timeline)
In [ ]:
Copied!
# Create an image of the stimuli sequence of the block
block.to_image(
"stroop.png",
data=[None, None, {"correct": True}, None, None],
zoom_factor=3,
sequence=True,
)
# Create an image of the stimuli sequence of the block
block.to_image(
"stroop.png",
data=[None, None, {"correct": True}, None, None],
zoom_factor=3,
sequence=True,
)
In [ ]:
Copied!
# Create an HTML file of the experiment
experiment = Experiment([block])
experiment.to_html("stroop.html")
# Create an HTML file of the experiment
experiment = Experiment([block])
experiment.to_html("stroop.html")