Skip to content

Commit

Permalink
updated grating use in illusions
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnSchmittwilken committed Dec 20, 2022
1 parent d2ce712 commit 84cd234
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
10 changes: 5 additions & 5 deletions stimuli/components/grating.py
Expand Up @@ -138,9 +138,9 @@ def square_wave(
# Determine size/shape of whole image
if None in shape:
shape = [length*alpha[1], length*alpha[0]]
if alpha[1] == 0:
if np.round(alpha[1], 5) == 0:
shape[0] = shape[1]
if alpha[0] == 0:
if np.round(alpha[0], 5) == 0:
shape[1] = shape[0]

if None in ppd:
Expand Down Expand Up @@ -265,9 +265,9 @@ def sine_wave(
# Determine size/shape of whole image
if None in shape:
shape = [length*alpha[1], length*alpha[0]]
if alpha[1] == 0:
if np.round(alpha[1], 5) == 0:
shape[0] = shape[1]
if alpha[0] == 0:
if np.round(alpha[0], 5) == 0:
shape[1] = shape[0]

if None in ppd:
Expand Down Expand Up @@ -380,7 +380,7 @@ def gabor(
if __name__ == "__main__":
from stimuli.utils.plotting import plot_stimuli

rotation = 45
rotation = 90

p1 = {
"visual_size": (10, 5),
Expand Down
33 changes: 13 additions & 20 deletions stimuli/illusions/grating.py
Expand Up @@ -23,7 +23,7 @@ def square_wave(
frequency=None,
n_bars=None,
bar_width=None,
orientation="horizontal",
rotation=0,
period="ignore",
intensity_bars=(1.0, 0.0),
target_indices=(),
Expand Down Expand Up @@ -77,7 +77,7 @@ def square_wave(
frequency=frequency,
n_bars=n_bars,
bar_width=bar_width,
orientation=orientation,
rotation=rotation,
period=period,
intensity_bars=intensity_bars,
)
Expand Down Expand Up @@ -113,7 +113,7 @@ def grating_uniform(
frequency=None,
n_bars=None,
bar_width=None,
orientation="horizontal",
rotation=0,
period="ignore",
intensity_bars=(1.0, 0.0),
target_indices=(),
Expand Down Expand Up @@ -175,7 +175,7 @@ def grating_uniform(
frequency=frequency,
n_bars=n_bars,
bar_width=bar_width,
orientation=orientation,
rotation=rotation,
period=period,
intensity_bars=intensity_bars,
target_indices=target_indices,
Expand Down Expand Up @@ -275,7 +275,7 @@ def grating_grating_shifted(
frequency=None,
n_bars=None,
bar_width=None,
orientation="horizontal",
rotation=0,
period="ignore",
intensity_bars=(1.0, 0.0),
target_indices=(),
Expand Down Expand Up @@ -336,7 +336,7 @@ def grating_grating_shifted(
"frequency": frequency,
"n_bars": n_bars,
"bar_width": bar_width,
"orientation": orientation,
"rotation": rotation,
"period": period,
"intensity_bars": reversed(intensity_bars),
}
Expand All @@ -347,16 +347,12 @@ def grating_grating_shifted(
"frequency": large_grating["frequency"],
"bar_width": large_grating["bar_width"],
"n_bars": large_grating["n_bars"],
"orientation": orientation,
"rotation": rotation,
"period": period,
"intensity_bars": intensity_bars,
"target_indices": target_indices,
"intensity_target": intensity_target,
}
if orientation == "horizontal":
small_params["visual_size"] = (shifted_width, large_grating["visual_size"].width)
elif orientation == "vertical":
small_params["visual_size"] = (large_grating["visual_size"].height, shifted_width)

# Update larger grating params
large_params.update(
Expand All @@ -381,7 +377,7 @@ def grating_induction(
n_bars=None,
bar_width=None,
period="ignore",
orientation="horizontal",
rotation=0,
intensity_bars=(1.0, 0.0),
target_width=0.5,
intensity_target=0.5,
Expand Down Expand Up @@ -440,7 +436,7 @@ def grating_induction(
n_bars=n_bars,
bar_width=bar_width,
period=period,
orientation=orientation,
rotation=rotation,
intensity_bars=intensity_bars,
)

Expand All @@ -449,10 +445,7 @@ def grating_induction(
stim["img"] = gaussian_filter(stim["img"], blur)

# Identify target region
if orientation == "horizontal":
rectangle_size = (target_width, stim["visual_size"].width)
elif orientation == "vertical":
rectangle_size = (stim["visual_size"].height, target_width)
rectangle_size = (target_width, stim["visual_size"].width)

target_mask = rectangle(
rectangle_size=rectangle_size,
Expand All @@ -476,17 +469,17 @@ def grating_induction(

ppd = 36
bar_width = 1.0
orientation = "vertical"
rotation = 90
small_grating_params = {
"n_bars": 8,
"bar_width": bar_width,
"orientation": orientation,
"rotation": rotation,
}

large_grating_params = {
"bar_width": bar_width,
"visual_size": (32, 32),
"orientation": orientation,
"rotation": rotation,
}

stims = {
Expand Down

0 comments on commit 84cd234

Please sign in to comment.