Skip to content

Commit

Permalink
fixed bug in grating_grating that rectangle and gratings could have d…
Browse files Browse the repository at this point in the history
…ifferent shapes + made masks ints
  • Loading branch information
LynnSchmittwilken committed Dec 7, 2022
1 parent dd6d526 commit 93c6b92
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions stimuli/illusions/grating.py
Expand Up @@ -93,7 +93,7 @@ def square_wave(

# Update and return stimulus
stim["bars_mask"] = stim["mask"]
stim["mask"] = targets_mask
stim["mask"] = targets_mask.astype(int)

return stim

Expand Down Expand Up @@ -174,7 +174,7 @@ def grating_uniform(
)
stim["mask"] = pad_to_visual_size(
img=stim["mask"], visual_size=image_size, ppd=ppd, pad_value=0
)
).astype(int)

# Repack
stim.update(
Expand Down Expand Up @@ -218,18 +218,20 @@ def grating_grating(

# Superimpose
small_grating_mask = rectangle(
rectangle_size=small_grating["visual_size"],
rectangle_size=np.array(small_grating["shape"]) / ppd,
ppd=ppd,
visual_size=large_grating["visual_size"],
visual_size=np.array(large_grating["shape"]) / ppd,
intensity_background=0,
intensity_rectangle=1,
rectangle_position=(
np.array(large_grating["visual_size"]) - np.array(small_grating["visual_size"])
)
/ 2,
)

small_grating["img"] = pad_to_shape(small_grating["img"], shape=large_grating["img"].shape)
small_grating["mask"] = pad_to_shape(small_grating["mask"], shape=large_grating["img"].shape)

img = np.where(small_grating_mask["mask"], small_grating["img"], large_grating["img"])
mask = np.where(small_grating_mask["mask"], small_grating["mask"], large_grating["img"])

Expand Down

0 comments on commit 93c6b92

Please sign in to comment.