Skip to content

Commit

Permalink
fine-tuned frames
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnSchmittwilken committed Mar 14, 2023
1 parent af0a83a commit 76fa262
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 85 deletions.
2 changes: 1 addition & 1 deletion stimupy/components/__init__.py
Expand Up @@ -680,7 +680,7 @@ def create_overview():
"gaussian_edge": edges.gaussian_edge(**p, sigma=1.5),
"cornsweet_edge": edges.cornsweet_edge(**p, ramp_width=3),
# frames
"frames": frames.frames(**p, frame_radii=(1, 2, 3)),
"frames": frames.frames(**p, radii=(1, 2, 3)),
"frames_sine_wave": frames.sine_wave(**p, frequency=0.5),
"frames_square_wave": frames.square_wave(**p, frequency=0.5),
# gaussians
Expand Down
13 changes: 8 additions & 5 deletions stimupy/components/frames.py
Expand Up @@ -60,7 +60,7 @@ def frames(
visual_size=None,
ppd=None,
shape=None,
frame_radii=None,
radii=None,
intensity_frames=(1.0, 0.0),
intensity_background=0.5,
origin="mean",
Expand All @@ -75,7 +75,7 @@ def frames(
pixels per degree [vertical, horizontal]
shape : Sequence[Number, Number], Number, or None (default)
shape [height, width] of image, in pixels
frame_radii : Sequence[Number]
radii : Sequence[Number]
radii of each frame, in degrees visual angle
intensity_frames : Sequence[float, ...]
intensity value for each frame, by default (1.0, 0.0).
Expand All @@ -95,12 +95,15 @@ def frames(
mask with integer index for each frame (key: "frame_mask"),
and additional keys containing stimulus parameters
"""
if frame_radii is None:
raise ValueError("frames() missing argument 'frame_radii' which is not 'None'")
if radii is None:
raise ValueError("frames() missing argument 'radii' which is not 'None'")

if np.diff(radii).min() < 0:
raise ValueError("radii need to monotonically increase")

# Get frames mask
stim = mask_frames(
edges=frame_radii,
edges=radii,
shape=shape,
visual_size=visual_size,
ppd=ppd,
Expand Down
4 changes: 2 additions & 2 deletions stimupy/illusions/__init__.py
Expand Up @@ -83,10 +83,10 @@ def create_overview():
"dungeon": dungeons.dungeon(**p, n_cells=5),
# Frames
"frames": frames.rings(**p, frequency=0.5, target_indices=3),
"frames_general": frames.rings_generalized(**p, frame_radii=(1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5), target_indices=3),
"frames_general": frames.rings_generalized(**p, radii=(1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5), target_indices=3),
"2sided_frames": frames.two_sided_rings(**p, frequency=1, target_indices=3),
"frames_bullseye": frames.bullseye(**p, frequency=0.5),
"frames_bullseye_general": frames.bullseye_generalized(**p, frame_radii=(1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5)),
"frames_bullseye_general": frames.bullseye_generalized(**p, radii=(1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5)),
"2sided_bullseye": frames.two_sided_bullseye(**p, frequency=1),
# Grating
"square_wave": gratings.square_wave(**p, frequency=0.5, target_indices=(3,)),
Expand Down
16 changes: 9 additions & 7 deletions stimupy/illusions/frames.py
Expand Up @@ -203,10 +203,10 @@ def two_sided_rings(


def rings_generalized(
frame_radii,
visual_size=None,
ppd=None,
shape=None,
radii=None,
intensity_frames=(1.0, 0.0),
intensity_background=0.5,
target_indices=(),
Expand All @@ -217,14 +217,14 @@ def rings_generalized(
Parameters
----------
frame_radii : Sequence[Number]
radii of each frame, in degrees visual angle
visual_size : Sequence[Number, Number], Number, or None (default)
visual size [height, width] of image, in degrees
ppd : Sequence[Number, Number], Number, or None (default)
pixels per degree [vertical, horizontal]
shape : Sequence[Number, Number], Number, or None (default)
shape [height, width] of image, in pixels
radii : Sequence[Number] or None (default)
radii of each frame, in degrees visual angle
intensity_frames : Sequence[float, ...]
intensity value for each frame, by default (1.0, 0.0).
Can specify as many intensities as number of frame_widths;
Expand Down Expand Up @@ -252,7 +252,7 @@ def rings_generalized(

# Frames component
stim = frames_component.frames(
frame_radii=frame_radii,
radii=radii,
visual_size=visual_size,
ppd=ppd,
shape=shape,
Expand Down Expand Up @@ -364,10 +364,10 @@ def bullseye(


def bullseye_generalized(
frame_radii,
visual_size=None,
ppd=None,
shape=None,
radii=None,
intensity_frames=(1.0, 0.0),
intensity_background=0.5,
intensity_target=0.5,
Expand All @@ -385,6 +385,8 @@ def bullseye_generalized(
pixels per degree [vertical, horizontal]
shape : Sequence[Number, Number], Number, or None (default)
shape [height, width] of image, in pixels
radii : Sequence[Number] or None (default)
radii of each frame, in degrees visual angle
intensity_frames : Sequence[float, ...]
intensity value for each frame, by default (1.0, 0.0).
Can specify as many intensities as number of frame_widths;
Expand All @@ -408,7 +410,7 @@ def bullseye_generalized(
and additional keys containing stimulus parameters
"""
stim = rings_generalized(
frame_radii=frame_radii,
radii=radii,
visual_size=visual_size,
ppd=ppd,
shape=shape,
Expand Down Expand Up @@ -509,7 +511,7 @@ def two_sided_bullseye(
from stimupy.utils import plot_stimuli

p1 = {
"frame_radii": (1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5),
"radii": (1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5),
"visual_size": 10,
"ppd": 10,
}
Expand Down
8 changes: 4 additions & 4 deletions stimupy/papers/RHS2007.py
Expand Up @@ -1749,12 +1749,12 @@ def bullseye_thin(ppd=PPD, pad=True):
Research, 44, 309–319.
"""

frame_radii = np.array([0.304, 0.426, 0.548, 0.670, 0.792])
radii = np.array([0.304, 0.426, 0.548, 0.670, 0.792])

params = {
"visual_size": 0.792 * 2,
"ppd": ppd,
"frame_radii": frame_radii,
"radii": radii,
"intensity_target": v2,
}

Expand Down Expand Up @@ -1807,12 +1807,12 @@ def bullseye_thick(ppd=PPD, pad=True):
Bindman, D., & Chubb, C. (2004). Brightness assimilation in bullseye displays. Vision
Research, 44, 309–319.
"""
frame_radii = np.array([0.304, 0.547, 0.790, 1.033, 1.276])
radii = np.array([0.304, 0.547, 0.790, 1.033, 1.276])

params = {
"visual_size": 1.276 * 2,
"ppd": ppd,
"frame_radii": frame_radii,
"radii": radii,
"intensity_target": v2,
}

Expand Down

0 comments on commit 76fa262

Please sign in to comment.