Skip to content

Commit

Permalink
closes #100; added masks to Gaussians, also in Gabors and plaids
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnSchmittwilken committed Jan 26, 2023
1 parent 48ded6e commit 1cfdfa2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
30 changes: 28 additions & 2 deletions stimuli/components/gaussians.py
@@ -1,6 +1,6 @@
import numpy as np
from stimuli.components import image_base
# from stimuli.components.shapes import disc
from stimuli.components.shapes import ellipse


__all__ = [
Expand Down Expand Up @@ -71,13 +71,39 @@ def gaussian(
gaussian = np.exp(-(a*xx**2 + 2*b*xx*yy + c*yy**2))
gaussian = gaussian / gaussian.max() * intensity_max

# create mask as ellipse with sigma radius
mask = ellipse(
visual_size=visual_size,
ppd=ppd,
shape=shape,
radius=sigma,
rotation=rotation,
)["shape_mask"]

stim = {
"img": gaussian,
"gaussian_mask": np.zeros(base["shape"]).astype(int),
"gaussian_mask": mask.astype(int),
"sigma": sigma,
"rotation": rotation,
"visual_size": base["visual_size"],
"shape": base["shape"],
"ppd": base["ppd"],
}
return stim


if __name__ == "__main__":
from stimuli.utils.plotting import plot_stimuli

p = {
"visual_size": (10, 8),
"ppd": 50,
"rotation": 90,
}

stims = {
"gaussian1": gaussian(**p, sigma=2),
"gaussian2": gaussian(**p, sigma=(3, 2)),
}

plot_stimuli(stims, mask=True)
3 changes: 3 additions & 0 deletions stimuli/components/grating.py
Expand Up @@ -9,6 +9,7 @@
"sine_wave",
"gabor",
"staircase",
"plaid",
]


Expand Down Expand Up @@ -501,6 +502,7 @@ def gabor(
return {
**stim,
"sigma": sigma,
"gaussian_mask": gaussian_window["gaussian_mask"],
}


Expand Down Expand Up @@ -701,6 +703,7 @@ def plaid(
grating1["frequency2"] = grating2["frequency"]
grating1["bar_width2"] = grating2["bar_width"]
grating1["n_bars2"] = grating2["n_bars"]
grating1["gaussian_mask"] = window["gaussian_mask"]
return grating1


Expand Down

0 comments on commit 1cfdfa2

Please sign in to comment.