Skip to content

Commit

Permalink
Rename and update demo components.waves
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisVincent committed Mar 22, 2023
1 parent 9b303b9 commit aeed9f8
Showing 1 changed file with 44 additions and 24 deletions.
Expand Up @@ -13,12 +13,12 @@ kernelspec:
---

```{important}
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/computational-psychology/stimupy/HEAD?urlpath=lab/tree/docs/reference/demos/components/gratings.md)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/computational-psychology/stimupy/HEAD?urlpath=lab/tree/docs/reference/demos/components/waves.md)
to get interactivity
```

# Components - Gratings
{py:mod}`stimupy.components.gratings`
# Components - Waves
{py:mod}`stimupy.components.waves`

```{code-cell} ipython3
:tags: [remove-cell]
Expand All @@ -28,17 +28,18 @@ import ipywidgets as iw
from stimupy.utils import plot_stim
```

## Sine-wave
{py:func}`stimupy.components.gratings.sine_wave`
## Sinewave
{py:func}`stimupy.components.waves.sine`

```{code-cell} ipython3
from stimupy.components.gratings import sine_wave
from stimupy.components.waves import sine
# Define widgets
w_height = iw.IntSlider(value=10, min=1, max=20, description="height [deg]")
w_width = iw.IntSlider(value=10, min=1, max=20, description="width [deg]")
w_ppd = iw.IntSlider(value=20, min=1, max=40, description="ppd")
w_base_type = iw.Dropdown(value="horizontal", options=['horizontal','vertical','rotated','radial','cityblock','angular'], description="base_type")
w_freq = iw.FloatSlider(value=1, min=0, max=2, description="frequency [cpd]")
w_phase = iw.FloatSlider(value=0, min=0, max=360, description="phase shift [deg]")
w_rot = iw.FloatSlider(value=0, min=0, max=360, description="rotation [deg]")
Expand All @@ -53,16 +54,17 @@ w_mask = iw.ToggleButton(value=False, disabled=False, description="add mask")
# Layout
b_im_size = iw.HBox([w_height, w_width, w_ppd])
b_geometry = iw.HBox([w_freq, w_phase, w_rot])
b_geometry = iw.HBox([w_base_type, w_freq, w_phase, w_rot])
b_intensities = iw.HBox([w_int1, w_int2])
b_add = iw.HBox([w_ori, w_period, w_round, w_mask])
ui = iw.VBox([b_im_size, b_geometry, b_intensities, b_add])
# Function for showing stim
def show_sine_wave(
def show_sine(
height=None,
width=None,
ppd=None,
base_type=None,
rotation=None,
frequency=None,
phase_shift=None,
Expand All @@ -73,13 +75,14 @@ def show_sine_wave(
period=None,
add_mask=False,
):
stim = sine_wave(
stim = sine(
visual_size=(height, width),
ppd=ppd,
base_type=base_type,
rotation=rotation,
frequency=frequency,
phase_shift=phase_shift,
intensity_bars=(int1, int2),
intensities=(int1, int2),
origin=origin,
round_phase_width=round_phase_width,
period=period,
Expand All @@ -88,11 +91,12 @@ def show_sine_wave(
# Set interactivity
out = iw.interactive_output(
show_sine_wave,
show_sine,
{
"height": w_height,
"width": w_width,
"ppd": w_ppd,
"base_type": w_base_type,
"rotation": w_rot,
"frequency": w_freq,
"phase_shift": w_phase,
Expand All @@ -109,17 +113,18 @@ out = iw.interactive_output(
display(ui, out)
```

## Square-wave
{py:func}`stimupy.components.gratings.square_wave`
## Squarewave
{py:func}`stimupy.components.waves.square`

```{code-cell} ipython3
from stimupy.components.gratings import square_wave
from stimupy.components.waves import square
# Define widgets
w_height = iw.IntSlider(value=10, min=1, max=20, description="height [deg]")
w_width = iw.IntSlider(value=10, min=1, max=20, description="width [deg]")
w_ppd = iw.IntSlider(value=20, min=1, max=40, description="ppd")
w_base_type = iw.Dropdown(value="horizontal", options=['horizontal','vertical','rotated','radial','cityblock','angular'], description="base_type")
w_freq = iw.FloatSlider(value=1, min=0, max=2, description="frequency [cpd]")
w_phase = iw.FloatSlider(value=0, min=0, max=360, description="phase shift [deg]")
w_rot = iw.FloatSlider(value=0, min=0, max=360, description="rotation [deg]")
Expand All @@ -134,16 +139,17 @@ w_mask = iw.ToggleButton(value=False, disabled=False, description="add mask")
# Layout
b_im_size = iw.HBox([w_height, w_width, w_ppd])
b_geometry = iw.HBox([w_freq, w_phase, w_rot])
b_geometry = iw.HBox([w_base_type, w_freq, w_phase, w_rot])
b_intensities = iw.HBox([w_int1, w_int2])
b_add = iw.HBox([w_ori, w_period, w_round, w_mask])
ui = iw.VBox([b_im_size, b_geometry, b_intensities, b_add])
# Function for showing stim
def show_square_wave(
def show_square(
height=None,
width=None,
ppd=None,
base_type=None,
rotation=None,
frequency=None,
phase_shift=None,
Expand All @@ -154,13 +160,14 @@ def show_square_wave(
period=None,
add_mask=False,
):
stim = square_wave(
stim = square(
visual_size=(height, width),
ppd=ppd,
base_type=base_type,
rotation=rotation,
frequency=frequency,
phase_shift=phase_shift,
intensity_bars=(int1, int2),
intensities=(int1, int2),
origin=origin,
round_phase_width=round_phase_width,
period=period,
Expand All @@ -169,11 +176,12 @@ def show_square_wave(
# Set interactivity
out = iw.interactive_output(
show_square_wave,
show_square,
{
"height": w_height,
"width": w_width,
"ppd": w_ppd,
"base_type": w_base_type,
"rotation": w_rot,
"frequency": w_freq,
"phase_shift": w_phase,
Expand All @@ -191,54 +199,63 @@ display(ui, out)
```

## Staircase
{py:func}`stimupy.components.gratings.staircase`
{py:func}`stimupy.components.waves.staircase`

```{code-cell} ipython3
from stimupy.components.gratings import staircase
from stimupy.components.waves import staircase
# Define widgets
w_height = iw.IntSlider(value=10, min=1, max=20, description="height [deg]")
w_width = iw.IntSlider(value=10, min=1, max=20, description="width [deg]")
w_ppd = iw.IntSlider(value=20, min=1, max=40, description="ppd")
w_base_type = iw.Dropdown(value="horizontal", options=['horizontal','vertical','rotated','radial','cityblock','angular'], description="base_type")
w_freq = iw.FloatSlider(value=0.5, min=0, max=2, description="frequency [cpd]")
w_rot = iw.FloatSlider(value=0, min=0, max=360, description="rotation [deg]")
w_phase = iw.FloatSlider(value=0, min=0, max=360, description="phase shift [deg]")
w_int1 = iw.FloatSlider(value=1, min=0, max=1, description="int1")
w_int2 = iw.FloatSlider(value=0, min=0, max=1, description="int2")
w_ori = iw.Dropdown(value="mean", options=['mean', 'corner', 'center'], description="origin")
w_period = iw.Dropdown(value="ignore", options=['ignore', 'even', 'odd', 'either'], description="period")
w_round = iw.ToggleButton(value=False, disabled=False, description="round phase")
w_mask = iw.ToggleButton(value=False, disabled=False, description="add mask")
# Layout
b_im_size = iw.HBox([w_height, w_width, w_ppd])
b_geometry = iw.HBox([w_freq, w_rot])
b_geometry = iw.HBox([w_base_type, w_freq, w_phase, w_rot])
b_intensities = iw.HBox([w_int1, w_int2])
b_add = iw.HBox([w_period, w_round, w_mask])
b_add = iw.HBox([w_ori, w_period, w_round, w_mask])
ui = iw.VBox([b_im_size, b_geometry, b_intensities, b_add])
# Function for showing stim
def show_staircase(
height=None,
width=None,
ppd=None,
base_type=None,
rotation=None,
frequency=None,
phase_shift=None,
int1=None,
int2=None,
round_phase_width=False,
period=None,
add_mask=False,
origin=None,
):
stim = staircase(
visual_size=(height, width),
ppd=ppd,
base_type=base_type,
rotation=rotation,
frequency=frequency,
intensity_bars=(int1, int2),
phase_shift=phase_shift,
intensities=(int1, int2),
round_phase_width=round_phase_width,
period=period,
origin=origin,
)
plot_stim(stim, mask=add_mask)
Expand All @@ -249,13 +266,16 @@ out = iw.interactive_output(
"height": w_height,
"width": w_width,
"ppd": w_ppd,
"base_type": w_base_type,
"rotation": w_rot,
"frequency": w_freq,
"int1": w_int1,
"int2": w_int2,
"round_phase_width": w_round,
"period": w_period,
"add_mask": w_mask,
"phase_shift": w_phase,
"origin": w_ori,
},
)
Expand Down

0 comments on commit aeed9f8

Please sign in to comment.