Skip to content

Commit

Permalink
closes #120; moved overviews to inits
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnSchmittwilken committed Feb 16, 2023
1 parent a162d54 commit 9a65592
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 248 deletions.
85 changes: 85 additions & 0 deletions stimuli/components/__init__.py
Expand Up @@ -417,3 +417,88 @@ def round_n_phases(n_phases, length, period="either"):
closest = possible_n_phases[np.argmin(np.abs(possible_n_phases - n_phases))]

return int(closest)


def create_overview(mask=False, save=None):
import numpy as np
from stimuli.utils import plot_stimuli
import stimuli.components.angulars as angulars
import stimuli.components.checkerboards as checkerboards
import stimuli.components.circulars as circulars
import stimuli.components.edges as edges
import stimuli.components.frames as frames
import stimuli.components.gaussians as gaussians
import stimuli.components.gratings as gratings
import stimuli.components.lines as lines
import stimuli.components.mondrians as mondrians
import stimuli.components.shapes as shapes


p = {
"visual_size": 10,
"ppd": 20,
}

p_mondrians = {
"mondrian_positions": ((0,0), (0,5), (1,3), (4,6), (6,1)),
"mondrian_sizes": 3,
"mondrian_intensities": np.random.rand(5),
}

# fmt: off
stims = {
# angulars
"wedge": angulars.wedge(**p, width=30, radius=3),
"angular_grating": angulars.grating(**p, n_segments=8),
"pinwheel": angulars.pinwheel(**p, n_segments=8, radius=3),
# checkerboards
"checkerboard_v1": checkerboards.checkerboard(**p, board_shape=(10, 10)),
"checkerboard_v2": checkerboards.checkerboard(**p, board_shape=(10, 10), rotation=45),
"checkerboard_v3": checkerboards.checkerboard(**p, frequency=1),
"checkerboard_v4": checkerboards.checkerboard(**p, frequency=1, rotation=45),
# circulars
"disc_and_rings": circulars.disc_and_rings(**p, radii=[1, 2, 3]),
"disc": circulars.disc(**p, radius=3),
"ring": circulars.ring(**p, radii=(1, 3)),
"annulus (=ring)": circulars.annulus(**p, radii=(1, 3)),
"circular_grating": circulars.grating(**p, frequency=1),
"circular_grating_v2": circulars.grating(**p, n_rings=8),
"bessel": circulars.bessel(**p, frequency=1),
# edges
"step_edge": edges.step_edge(**p),
"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_grating": frames.grating(**p, n_frames=8),
# gaussians
"gaussian": gaussians.gaussian(**p, sigma=(1, 2)),
# gratings
"square_wave": gratings.square_wave(**p, frequency=1),
"square_wave2": gratings.square_wave(**p, frequency=1, rotation=45),
"sine_wave": gratings.sine_wave(**p, frequency=1),
"gabor": gratings.gabor(**p, frequency=1, sigma=2),
"staircase": gratings.staircase(**p, n_bars=8),
"plaid": gratings.plaid(grating_parameters1={**p, "frequency": 1},
grating_parameters2={**p, "frequency": 1, "rotation": 90},
sigma=2),
# lines
"line": lines.line(**p, line_length=3),
"dipole": lines.dipole(**p, line_length=3, line_gap=0.5),
"line_circle": lines.circle(**p, radius=3),
# mondrians
"mondrians": mondrians.mondrians(**p, **p_mondrians),
# shapes
"rectangle": shapes.rectangle(**p, rectangle_size=3),
"triangle": shapes.triangle(**p, triangle_size=3),
"cross": shapes.cross(**p, cross_size=3, cross_thickness=0.5),
"parallelogram": shapes.parallelogram(**p, parallelogram_size=(3, 3, 1)),
"ellipse": shapes.ellipse(**p, radius=(2, 3)),
"shape_wedge": shapes.wedge(**p, width=30, radius=3),
"shape_annulus": shapes.annulus(**p, radii=(1, 3)),
"shape_ring": shapes.ring(**p, radii=(1, 3)),
"shape_disc": shapes.disc(**p, radius=3),
}

# Plotting
plot_stimuli(stims, mask=mask, save=save)
83 changes: 0 additions & 83 deletions stimuli/components/overview.py

This file was deleted.

135 changes: 135 additions & 0 deletions stimuli/illusions/__init__.py
Expand Up @@ -16,3 +16,138 @@
from .todorovics import *
from .wedding_cakes import *
from .whites import *


def create_overview(mask=False, save=None):
import stimuli.illusions.angulars as angulars
import stimuli.illusions.benarys as benarys
import stimuli.illusions.checkerboards as checkerboards
import stimuli.illusions.circulars as circulars
from stimuli.illusions.cornsweets import cornsweet
import stimuli.illusions.cubes as cubes
import stimuli.illusions.delboeufs as delboeufs
from stimuli.illusions.dungeons import dungeon
import stimuli.illusions.gratings as gratings
from stimuli.illusions.hermanns import grid as hermann_grid
from stimuli.illusions.mondrians import corrugated_mondrians
import stimuli.illusions.mueller_lyers as mueller_lyers
from stimuli.illusions.ponzos import ponzo
import stimuli.illusions.sbcs as sbcs
import stimuli.illusions.todorovics as todorovics
from stimuli.illusions.wedding_cakes import wedding_cake
import stimuli.illusions.whites as whites
import stimuli.illusions.frames as frames
from stimuli.utils import plot_stimuli
p = {
"visual_size": (10, 10),
"ppd": 20,
}

p_mondrians = {
"mondrian_depths": (0.0, 1.0, 0.0, -1.0),
"target_indices": ((1, 1), (3, 1)),
"mondrian_intensities": (
(0.4, 0.75, 0.4, 0.75),
(0.75, 0.4, 0.75, 1.0),
(0.4, 0.75, 0.4, 0.75),
(0.0, 0.4, 0.0, 0.4),
),
}


p_small_grating = {
"ppd": 20,
"frequency": 1,
"intensity_bars": (1, 0),
}

# fmt: off
stims = {
# Angular
"pinwheel": angulars.pinwheel(**p, n_segments=8),
# Benary
"benary_general": benarys.cross_generalized(**p, target_size=1, cross_thickness=2, target_x=(3, 6, 3, 6), target_y=(4, 6, 6, 4)),
"benary_rectangles": benarys.cross_rectangles(**p, target_size=1, cross_thickness=2),
"benary_triangles": benarys.cross_triangles(**p, target_size=1, cross_thickness=2),
"todorovic_benary_general": benarys.todorovic_generalized(**p, L_width=2, target_size=1, target_x=(3, 6, 3, 6), target_y=(4, 6, 6, 4)),
"todorovic_benary_rectangles": benarys.todorovic_rectangles(**p, target_size=1, L_width=2),
"todorovic_benary_triangles": benarys.todorovic_triangles(**p, target_size=1, L_width=2),
# Checkerboards
"checkerboard": checkerboards.checkerboard(**p, board_shape=8, target_indices=[(3, 2), (3, 5)]),
"contrast-contrast": checkerboards.contrast_contrast(**p, board_shape=8, target_shape=(4, 4)),
# Circular
"circular_rings": circulars.rings(**p, frequency=1.0),
"circular_rings_two_sided": circulars.two_sided_rings(**p, frequency=1.0),
"circular_bullseye": circulars.bullseye(**p, frequency=1.0),
"circular_bullseye_two_sided": circulars.two_sided_bullseye(**p, frequency=1.0),
# Cornsweet
"cornsweet": cornsweet(**p, ramp_width=3),
# Cube
"cube_variable": cubes.varying_cells(ppd=20, cell_heights=(1, 1.5, 1), cell_widths=(1.5, 2, 1.5), cell_spacing=0.5, targets=1),
"cube": cubes.cube(**p, n_cells=5, targets=(1, 2), cell_thickness=1, cell_spacing=0.5),
# Delbouef
"delboeuf": delboeufs.delboeuf(**p, outer_radius=4, target_radius=1),
"2sided_delboeuf": delboeufs.two_sided(**p, outer_radii=(2, 1.1), target_radius=1),
# Dungeon
"dungeon": 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),
"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)),
"2sided_bullseye": frames.two_sided_bullseye(**p, frequency=1),
# Grating
"square_wave": gratings.square_wave(**p, frequency=0.5, target_indices=(3,)),
"grating_uniform": gratings.uniform(**p, frequency=1, grating_size=3, target_indices=(3,)),
"grating_grating1": gratings.grating(large_grating_params={**p, "frequency": 2, "rotation": 45},
small_grating_params={**p_small_grating, "visual_size": 4, "target_indices": (1, 3, 5, 7),}),
"grating_grating2": gratings.grating(large_grating_params={**p, "frequency": 1},
small_grating_params={**p_small_grating, "visual_size": 4,"target_indices": (1, 3, 5, 7),}),
"grating_grating3": gratings.grating(large_grating_params={**p, "frequency": 1, "intensity_bars": (0, 1),},
small_grating_params={**p_small_grating, "visual_size": (4, 10), "target_indices": (9, 11, 13),}),
"grating_grating_masked": gratings.grating_masked(large_grating_params={**p, "frequency": 1, "rotation": 90,},
small_grating_params={**p_small_grating, "visual_size": 4, "target_indices": (1, 3, 5, 7),},
mask_size=(2, 2, 1)),
"counterphase_induction": gratings.counterphase_induction(**p, frequency=1, target_size=4, target_phase_shift=90,),
"grating_induction": gratings.induction(**p, frequency=0.5, target_width=0.5),
"grating_induction_blur": gratings.induction_blur(**p, frequency=0.5, target_width=0.5, target_blur=2),
# Hermann´
"hermann": hermann_grid(**p, element_size=(1.5, 1.5, 0.2)),
# Mondrians
"mondrians": corrugated_mondrians(**p, **p_mondrians),
# Mueller-Lyer
"mueller-lyer": mueller_lyers.mueller_lyer(**p, outer_lines_length=1.5, outer_lines_angle=45, target_length=6, line_width=0.1),
"2sided_mueller-lyer": mueller_lyers.two_sided(**p, outer_lines_length=1.5, outer_lines_angle=45, target_length=2.5, line_width=0.1),
# Ponzo
"ponzo": ponzo(**p, outer_lines_length=8, outer_lines_width=0.1, target_lines_length=3, target_lines_width=0.1, target_distance=3),
# SBC
"sbc_generalized": sbcs.generalized(**p, target_size=3, target_position=(0, 2)),
"sbc_basic": sbcs.basic(**p, target_size=3),
"sbc_two_sided": sbcs.two_sided(**p, target_size=3),
"sbc_with_dots": sbcs.with_dots(ppd=20, n_dots=5, dot_radius=3, distance=0.5, target_shape=3),
"sbc_dotted": sbcs.dotted(ppd=20, n_dots=5, dot_radius=3, distance=0.5, target_shape=3),
"2sided_sbc_with_dots": sbcs.two_sided_with_dots(ppd=20, n_dots=5, dot_radius=3, distance=0.5, target_shape=3),
"2sided_dotted_sbc": sbcs.two_sided_dotted(ppd=20, n_dots=5, dot_radius=3, distance=0.5, target_shape=3),
# Todorovic
"todorovic_rectangle_general": todorovics.rectangle_generalized(**p, target_size=4, target_position=3, covers_size=2, covers_x=(2, 6), covers_y=(2, 6)),
"todorovic_rectangle": todorovics.rectangle(**p, target_size=4, covers_size=2, covers_offset=2),
"todorovic_cross_general": todorovics.cross_generalized(**p, cross_size=4, cross_arm_ratios=1., cross_thickness=2, covers_size=2, covers_x=(2, 6), covers_y=(2, 6)),
"todorovic_cross": todorovics.cross(**p, cross_size=4, cross_thickness=2, covers_size=2),
"todorovic_equal": todorovics.equal(**p, cross_size=4, cross_thickness=2),
"2sided_todorovic_rectangle": todorovics.two_sided_rectangle(**p, target_size=3, covers_size=1.5, covers_offset=1.5),
"2sided_todorovic_cross": todorovics.two_sided_cross(**p, cross_size=3, cross_thickness=1.5, covers_size=1.5),
"2sided_todorovic_equal": todorovics.two_sided_equal(**p, cross_size=3, cross_thickness=1.5),
# Wedding cake
"wedding_cake": wedding_cake(**p, L_size=(3, 3, 1), target_height=1, target_indices1=((1, 1), (2, 1)),),
# White
"white_general": whites.generalized(**p, frequency=0.5, target_indices=(1, 3, 5), target_center_offsets=(-1, -3, -1), target_heights=(2, 3, 2)),
"white_basic": whites.white(**p, frequency=0.5, target_indices=(2, -3), target_height=2),
"white_two-rows": whites.white_two_rows(**p, frequency=0.5, target_indices_top=(2,4), target_indices_bottom=(-2, -4), target_height=1, target_center_offset=2),
"Anderson White": whites.anderson(**p, frequency=0.5, target_indices_top=3, target_indices_bottom=-2, target_center_offset=2, target_height=2, stripe_center_offset=1.5, stripe_height=2),
"Yazdanbakhsh White": whites.yazdanbakhsh(**p, frequency=0.5, target_indices_top=3, target_indices_bottom=-2, target_center_offset=2, target_height=2, gap_size=0.5),
"Howe White": whites.howe(**p, frequency=0.5, target_indices_top=3, target_indices_bottom=-2, target_center_offset=2, target_height=2),
}

# Plot
plot_stimuli(stims, mask=mask, save=save)

0 comments on commit 9a65592

Please sign in to comment.