stimupy.components.waves#
Demos#
Functions#
Draw a sine-wave grating given a certain distance_metric |
|
Draw a square-wave grating given a certain distance_metric |
|
Draw a luminance staircase |
|
Draw a Bessel stimulus, i.e. draw circular rings following an nth order Bessel function of a given frequency. |
- sine(visual_size=None, ppd=None, shape=None, frequency=None, n_phases=None, phase_width=None, period='ignore', rotation=0.0, phase_shift=0.0, intensities=(0.0, 1.0), origin='center', distance_metric=None, round_phase_width=False)[source]#
Draw a sine-wave grating given a certain distance_metric
- Parameters:
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
frequency (Number, or None (default)) – spatial frequency of grating, in cycles per degree visual angle. For distance_metric=”angular”, this is used as cycles-per-image.
n_phases (int, or None (default)) – number of phases in the grating
phase_width (Number, or None (default)) – width of a single phase, in degrees visual angle
period ("even", "odd", "either", "ignore" (default)) – ensure whether the grating has “even” number of phases, “odd” number of phases, either or whether not to round the number of phases (“ignore”)
rotation (float, optional) – rotation (in degrees), counterclockwise, by default 0.0 (horizontal)
phase_shift (float) – phase shift of grating in degrees, by default 0.0
intensities (Sequence[float, float]) – min and max intensity of sine-wave, by default (0.0, 1.0).
origin ("corner", "mean", or "center" (default)) – if “corner”: set origin to upper left corner if “mean”: set origin to hypothetical image center if “center”: set origin to real center (closest existing value to mean)
distance_metric (str or None) – if “horizontal”, use distance from origin in x-direction, if “vertical”, use distance from origin in x-direction; if “oblique”, use combined and rotated distance from origin in x-y; if “radial”, use radial distance from origin, if “angular”, use angular distance from origin, if “rectilinear”, use rectilinear/cityblock/Manhattan distance from origin
round_phase_width (bool) – if True, round width of bars given resolution, by default False.
- Returns:
dict with the stimulus (key: “img”), mask with integer index for each bar (key: “grating_mask”), and additional keys containing stimulus parameters
- Return type:
- square(visual_size=None, ppd=None, shape=None, frequency=None, n_phases=None, phase_width=None, period='ignore', rotation=0.0, phase_shift=0.0, intensities=(0.0, 1.0), origin='center', distance_metric=None, round_phase_width=False)[source]#
Draw a square-wave grating given a certain distance_metric
- Parameters:
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
frequency (Number, or None (default)) – spatial frequency of grating, in cycles per degree visual angle
n_phases (int, or None (default)) – number of phases in the grating
phase_width (Number, or None (default)) – width of a single phase, in degrees visual angle
period ("even", "odd", "either", "ignore" (default)) – ensure whether the grating has “even” number of phases, “odd” number of phases, either or whether not to round the number of phases (“ignore”)
rotation (float, optional) – rotation (in degrees), counterclockwise, by default 0.0 (horizontal)
phase_shift (float) – phase shift of grating in degrees, by default 0.0
intensities (Sequence[float, float]) – min and max intensity of sine-wave, by default (0.0, 1.0).
origin ("corner", "mean", or "center" (default)) – if “corner”: set origin to upper left corner if “mean”: set origin to hypothetical image center if “center”: set origin to real center (closest existing value to mean)
distance_metric (str or None) – if “horizontal”, use distance from origin in x-direction, if “vertical”, use distance from origin in x-direction; if “oblique”, use combined and rotated distance from origin in x-y; if “radial”, use radial distance from origin, if “angular”, use angular distance from origin, if “rectilinear”, use rectilinear/cityblock/Manhattan distance from origin
round_phase_width (bool) – if True, round width of bars given resolution, by default False
- Returns:
dict with the stimulus (key: “img”), mask with integer index for each bar (key: “grating_mask”), and additional keys containing stimulus parameters
- Return type:
- staircase(visual_size=None, ppd=None, shape=None, frequency=None, n_phases=None, phase_width=None, period='ignore', rotation=0.0, phase_shift=0.0, origin='center', distance_metric=None, round_phase_width=False, intensities=(0.0, 1.0))[source]#
Draw a luminance staircase
- Parameters:
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
frequency (Number, or None (default)) – spatial frequency of grating, in cycles per degree visual angle
n_phases (int, or None (default)) – number of phases in the grating
phase_width (Number, or None (default)) – width of a single phase, in degrees visual angle
period ("even", "odd", "either", "ignore" (default)) – ensure whether the grating has “even” number of phases, “odd” number of phases, either or whether not to round the number of phases (“ignore”)
rotation (float, optional) – rotation (in degrees), counterclockwise, by default 0.0 (horizontal)
phase_shift (float) – phase shift of grating in degrees, by default 0.o
origin ("corner", "mean", or "center" (default)) – if “corner”: set origin to upper left corner if “mean”: set origin to hypothetical image center if “center”: set origin to real center (closest existing value to mean)
distance_metric (str or None) – if “horizontal”, use distance from origin in x-direction, if “vertical”, use distance from origin in x-direction; if “oblique”, use combined and rotated distance from origin in x-y; if “radial”, use radial distance from origin, if “angular”, use angular distance from origin, if “rectilinear”, use rectilinear/cityblock/Manhattan distance from origin
round_phase_width (bool) – if True, round width of bars given resolution, by default False
intensities (Sequence[float, ...]) – if len(intensities)==2, intensity range of staircase (default 0.0, 1.0); if len(intensities)>2, intensity value for each phase. Can specify as many intensities as n_phases. If fewer intensities are passed than n_phases, cycles through intensities.
- Returns:
dict with the stimulus (key: “img”), mask with integer index for each phase (key: “grating_mask”), and additional keys containing stimulus parameters
- Return type:
- bessel(visual_size=None, ppd=None, shape=None, frequency=None, order=0, intensities=(1.0, 0.0), origin='mean')[source]#
Draw a Bessel stimulus, i.e. draw circular rings following an nth order Bessel function of a given frequency.
- Parameters:
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
frequency (Number, or None (default)) – spatial frequency of circular grating, in cycles per degree
order (int) – n-th order Bessel function
intensities ((float, float)) – intensity values of rings, first value indicating center intensity
origin ("corner", "mean" or "center") – if “corner”: set origin to upper left corner if “mean”: set origin to hypothetical image center (default) if “center”: set origin to real center (closest existing value to mean)
- Returns:
dict with the stimulus (key: “img”), empty mask (key: “ring_mask”), and additional keys containing stimulus parameters
- Return type: