Skip to content

Commit

Permalink
by default, turn off smoothing in stims
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnSchmittwilken committed Jul 25, 2022
1 parent 05dec90 commit 37d47e3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 44 deletions.
32 changes: 11 additions & 21 deletions stimuli/illusions/whites.py
@@ -1,6 +1,6 @@
import numpy as np
from stimuli.components import square_wave, disc_and_rings
from stimuli.utils import degrees_to_pixels, resize_array
from stimuli.utils import degrees_to_pixels, resize_array, round_to_vals


def white(
Expand Down Expand Up @@ -95,6 +95,7 @@ def circular_white(
vdisc2=1.,
vtarget=0.5,
target_indices=(1, 3,),
ssf=1,
):
"""
Circular Whites's illusion
Expand Down Expand Up @@ -138,9 +139,12 @@ def circular_white(
vdiscs_img.append(vdisc2)
vdics_mask.append(0)

img = disc_and_rings(ppd, radii, vtarget, vdiscs_img)
mask = disc_and_rings(ppd, radii, 0, vdics_mask)
return {"img": img, "mask": mask}
img = disc_and_rings(ppd, radii, vtarget, vdiscs_img, ssf)
mask = disc_and_rings(ppd, radii, 0, vdics_mask, ssf)

cond = ((img != vtarget) & (mask != 0))
mask[cond] = 0
return {"img": img, "mask": mask.astype(int)}


def wheel_of_fortune_white(
Expand Down Expand Up @@ -275,25 +279,11 @@ def wheel_of_fortune_white(
# downsample the stimulus by local averaging along rows and columns
sampler = resize_array(np.eye(img.shape[0] // ssf), (1, ssf))
img = np.dot(sampler, np.dot(img, sampler.T)) / ssf**2

# Round values to the ones closest of given values
img = round_to_vals(img, (vpie1, vpie2, vtarget))
mask = np.dot(sampler, np.dot(mask, sampler.T)) / ssf**2
return {"img": img, "mask": mask.astype(int)}


def round_to_vals(input_arr, vals):
n_val = len(vals)
input_arr = np.repeat(np.expand_dims(input_arr, -1), n_val, axis=2)
vals_arr = np.ones(input_arr.shape) * np.array(np.expand_dims(vals, [0, 1]))

indices = np.argmin(np.abs(input_arr - vals_arr), axis=2)
out_arr = np.copy(indices).astype(float)

for i in range(n_val):
out_arr[indices == i] = vals[i]
return out_arr

cond = ((img != vtarget) & (mask != 0))
mask[cond] = 0
return {"img": img, "mask": mask.astype(int)}


def white_anderson(
Expand Down
46 changes: 23 additions & 23 deletions stimuli/papers/RHS2007.py
Expand Up @@ -3,35 +3,35 @@
from stimuli.utils import degrees_to_pixels, pad_img, pad_img_to_shape

__all__ = [
# "WE_thick",
# "WE_thin_wide",
# "WE_dual",
# "WE_anderson",
# "WE_howe",
# "WE_zigzag",
"WE_thick",
"WE_thin_wide",
"WE_dual",
"WE_anderson",
"WE_howe",
"WE_zigzag",
"WE_radial_thick_small",
"WE_radial_thick",
"WE_radial_thin_small",
"WE_circular1",
"WE_circular05",
"WE_circular025",
# "grating_induction",
# "sbc_large",
# "sbc_small",
# "todorovic_equal",
# "todorovic_in_large",
# "todorovic_in_small",
# "todorovic_out",
# "checkerboard_016",
# "checkerboard_0938",
# "checkerboard209",
# "corrugated_mondrian",
# "benary_cross",
# "todorovic_benary1_2",
# "todorovic_benary3_4",
# "todorovic_benary1_2_3_4",
# "bullseye_thin",
# "bullseye_thick",
"grating_induction",
"sbc_large",
"sbc_small",
"todorovic_equal",
"todorovic_in_large",
"todorovic_in_small",
"todorovic_out",
"checkerboard_016",
"checkerboard_0938",
"checkerboard209",
"corrugated_mondrian",
"benary_cross",
"todorovic_benary1_2",
"todorovic_benary3_4",
"todorovic_benary1_2_3_4",
"bullseye_thin",
"bullseye_thick",
]

VISEXTENT = (32.0, 32.0)
Expand Down

0 comments on commit 37d47e3

Please sign in to comment.