Attention
To run locally, the code for these interactive demos requires
a Jupyter Notebook environment,
and the Jupyter Widgets extension (ipywidgets).
Noises - Binaries#
Binary#
stimupy.noises.binaries.binary()
import ipywidgets as iw
from stimupy.utils import plot_stim
from stimupy.noises.binaries import binary
# 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_int1 = iw.FloatSlider(value=0., min=0, max=1, description="intensity1")
w_int2 = iw.FloatSlider(value=1., min=0, max=1, description="intensity2")
# Layout
b_im_size = iw.HBox([w_height, w_width, w_ppd])
b_intensities = iw.HBox([w_int1, w_int2])
ui = iw.VBox([b_im_size, b_intensities])
# Function for showing stim
def show_binary(
height=None,
width=None,
ppd=None,
intensity1=None,
intensity2=None,
):
try:
stim = binary(
visual_size=(height, width),
ppd=ppd,
intensity_range=(intensity1, intensity2),
)
plot_stim(stim, mask=False)
except Exception as e:
raise ValueError(f"Invalid parameter combination: {e}") from None
# Set interactivity
out = iw.interactive_output(
show_binary,
{
"height": w_height,
"width": w_width,
"ppd": w_ppd,
"intensity1": w_int1,
"intensity2": w_int2,
},
)
# Show
display(ui, out)