GratingStim

visual GratingStim

Grating Stimulus.

Constructor

new GratingStim(options)

Source:
Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
name String

the name used when logging messages from this stimulus

win Window

the associated Window

tex String | HTMLImageElement <optional>
"sin"

the name of the predefined grating texture or image resource or the HTMLImageElement corresponding to the texture

mask String | HTMLImageElement <optional>

the name of the mask resource or HTMLImageElement corresponding to the mask

units String <optional>
"norm"

the units of the stimulus (e.g. for size, position, vertices)

sf number <optional>
1.0

spatial frequency of the function used in grating stimulus

phase number <optional>
0.0

phase of the function used in grating stimulus, multiples of period of that function

pos Array.<number> <optional>
[0, 0]

the position of the center of the stimulus

ori number <optional>
0.0

the orientation (in degrees)

size number <optional>

the size of the rendered image (DEFAULT_STIM_SIZE_PX will be used if size is not specified)

color Color <optional>
"white"

Foreground color of the stimulus. Can be String like "red" or "#ff0000" or Number like 0xff0000.

opacity number <optional>
1.0

Set the opacity of the stimulus. Determines how visible the stimulus is relative to background.

contrast number <optional>
1.0

Set the contrast of the stimulus, i.e. scales how far the stimulus deviates from the middle grey. Ranges [-1, 1].

depth number <optional>
0

the depth (i.e. the z order)

interpolate boolean <optional>
false

Whether to interpolate (linearly) the texture in the stimulus. Currently supports only image based gratings.

blendmode String <optional>
"avg"

blend mode of the stimulus, determines how the stimulus is blended with the background. Supported values: "avg", "add", "mul", "screen".

autoDraw boolean <optional>
false

whether or not the stimulus should be automatically drawn on every frame flip

autoLog boolean <optional>
false

whether or not to log

Extends

  • VisualStim

Methods

(protected) _estimateBoundingBox()

Source:

Estimate the bounding box.

(protected) _getDisplaySize() → {Array.<number>}

Source:

Get the size of the display image, which is either that of the GratingStim or that of the image it contains.

Returns:

the size of the displayed image

Type
Array.<number>

(protected) _getPixiMeshFromPredefinedShaders(shaderName, uniforms) → {Pixi.Mesh}

Source:

Generate PIXI.Mesh object based on provided shader function name and uniforms.

Parameters:
Name Type Description
shaderName String

name of the shader. Must be one of the SHADERS

uniforms Object

a set of uniforms to supply to the shader. Mixed together with default uniform values.

Returns:

Pixi.Mesh object that represents shader and later added to the scene.

Type
Pixi.Mesh

(protected) _updateIfNeeded()

Source:

Update the stimulus, if necessary.

setBlendmode(blendMode, logopt)

Source:

Set blend mode of the grating stimulus.

Parameters:
Name Type Attributes Default Description
blendMode String avg

blend mode, can be one of the following: ["avg", "add", "mul", "screen"].

log boolean <optional>
false

whether or not to log

setColor(colorVal, logopt)

Source:

Set foreground color value for the grating stimulus.

Parameters:
Name Type Attributes Default Description
colorVal Color white

color value, can be String like "red" or "#ff0000" or Number like 0xff0000.

log boolean <optional>
false

whether of not to log

setColorSpace(colorSpaceVal, logopt)

Source:

Set color space value for the grating stimulus.

Parameters:
Name Type Attributes Default Description
colorSpaceVal String RGB

color space value

log boolean <optional>
false

whether of not to log

setInterpolate(interpolate, logopt)

Source:

Whether to interpolate (linearly) the texture in the stimulus.

Parameters:
Name Type Attributes Default Description
interpolate boolean false

interpolate or not.

log boolean <optional>
false

whether or not to log

setMask(mask, logopt)

Source:

Setter for the mask attribute.

Parameters:
Name Type Attributes Default Description
mask HTMLImageElement | string

the name of the mask resource or HTMLImageElement corresponding to the mask

log boolean <optional>
false

whether of not to log

setOpacity(opacityopt, logopt)

Source:

Determines how visible the stimulus is relative to background.

Parameters:
Name Type Attributes Default Description
opacity number <optional>
1

opacity - The value should be a single float ranging 1.0 (opaque) to 0.0 (transparent).

log boolean <optional>
false

whether of not to log

setPhase(phase, logopt)

Source:

Set phase value for the function.

Parameters:
Name Type Attributes Default Description
phase number

phase value

log boolean <optional>
false

whether of not to log

setSF(sf, logopt)

Source:

Set spatial frequency value for the function.

Parameters:
Name Type Attributes Default Description
sf number

spatial frequency value

log boolean <optional>
false

whether or not to log

setTex(tex, logopt)

Source:

Setter for the tex attribute.

Parameters:
Name Type Attributes Default Description
tex HTMLImageElement | string

the name of built in shader function or name of the image resource or HTMLImageElement corresponding to the image

log boolean <optional>
false

whether of not to log