Skip to content

Commit

Permalink
White's as toplevel stimulus module
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisVincent committed Mar 20, 2023
1 parent c499a41 commit a59b28d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 52 deletions.
2 changes: 1 addition & 1 deletion stimupy/__init__.py
@@ -1,3 +1,3 @@
__version__ = "0.99.0"

from . import components, gabors, illusions, mondrians, noises, utils
from . import components, gabors, illusions, mondrians, noises, utils, whites
8 changes: 0 additions & 8 deletions stimupy/illusions/__init__.py
Expand Up @@ -15,7 +15,6 @@
sbcs,
todorovics,
wedding_cakes,
whites,
)


Expand Down Expand Up @@ -117,13 +116,6 @@ def create_overview():
"2sided_todorovic_equal": todorovics.two_sided_equal(**p, cross_size=3, cross_thickness=1.5),
# Wedding cake
"wedding_cake": wedding_cakes.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),
}
# fmt: on

Expand Down
32 changes: 16 additions & 16 deletions stimupy/papers/RHS2007.py
Expand Up @@ -145,7 +145,7 @@ def WE_thick(ppd=PPD, pad=True):
"period": "even",
}

stim = illusions.whites.white(
stim = stimupy.whites.white(
visual_size=(height, width),
**params,
)
Expand Down Expand Up @@ -206,7 +206,7 @@ def WE_thin_wide(ppd=PPD, pad=True):
"period": "even",
}

stim = illusions.whites.white(
stim = stimupy.whites.white(
visual_size=(height, width),
**params,
)
Expand Down Expand Up @@ -258,12 +258,12 @@ def WE_dual(ppd=PPD, pad=True):
"period": "even",
}

stim1 = illusions.whites.white(
stim1 = stimupy.whites.white(
visual_size=(height, width),
**params,
)

stim2 = illusions.whites.white(
stim2 = stimupy.whites.white(
visual_size=(height, width),
**params,
)
Expand Down Expand Up @@ -333,7 +333,7 @@ def WE_anderson(ppd=PPD, pad=True):
"period": "even",
}

stim = illusions.whites.anderson(
stim = stimupy.whites.anderson(
visual_size=(height, width),
**params,
)
Expand Down Expand Up @@ -400,7 +400,7 @@ def WE_howe(ppd=PPD, pad=True):
"period": "even",
}

stim = illusions.whites.howe(
stim = stimupy.whites.howe(
visual_size=(height, width),
**params,
)
Expand Down Expand Up @@ -501,7 +501,7 @@ def WE_radial_thick_small(ppd=PPD, pad=True):
"intensity_target": v2,
}

stim = illusions.whites.radial(
stim = stimupy.whites.radial(
visual_size=(16, 16),
**params,
)
Expand Down Expand Up @@ -556,7 +556,7 @@ def WE_radial_thick(ppd=PPD, pad=True):
"intensity_target": v2,
}

stim = illusions.whites.radial(
stim = stimupy.whites.radial(
visual_size=(24, 24),
**params,
)
Expand Down Expand Up @@ -611,7 +611,7 @@ def WE_radial_thin_small(ppd=PPD, pad=True):
"intensity_target": v2,
}

stim = illusions.whites.radial(
stim = stimupy.whites.radial(
visual_size=(16, 16),
**params,
)
Expand Down Expand Up @@ -666,7 +666,7 @@ def WE_radial_thin(ppd=PPD, pad=True):
"intensity_target": v2,
}

stim = illusions.whites.radial(
stim = stimupy.whites.radial(
visual_size=(24, 24),
**params,
)
Expand Down Expand Up @@ -718,13 +718,13 @@ def WE_circular1(ppd=PPD, pad=True):
"intensity_target": v2,
}

stim1 = illusions.whites.circular(
stim1 = stimupy.whites.circular(
visual_size=(height, width),
intensity_rings=(v1, v3),
**params,
)

stim2 = illusions.whites.circular(
stim2 = stimupy.whites.circular(
visual_size=(height, width),
intensity_rings=(v3, v1),
**params,
Expand Down Expand Up @@ -778,13 +778,13 @@ def WE_circular05(ppd=PPD, pad=True):
"intensity_target": v2,
}

stim1 = illusions.whites.circular(
stim1 = stimupy.whites.circular(
visual_size=(height, width),
intensity_rings=(v1, v3),
**params,
)

stim2 = illusions.whites.circular(
stim2 = stimupy.whites.circular(
visual_size=(height, width),
intensity_rings=(v3, v1),
**params,
Expand Down Expand Up @@ -838,13 +838,13 @@ def WE_circular025(ppd=PPD, pad=True):
"intensity_target": v2,
}

stim1 = illusions.whites.circular(
stim1 = stimupy.whites.circular(
visual_size=(height, width),
intensity_rings=(v1, v3),
**params,
)

stim2 = illusions.whites.circular(
stim2 = stimupy.whites.circular(
visual_size=(height, width),
intensity_rings=(v3, v1),
**params,
Expand Down
16 changes: 6 additions & 10 deletions stimupy/papers/domijan2015.py
Expand Up @@ -38,13 +38,9 @@

import numpy as np

import stimupy
from stimupy import illusions
from stimupy.utils import (
pad_dict_by_visual_size,
pad_dict_to_shape,
resolution,
stack_dicts,
)
from stimupy.utils import pad_dict_by_visual_size, pad_dict_to_shape, resolution, stack_dicts

__all__ = [
"dungeon",
Expand Down Expand Up @@ -646,7 +642,7 @@ def white(visual_size=VSIZES["white"], ppd=PPD, pad=PAD, shape=SHAPES["white"]):
"period": "even",
}

stim = illusions.whites.white(
stim = stimupy.whites.white(
**params,
intensity_bars=(v3, v1),
intensity_target=v2,
Expand Down Expand Up @@ -1093,7 +1089,7 @@ def white_yazdanbakhsh(
"period": "even",
}

stim = illusions.whites.yazdanbakhsh(
stim = stimupy.whites.yazdanbakhsh(
**params,
intensity_bars=(v3, v1),
intensity_target=v2,
Expand Down Expand Up @@ -1180,7 +1176,7 @@ def white_anderson(
"period": "even",
}

stim = illusions.whites.anderson(
stim = stimupy.whites.anderson(
**params,
intensity_bars=(v1, v3),
intensity_target=v2,
Expand Down Expand Up @@ -1262,7 +1258,7 @@ def white_howe(visual_size=VSIZES["white_howe"], ppd=PPD, shape=SHAPES["white_ho
"period": "even",
}

stim = illusions.whites.howe(
stim = stimupy.whites.howe(
**params,
intensity_bars=(v1, v3),
intensity_target=v2,
Expand Down
3 changes: 2 additions & 1 deletion stimupy/papers/murray2020.py
Expand Up @@ -36,6 +36,7 @@
import numpy as np
import scipy.io

import stimupy
from stimupy import illusions
from stimupy.utils import pad_dict_by_visual_size, rotate_dict

Expand Down Expand Up @@ -740,7 +741,7 @@ def white(ppd=PPD):
"period": "even",
}

stim = illusions.whites.white_two_rows(**params)
stim = stimupy.whites.white_two_rows(**params)
stim = rotate_dict(stim)
reduced_mask = np.where(stim["target_mask"] == 2, 2, 0)
reduced_mask = np.where(stim["target_mask"] == 5, 1, reduced_mask).astype(int)
Expand Down
47 changes: 31 additions & 16 deletions stimupy/illusions/whites.py → stimupy/whites.py
Expand Up @@ -756,51 +756,66 @@ def yazdanbakhsh(
return stim


if __name__ == "__main__":
from stimupy.utils import plot_stimuli
def overview(**kwargs):
"""Generate example stimuli from this module
params = {
Returns
-------
stims : dict
dict with all stimuli containing individual stimulus dicts.
"""
default_params = {
"visual_size": 10,
"ppd": 10,
"ppd": 30,
"frequency": 0.5,
}
default_params.update(kwargs)

stims = {
"generalized": generalized(
**params, target_indices=(1, 3), target_center_offsets=(-1, -3), target_heights=(2, 3)
# fmt: off
stimuli = {
"White's stimulus": white(**default_params, target_indices=(2, -3), target_height=2),
"White's, generalized": generalized(
**default_params, target_indices=(1, 3, 5), target_center_offsets=(-1, -3, -1), target_heights=(2, 3, 2)
),
"white": white(**params, target_indices=(2, -3), target_height=2),
"white_two_rows": white_two_rows(
**params,
"White's, two rows": white_two_rows(
**default_params,
target_indices_top=(2, 4),
target_indices_bottom=(-2, -4),
target_height=1,
target_center_offset=2,
),
"anderson": anderson(
**params,
"White's - Anderson": anderson(
**default_params,
target_indices_top=3,
target_indices_bottom=-2,
target_center_offset=2,
target_height=2,
stripe_center_offset=1.5,
stripe_height=2,
),
"howe": howe(
**params,
"White's - Howe": howe(
**default_params,
target_indices_top=3,
target_indices_bottom=-2,
target_center_offset=2,
target_height=2,
),
"yazdanbakhsh": yazdanbakhsh(
**params,
"White's - Yazdanbakhsh": yazdanbakhsh(
**default_params,
target_indices_top=3,
target_indices_bottom=-2,
target_center_offset=2,
target_height=2,
gap_size=0.5,
),
}
# fmt: on

return stimuli


if __name__ == "__main__":
from stimupy.utils import plot_stimuli

stims = overview()
plot_stimuli(stims, mask=True, save=None)

0 comments on commit a59b28d

Please sign in to comment.