Skip to content

Commit

Permalink
Robinson et al (2007) stimuli generated by papers/RHS2007
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisVincent committed Jun 14, 2022
1 parent 1110ca6 commit da4f0d2
Show file tree
Hide file tree
Showing 7 changed files with 625 additions and 737 deletions.
29 changes: 0 additions & 29 deletions stimuli/illusions/bullseye.py
Expand Up @@ -73,35 +73,6 @@ def bullseye_illusion(
return {"img": img, "mask": mask}


def RHS2007_bullseye_thin():
"""
Generates Bullseye thin illusion as used in the Robinson, Hammon and de Sa 2007 paper.
"""
return bullseye_illusion(
n_rings=8,
ring_width=1,
padding=(100, 100, 100, 100),
back=1.0,
rings=9.0,
target=5.0,
)


def RHS2007_bullseye_thick():
"""
Generates Bullseye thick illusion as used in the Robinson, Hammon and de Sa 2007 paper.
"""

return bullseye_illusion(
n_rings=8,
ring_width=1,
padding=(50, 50, 50, 50),
back=1.0,
rings=9.0,
target=5.0,
)


if __name__ == "__main__":
import matplotlib.pyplot as plt

Expand Down
90 changes: 2 additions & 88 deletions stimuli/illusions/checkerboard_sbc.py
@@ -1,5 +1,5 @@
import numpy as np
from stimuli.utils import degrees_to_pixels, pad_img_to_shape, plot_stim
from stimuli.utils import degrees_to_pixels, plot_stim


def checkerboard_contrast(
Expand Down Expand Up @@ -73,93 +73,7 @@ def checkerboard_contrast(
return {"img": img, "mask": mask}


def RHS2007_Checkerboard016():
"""
Generates checkerboard 0.16 illusion as used in Robinson, Hammon and de Sa 2007 paper.
"""
total_height, total_width, ppd = (32,) * 3
height_checks, width_checks = 40, 102
check_height = 32 / 102
board_shape = (height_checks, width_checks)

check1, check2, target = 1, 0, 0.5
target_height = height_checks // 2
stim = checkerboard_contrast(
ppd=ppd,
board_shape=board_shape,
check_size=check_height,
targets_coords=((target_height, 16), (target_height, 85)),
extend_targets=False,
check1=check1,
check2=check2,
target=target,
)

img = pad_img_to_shape(stim["img"], (1024, 1024), val=target)
mask = pad_img_to_shape(stim["mask"], (1024, 1024), val=0)

return {"img": img, "mask": mask}


def RHS2007_Checkerboard0938():
"""
Generates checkerboard 0.94 illusion as used in Robinson, Hammon and de Sa 2007 paper.
"""
total_height, total_width, ppd = (32,) * 3
height_checks, width_checks = 7, 25
check_height = 0.938
board_shape = (height_checks, width_checks)

check1, check2, target = 0, 1, 0.5
target_height = height_checks // 2
stim = checkerboard_contrast(
ppd=ppd,
board_shape=board_shape,
check_size=check_height,
targets_coords=((target_height, 6), (target_height, 17)),
extend_targets=False,
check1=check1,
check2=check2,
target=target,
)
img = pad_img_to_shape(stim["img"], (1024, 1024), val=target)
mask = pad_img_to_shape(stim["mask"], (1024, 1024), val=0)

return {"img": img, "mask": mask}


def RHS2007_Checkerboard209():
"""
Generates checkerboard 2.1 illusion as used in Robinson, Hammon and de Sa 2007 paper.
"""
total_height, total_width, ppd = (32,) * 3
height_checks, width_checks = 3, 10
check_height = 2.09
board_shape = (height_checks, width_checks)

check1, check2, target = 0, 1, 0.5
target_height = height_checks // 2
stim = checkerboard_contrast(
ppd=ppd,
board_shape=board_shape,
check_size=check_height,
targets_coords=((target_height, 2), (target_height, 7)),
extend_targets=False,
check1=check1,
check2=check2,
target=target,
)
img = pad_img_to_shape(stim["img"], (1024, 1024), val=target)
mask = pad_img_to_shape(stim["mask"], (1024, 1024), val=0)

return {"img": img, "mask": mask}


if __name__ == "__main__":
img1 = RHS2007_Checkerboard016()
img2 = RHS2007_Checkerboard0938()
img3 = RHS2007_Checkerboard209()

stim = checkerboard_contrast()
plt.figure()

plot_stim(stim, mask=True)
25 changes: 0 additions & 25 deletions stimuli/illusions/grating_induction.py
Expand Up @@ -78,31 +78,6 @@ def grating_illusion(
return {"img": img, "mask": mask}


def RHS2007_grating_induction():
total_height, total_width, ppd = (32.0,) * 3
n_cycles = 4.0
height, width = 12.0, 16.0
frequency = n_cycles / width
padding_horizontal = (total_width - width) / 2
padding_vertical = (total_height - height) / 2
padding = (
padding_vertical,
padding_vertical,
padding_horizontal,
padding_horizontal,
)
stim = grating_illusion(
shape=(height, width),
ppd=ppd,
frequency=frequency,
target_height=1,
blur=10,
start="high",
padding=padding,
)
return stim


if __name__ == "__main__":
import matplotlib.pyplot as plt

Expand Down
66 changes: 0 additions & 66 deletions stimuli/illusions/sbc.py
Expand Up @@ -60,72 +60,6 @@ def simultaneous_brightness_contrast(
return {"img": img, "mask": mask}


def RHS2007_sbc_large():
total_height, total_width, ppd = (32,) * 3
height, width = 12, 15
target_height, target_width = 3, 3

inner_padding_vertical, inner_padding_horizontal = (
height - target_height
) / 2, (width - target_width) / 2
inner_padding = (
inner_padding_vertical,
inner_padding_vertical,
inner_padding_horizontal,
inner_padding_horizontal,
)

padding_vertical, padding_horizontal = (total_height - height) / 2, (
total_width - 2 * width
) / 2
padding = (
padding_vertical,
padding_vertical,
padding_horizontal,
padding_horizontal,
)

return simultaneous_brightness_contrast(
target_shape=(target_height, target_width),
ppd=ppd,
inner_padding=inner_padding,
padding=padding,
)


def RHS2007_sbc_small():
total_height, total_width, ppd = (32,) * 3
height, width = 12, 15
target_height, target_width = 1, 1

inner_padding_vertical, inner_padding_horizontal = (
height - target_height
) / 2, (width - target_width) / 2
inner_padding = (
inner_padding_vertical,
inner_padding_vertical,
inner_padding_horizontal,
inner_padding_horizontal,
)

padding_vertical, padding_horizontal = (total_height - height) / 2, (
total_width - 2 * width
) / 2
padding = (
padding_vertical,
padding_vertical,
padding_horizontal,
padding_horizontal,
)

return simultaneous_brightness_contrast(
target_shape=(target_height, target_width),
ppd=ppd,
inner_padding=inner_padding,
padding=padding,
)


if __name__ == "__main__":
import matplotlib.pyplot as plt

Expand Down

0 comments on commit da4f0d2

Please sign in to comment.