Skip to content

Commit

Permalink
closes #46; removed supersampling
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnSchmittwilken committed Jan 24, 2023
1 parent a97debc commit 980a01e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 55 deletions.
1 change: 0 additions & 1 deletion stimuli/components/angular.py
Expand Up @@ -114,7 +114,6 @@ def wedge(
visual_size=visual_size,
ppd=ppd,
shape=shape,
# supersampling=supersampling,
origin=origin,
)
visual_size = stim["visual_size"]
Expand Down
38 changes: 4 additions & 34 deletions stimuli/components/circular.py
Expand Up @@ -156,7 +156,6 @@ def disc_and_rings(
ppd=None,
shape=None,
intensity_background=0.5,
supersampling=1,
origin="mean",
):
"""Draw a central solid disc with zero or more solid rings (annuli)
Expand All @@ -176,9 +175,6 @@ def disc_and_rings(
shape [height, width] of image, in pixels
intensity_background : float (optional)
value of background, by default 0.5
supersampling : int (optional)
supersampling-factor used for anti-aliasing, by default 5.
Warning: produces smoother circles but might introduce gradients that affect vision!
origin : "corner", "mean" or "center"
if "corner": set origin to upper left corner
if "mean": set origin to hypothetical image center (default)
Expand Down Expand Up @@ -216,29 +212,18 @@ def disc_and_rings(
)
shape = params["shape"]

# Supersample shape (in pixels), to allow for antialiasing
super_shape = resolution.validate_shape((shape[0] * supersampling, shape[1] * supersampling))

# Draw rings
base = image_base(shape=super_shape, visual_size=visual_size, origin=origin)
base = image_base(shape=shape, visual_size=visual_size, origin=origin)
distances = base["radial"]

img = np.ones(super_shape) * intensity_background
img = np.ones(shape) * intensity_background
ints = [*itertools.islice(itertools.cycle(intensity_rings), len(radii))]
for radius, intensity in zip(reversed(radii), reversed(ints)):
img[distances < radius] = intensity

# Downsample the stimulus by local averaging along rows and columns
sampler = resize_array(np.eye(img.shape[0] // supersampling), (1, supersampling))
img = np.dot(sampler, np.dot(img, sampler.T)) / supersampling**2

# Assemble output
params.update(
{
"intensities": intensity_rings,
"supersampling": supersampling,
}
)
params["intensity_rings"] = intensity_rings

return {"img": img, **params}


Expand All @@ -249,7 +234,6 @@ def disc(
ppd=None,
shape=None,
intensity_background=0.5,
supersampling=1,
origin="mean",
):
"""Draw a central disc
Expand All @@ -270,9 +254,6 @@ def disc(
shape [height, width] of image, in pixels
intensity_background : float (optional)
intensity value of background, by default 0.5
supersampling : int (optional)
supersampling-factor used for anti-aliasing, by default 1.
Warning: produces smoother circles but might introduce gradients that affect vision!
origin : "corner", "mean" or "center"
if "corner": set origin to upper left corner
if "mean": set origin to hypothetical image center (default)
Expand All @@ -299,7 +280,6 @@ def disc(
visual_size=visual_size,
ppd=ppd,
intensity_background=intensity_background,
supersampling=supersampling,
shape=shape,
origin=origin,
)
Expand All @@ -314,7 +294,6 @@ def ring(
ppd=None,
shape=None,
intensity_background=0.5,
supersampling=1,
origin="mean",
):
"""Draw a ring (annulus)
Expand All @@ -333,9 +312,6 @@ def ring(
shape [height, width] of image, in pixels
intensity_background : float (optional)
intensity value of background, by default 0.5
supersampling : int (optional)
supersampling-factor used for anti-aliasing, by default 5.
Warning: produces smoother circles but might introduce gradients that affect vision!
origin : "corner", "mean" or "center"
if "corner": set origin to upper left corner
if "mean": set origin to hypothetical image center (default)
Expand Down Expand Up @@ -371,7 +347,6 @@ def ring(
visual_size=visual_size,
ppd=ppd,
intensity_background=intensity_background,
supersampling=supersampling,
origin=origin,
)
return stim
Expand All @@ -389,7 +364,6 @@ def grating(
ring_width=None,
intensity_rings=(1.0, 0.0),
intensity_background=0.5,
supersampling=1,
origin="mean",
):
"""Draw a circular grating, i.e., set of rings
Expand All @@ -413,9 +387,6 @@ def grating(
If fewer intensities are passed than number of radii, cycles through intensities
intensity_background : float (optional)
intensity value of background, by default 0.5
supersampling : int (optional)
supersampling-factor used for anti-aliasing, by default 1.
Warning: produces smoother circles but might introduce gradients that affect vision!
origin : "corner", "mean" or "center"
if "corner": set origin to upper left corner
if "mean": set origin to hypothetical image center (default)
Expand Down Expand Up @@ -449,7 +420,6 @@ def grating(
**stim_params,
intensity_background=intensity_background,
intensity_rings=intensity_rings,
supersampling=supersampling,
origin=origin,
)

Expand Down
19 changes: 2 additions & 17 deletions stimuli/illusions/circular.py
Expand Up @@ -22,7 +22,6 @@ def circular_white(
intensity_target=0.5,
intensity_rings=(1.0, 0.0),
intensity_background=0.5,
supersampling=1,
origin="mean",
):
"""Circular grating, with one or more target rings
Expand Down Expand Up @@ -63,9 +62,6 @@ def circular_white(
If fewer intensities are passed than number of radii, cycles through intensities
intensity_background : float (optional)
intensity value of background, by default 0.5
supersampling : int (optional)
supersampling-factor used for anti-aliasing, by default 1.
Warning: produces smoother circles but might introduce gradients that affect vision!
origin : "corner", "mean" or "center"
if "corner": set origin to upper left corner
if "mean": set origin to hypothetical image center (default)
Expand Down Expand Up @@ -94,7 +90,6 @@ def circular_white(
ring_width=ring_width,
intensity_background=intensity_background,
intensity_rings=intensity_rings,
supersampling=supersampling,
shape=shape,
origin=origin,
)
Expand All @@ -119,7 +114,6 @@ def circular_white(
ring_width=ring_width,
intensity_rings=intensities,
intensity_background=intensity_background,
supersampling=supersampling,
shape=shape,
origin=origin,
)
Expand All @@ -130,12 +124,8 @@ def circular_white(
for i, ring_idx in enumerate(target_indices):
mask = np.where(stim["mask"] == ring_idx+1, i+1, 0)
stim["mask"] = mask.astype(int)

params = {
"target_indices": target_indices,
"intensity_target": intensity_target,
}
stim.update(params)
stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target

return stim

Expand All @@ -150,7 +140,6 @@ def circular_bullseye(
intensity_target=0.5,
intensity_rings=(1.0, 0.0),
intensity_background=0.5,
supersampling=1,
origin="mean",
):
"""Circular Bullseye stimulus
Expand Down Expand Up @@ -192,9 +181,6 @@ def circular_bullseye(
If fewer intensities are passed than number of radii, cycles through intensities
intensity_background : float (optional)
intensity value of background, by default 0.5
supersampling : int (optional)
supersampling-factor used for anti-aliasing, by default 1.
Warning: produces smoother circles but might introduce gradients that affect vision!
origin : "corner", "mean" or "center"
if "corner": set origin to upper left corner
if "mean": set origin to hypothetical image center (default)
Expand Down Expand Up @@ -226,7 +212,6 @@ def circular_bullseye(
intensity_background=intensity_background,
intensity_target=intensity_target,
target_indices=0,
supersampling=supersampling,
origin=origin,
)
return stim
Expand Down
3 changes: 0 additions & 3 deletions stimuli/papers/RHS2007.py
Expand Up @@ -692,7 +692,6 @@ def WE_circular1(ppd=PPD, pad=True):
"target_indices": 4,
"intensity_background": v2,
"intensity_target": v2,
"supersampling": 1,
}

stim1 = illusions.circular.circular_white(
Expand Down Expand Up @@ -751,7 +750,6 @@ def WE_circular05(ppd=PPD, pad=True):
"target_indices": 10,
"intensity_background": v2,
"intensity_target": v2,
"supersampling": 1,
}

stim1 = illusions.circular.circular_white(
Expand Down Expand Up @@ -810,7 +808,6 @@ def WE_circular025(ppd=PPD, pad=True):
"target_indices": 22,
"intensity_background": v2,
"intensity_target": v2,
"supersampling": 1,
}

stim1 = illusions.circular.circular_white(
Expand Down

0 comments on commit 980a01e

Please sign in to comment.