示例#1
0
    derived_level("right", within_trial(response_right, [color])),
])

# DEFINE RESPONSE TRANSITION FACTOR


def response_repeat(response):
    return response[0] == response[1]


def response_switch(response):
    return not response_repeat(response)


resp_transition = factor("response_transition", [
    derived_level("repeat", transition(response_repeat, [response])),
    derived_level("switch", transition(response_switch, [response]))
])

# DEFINE SEQUENCE CONSTRAINTS

k = 7
constraints = [no_more_than_k_in_a_row(k, resp_transition)]

# DEFINE EXPERIMENT

design = [color, word, congruency, resp_transition, response]
crossing = [color, word, resp_transition]
block = fully_cross_block(design, crossing, constraints)

# SOLVE
示例#2
0

def con_inc(congruency):
    return congruency[0] == "congruent" and congruency[1] == "incongruent"


def inc_con(congruency):
    return congruency[0] == "incongruent" and congruency[1] == "congruent"


def inc_inc(congruency):
    return congruency[0] == "incongruent" and congruency[1] == "incongruent"


congruency_transition = factor("congruency transition", [
    derived_level("congruent-congruent", transition(con_con, [congruency])),
    derived_level("congruent-incongruent", transition(con_inc, [congruency])),
    derived_level("incongruent-congruent", transition(inc_con, [congruency])),
    derived_level("incongruent-incongruent", transition(inc_inc,
                                                        [congruency])),
])


# DEFINE FLANKER RESPONSE FACTOR
def flanker_left(target_direction, congruency):
    return ((target_direction == "1" and congruency == "congruent")
            or (target_direction == "-1" and congruency == "incongruent"))


def flanker_right(target_direction, congruency):
    return not flanker_left(target_direction, congruency)
示例#3
0
def inc_con(congruency):
    return congruency[0] == "incongruent" and congruency[1] == "congruent"
def inc_inc(congruency):
    return congruency[0] == "incongruent" and congruency[1] == "incongruent"
def inc_ntr(congruency):
    return congruency[0] == "incongruent" and congruency[1] == "neutral"
def ntr_con(congruency):
    return congruency[0] == "neutral" and congruency[1] == "congruent"
def ntr_inc(congruency):
    return congruency[0] == "neutral" and congruency[1] == "incongruent"
def ntr_ntr(congruency):
    return congruency[0] == "neutral" and congruency[1] == "neutral"


congruency_transition = factor("congruency_transition", [
    derived_level("congruent-congruent", transition(con_con, [congruency])),
    derived_level("congruent-incongruent", transition(con_inc, [congruency])),
    derived_level("congruent-neutral", transition(con_ntr, [congruency])),
    derived_level("incongruent-congruent", transition(inc_con, [congruency])),
    derived_level("incongruent-incongruent", transition(inc_inc, [congruency])),
    derived_level("incongruent-neutral", transition(inc_ntr, [congruency])),
    derived_level("neutral-congruent", transition(ntr_con, [congruency])),
    derived_level("neutral-incongruent", transition(ntr_inc, [congruency])),
    derived_level("neutral-neutral", transition(ntr_ntr, [congruency]))
])

# DEFINE RESPONSE TRANSITION FACTOR

def response_repeat(responses):
    return responses[0] == responses[1]
示例#4
0
def color_motion_incongruent(color, motion):
    return not color_motion_congruent(color, motion)


congruency = factor("congruency", [
    derived_level("con", within_trial(color_motion_congruent,
                                      [color, motion])),
    derived_level("inc", within_trial(color_motion_incongruent,
                                      [color, motion]))
])

# Task transition
task_transition = factor("task transition", [
    derived_level("repeat",
                  transition(lambda tasks: tasks[0] == tasks[1], [task])),
    derived_level("switch",
                  transition(lambda tasks: tasks[0] != tasks[1], [task]))
])

# Response transition
response_transition = factor("response transition", [
    derived_level(
        "repeat",
        transition(lambda responses: responses[0] == responses[1],
                   [response])),
    derived_level(
        "switch",
        transition(lambda responses: responses[0] != responses[1], [response]))
])
示例#5
0
from acceptance import shuffled_design_sample

# Basic setup
color_list = ["red", "blue"]
color = factor("color", color_list)
text  = factor("text",  color_list)
mix   = factor("text",  color_list)

# Congruent factor
con_level  = derived_level("con", within_trial(op.eq, [color, text]))
inc_level  = derived_level("inc", within_trial(op.ne, [color, text]))
con_factor = factor("congruent?", [con_level, inc_level])

# Repeated color factor
repeated_color_factor = factor("repeated color?", [
    derived_level("yes", transition(lambda colors: colors[0] == colors[1], [color])),
    derived_level("no",  transition(lambda colors: colors[0] != colors[1], [color]))
])

# Repeated text factor
repeated_text_factor = factor("repeated text?", [
    derived_level("yes", transition(lambda texts: texts[0] == texts[1], [text])),
    derived_level("no",  transition(lambda texts: texts[0] != texts[1], [text]))
])


@pytest.mark.parametrize('design', shuffled_design_sample([color, text, mix], 6))
def test_correct_solution_count(design):
    crossing = [[color, mix], [text, mix]]
    constraints = []
示例#6
0
color = factor("color", ["28", "45"])
motion = factor("motion", ["up", "down"])
response = factor("response", ["👈", "👉"])


def congruent(color, motion):
    return ((color == "red") and (motion == "up")) or ((color == "blue") and
                                                       (motion == "down"))


def some_func(color0, text0, color1, text1, color2):
    return None


derived_level("con", within_trial(op.eq, [color, text]))
derived_level("con", transition(congruent, [color, motion]))
#derived_level("con", window(some_func, [[color, text], [color, text], [color]], 2, stride=2))

k = 1  #TODO this value should change to the intended value from the writing of the original code
at_most_k_in_a_row(k, conLevel)
Balance(congruentFactor)

# congruent   : 3 (red, red) (g, g) (b,b)
# incongruent : 6
#
# 2 of each congruent --> 6 congruent
# matches the 6 incongruent

# without rep should be a keyword
# balance which figures out the 2-to-1 ratio
示例#7
0
congruent = derived_level("con", within_trial(operator.eq, [color, word]))
incongruent = derived_level("inc", within_trial(operator.ne, [color, word]))

congruence = factor("congruence", [congruent, incongruent])

one_con_at_a_time = at_most_k_in_a_row(1, (congruence, congruent))


def one_diff(colors, words):
    if (colors[0] == colors[1]):
        return words[0] != words[1]
    else:
        return words[0] == words[1]


def both_diff(colors, words):
    return not one_diff(colors, words)


one = derived_level("one", transition(one_diff, [color, word]))
both = derived_level("both", transition(both_diff, [color, word]))
changed = factor("changed", [one, both])

block = fully_cross_block([color, word, congruence, changed],
                          [color, word, changed], [])

experiments = synthesize_trials_non_uniform(block, 1)

print_experiments(block, experiments)
from sweetpea.tests.test_utils import get_level_from_name

direction = factor("direction", ["up", "down"])

color_list = ["red", "blue"]
color = factor("color", color_list)
text = factor("text", color_list)

congruent_factor = factor("congruent?", [
    derived_level("con", within_trial(op.eq, [color, text])),
    derived_level("inc", within_trial(op.ne, [color, text]))
])

repeated_color_factor = factor("repeated color?", [
    derived_level("yes",
                  transition(lambda colors: colors[0] == colors[1], [color])),
    derived_level("no",
                  transition(lambda colors: colors[0] != colors[1], [color]))
])


@pytest.mark.parametrize('design',
                         [[direction, color, text, congruent_factor],
                          [congruent_factor, direction, color, text],
                          [direction, congruent_factor, color, text]])
def test_correct_solution_count_when_unconstrained(design):
    crossing = [direction, congruent_factor]
    constraints = []

    block = fully_cross_block(design, crossing, constraints)
    experiments = synthesize_trials_non_uniform(block, 500)