Skip to content

Commit

Permalink
refactor(papers): use sbcs.<>_two_sided() in papers
Browse files Browse the repository at this point in the history
`domijan2015.simultaneous_brightness_contrast()`
`RHS2007.sbc_small()`
`RHS2007.sbc_large()`
  • Loading branch information
JorisVincent committed Sep 16, 2023
1 parent 7318280 commit 3ee13ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 57 deletions.
52 changes: 16 additions & 36 deletions stimupy/papers/RHS2007.py
Expand Up @@ -955,23 +955,13 @@ def sbc_large(ppd=PPD, pad=True):
Vision Research, 39, 4361-4377.
"""

params = {
"ppd": ppd,
"target_size": 3.0,
"intensity_target": v2,
}

stim1 = stimupy.sbcs.basic(
visual_size=(13.0, 15.5),
intensity_background=0.0,
**params,
)
stim2 = stimupy.sbcs.basic(
visual_size=(13.0, 15.5),
intensity_background=1.0,
**params,
stim = stimupy.sbcs.basic_two_sided(
visual_size=(13.0, 31.0),
ppd=ppd,
target_size=3.0,
intensity_target=v2,
intensity_background=(0.0, 1.0),
)
stim = stack_dicts(stim1, stim2)

if pad:
stim = pad_dict_to_visual_size(stim, VISEXTENT, ppd, pad_value=v2)
Expand All @@ -980,13 +970,13 @@ def sbc_large(ppd=PPD, pad=True):
"effect_strength": 11.35,
}

params.update(
stim.update(
visual_size=np.array(stim["img"].shape) / ppd,
shape=stim["img"].shape,
intensity_range=(v1, v3),
experimental_data=experimental_data,
)
return {**stim, **params}
return stim


def sbc_small(ppd=PPD, pad=True):
Expand Down Expand Up @@ -1015,23 +1005,13 @@ def sbc_small(ppd=PPD, pad=True):
Vision Research, 39, 4361-4377.
"""

params = {
"ppd": ppd,
"target_size": 1.0,
"intensity_target": v2,
}

stim1 = stimupy.sbcs.basic(
visual_size=(13.0, 15.5),
intensity_background=0.0,
**params,
)
stim2 = stimupy.sbcs.basic(
visual_size=(13.0, 15.5),
intensity_background=1.0,
**params,
stim = stimupy.sbcs.basic_two_sided(
visual_size=(13.0, 31.0),
ppd=ppd,
target_size=1.0,
intensity_background=(0.0, 1.0),
intensity_target=v2,
)
stim = stack_dicts(stim1, stim2)

if pad:
stim = pad_dict_to_visual_size(stim, VISEXTENT, ppd, pad_value=v2)
Expand All @@ -1040,13 +1020,13 @@ def sbc_small(ppd=PPD, pad=True):
"effect_strength": 19.78,
}

params.update(
stim.update(
visual_size=np.array(stim["img"].shape) / ppd,
shape=stim["img"].shape,
intensity_range=(v1, v3),
experimental_data=experimental_data,
)
return {**stim, **params}
return stim


def todorovic_equal(ppd=PPD, pad=True):
Expand Down
29 changes: 8 additions & 21 deletions stimupy/papers/domijan2015.py
Expand Up @@ -564,30 +564,17 @@ def simultaneous_brightness_contrast(
shape, visual_size, ppd, visual_resize = resolve(
shape, visual_size, ppd, VSIZES["simultaneous_brightness_contrast"]
)
ppd = ppd[0]

params = {
"visual_size": visual_size[0],
"ppd": ppd,
"target_size": (2.1 * visual_resize, 2.1 * visual_resize),
"target_position": (3.8 * visual_resize, 3.8 * visual_resize),
}

stim1 = stimupy.sbcs.generalized(
**params,
intensity_background=v3,
stim = stimupy.sbcs.generalized_two_sided(
visual_size=visual_size,
ppd=ppd,
target_size=(2.1 * visual_resize, 2.1 * visual_resize),
target_position=(3.8 * visual_resize, 3.8 * visual_resize),
intensity_background=(v3, v1),
intensity_target=v2,
)
stim2 = stimupy.sbcs.generalized(
**params,
intensity_background=v1,
intensity_target=v2,
)

# Stacking
stim = stack_dicts(stim1, stim2)

params.update(
stim.update(
original_shape=SHAPES["simultaneous_brightness_contrast"],
original_ppd=PPD,
original_visual_size=VSIZES["simultaneous_brightness_contrast"],
Expand All @@ -596,7 +583,7 @@ def simultaneous_brightness_contrast(
visual_size=resolution.visual_size_from_shape_ppd(stim["img"].shape, ppd),
shape=stim["img"].shape,
)
return {**stim, **params}
return stim


def white(visual_size=VSIZES["white"], ppd=PPD, pad=PAD, shape=SHAPES["white"]):
Expand Down

0 comments on commit 3ee13ed

Please sign in to comment.