Since Psykinematix is a sophisticated tool, there are usually several ways to solve a given problem. Before jumping to the most obvious solution, try to think about alternative solutions. Here are a few tips to generate complex stimuli using various techniques:

Motion Stimuli
Spatial Aperture

Motion Stimuli

Motion can be created using several techniques (see the techniques demo in the Storage area of the Designer Panel):

  • Use of a static stimulus whose position changes over time

    Advantages: This is a very fast technique that does not require the recomputation of the stimulus for each presentation frame, the stimulus being computed once and then pasted into a different position for each frame.

    Caveats: This technique is only appropriate for very simple stimuli (like drifting grating), and generally requires the application of a spatial aperture to limit the stimulus presentation to a static window. Particular care with the size of the aperture and stimulus as well as the speed of the motion is necessary to prevent the stimulus from disappearing from the window aperture during the presentation. A consequence of this technique is that the motion is necessarily limited to short durations, but there is a work around that may work for you.

    Work around: Rather than using a single stimulus that moves behind the aperture window, a second stimulus can be used to replace the one that goes out of the aperture and their roles are then flipped over as illustrated on the figure below (the 2 sweeps are copies of the same moving stimulus designed so that their border is invisible when put side by side). This technique, we call the 2-pass sweeping technique, can produce motion of infinitely long duration with a minimum of computational requirements, which is particularly useful for creating adapting motion stimuli for example (see the 2-Pass Sweeping Technique motion demo in the Storage area of the Designer Panel).


  • The difficulty in the implementation of this technique resides in the proper specification of the time-varying expression for the position of each sweep: in particular the sweep position needs to be reset every time the sweep goes out of the aperture. Below is an example of such expression for each sweep:

    22*([TIME]*[speed]-floor([TIME]*[speed]))-11     for the horizontal position of sweep 1 to specify a center position that starts outside and on the left of the circular aperture (-11 deg), shifts to the right at a speed of 1 deg/s, and gets reset to its starting position after 22 seconds (22 deg being the diameter of the aperture and the size of each sweep stimulus).

    22*([TIME]*[speed]-floor([TIME]*[speed]))-11     for the horizontal position of sweep 2 to specify a position that starts centered on the circular aperture (0 deg), shifts to the right at a speed of 1 deg/s, and gets reset outside and on the left of the circular aperture (-11 deg) after 11 seconds:

  • Use of other time-varying parameters (for example spatial phase in drifting grating)

    Advantages: Very complex stimuli can be created this way, particularly when several parameters are simultaneously time-varying. Almost all stimuli parameters support time-varying expressions.

    Caveats: The stimulus may need to be recomputed for each frame at the display frame rate. This computation is performed before the actual presentation of the dynamic stimulus, and this may result in a significant delay before each presentation if the number of frames is too large or the stimulus is too complex.

    Work around: Psykinematix provides several ways to specify time-varying parameters. The most straightforward way is to use the [TIME] built-in variable in the mathematical expression of a time-varying parameter. However, the use of the [TIME] variable requires the stimulus to be generated for every video frame, that is at the display frame rate. This may not be necessary in your experimental design and there are other time-varying formats available to specify values that change at a specified temporal rate and that require much less computational requirements in terms of speed and memory footprint. For example:

    min : nbsamples : max (duration)    to indicate a uniform sampling in a range, each sample presented for a specified duration.

    Instead of using the phase expression 360*[TIME] to create a drifting grating at a speed of 1 cycle per second, one could use the format 0:4:270(0.250) to create an apparent motion by cycling through 4 spatial phases (0, 90, 180 and 270 deg), this cycle being repeated for the whole duration of the grating.

Note that the popular but dated technique of animated lookup tables (LUT) is not supported by Psykinematix because the OpenGL drivers for MacOS X do not implement it across the full range of graphics cards.

Spatial Aperture

A spatial aperture is a transparent window that lets you see only parts of visual stimuli being otherwise hidden by the most front stimuli. The effect is easily computed by multiplying a binary mask (set to 0 for the opaque parts, and 1 for the transparent parts) by the stimulus presented behind the window on a pixel basis. This effect is generally combined with the presentation of another stimulus outside the window (the "wallpaper") as illustrated below and formally described as:

seen result = mask x stimulus + (1 - mask) x wallpaper

result

mask

stimulus

1 - mask
wallpaper

Psykinematix offers several techniques to create a spatial aperture (see the techniques demo in the Storage area of the Designer Panel):

  • Use of Custom Stimuli only, typically in the form:

    stimulus = f(x,y,r,theta)
    mask = g(x,y,r,theta)
    wallpaper = h(x,y,r,theta)
    z = mask*stimulus+(1-mask)*wallpaper


    Advantages: The aperture window and the stimuli are computed and combined simultaneously. This is the recommended technique for beginners.

    Caveats: This technique, however, cannot be used if the stimuli cannot be generated using mathematical expressions, as it is the case with Multimedia stimuli. Moreover, if the stimuli are dynamic (time-varying) then the aperture and the combination are recomputed for every frame that may lead to unneeded delay.

    Work around: If the wallpaper is already present as the display background, an aperture can still be created using the za output component and by specifying a 'Transparent' blending mode in the rendering options:

    stimulus = f(x,y,r,theta)
    mask = g(x,y,r,theta)
    z = stimulus
    za = mask


    With the 'Transparent' blending mode set, the aperture stored in the za component is used to blend together the wallpaper and the stimulus (stored in the z component) so the mask parts of the background are replaced with the z component. This operation is hardware-accelerated through the OpenGL engine (see below).

  • Use of Static Composing with the 'Multiply' operation

    Advantages: Computation of stimuli and aperture are done separately.

    Caveats: This technique is limited to achromatic stimuli and does not support Multimedia stimuli. This technique can still be quite time-consuming for dynamic stimuli even if the aperture is not recomputed for every frame.

  • Use of OpenGL blending techniques

    OpenGL provides hardware computation for blending operations, masking being only one of them. In addition of the RGB components, stimuli (represented as OpenGL textures) can specify an Alpha channel that characterizes the stimulus opacity (opposite of transparent), and therefore be used to create a see-through effect as describe above.

    Advantages: Using alpha masking, aperture can be applied to any kind of visual stimulus, and its computation is extremely fast using OpenGL blending. This is the recommended technique for advanced users.

    Caveats: OpenGL blending techniques should only be attempted by advanced users who have some expertise with OpenGL. To learn more about OpenGL, start with the OpenGL Programming Guide. To learn more about the use of OpenGL control in Psykinematix, see the Render section in "More Control".

Note that a mask does not have to be binary but may be any image where a level of transparency could be specified for each RGB component.