retinotopic_mapping.StimulusRoutines

This module define a base class Stim for visual stimulation. Each subclass of Stim defines a particular type of visual stimulus, i.e. UniformContrast or SparseNoise. When initiated, these subclasses take various parameter inputs to generate stimulus arrays and metadata dictionary which can be passed to the DisplayStimulus.DisplaySequence for displaying. Each subclass will have a method called generate_movie() or generate_movie_by_index() or both. Only when these methods are called, will heavy lifting calculation take place.

Stim

class retinotopic_mapping.StimulusRoutines.Stim(monitor, indicator, background=0.0, coordinate='degree', pregap_dur=2.0, postgap_dur=3.0)

generic class for visual stimulation. parent class for individual stimulus routines.

Parameters:
monitor : monitor object

the monitor used to display stimulus in the experiment

indicator : indicator object

the indicator used during stimulus

background : float, optional

background color of the monitor screen when stimulus is not being presented, takes values in [-1,1] and defaults to 0. (grey)

coordinate : str {‘degree’, ‘linear’}, optional

determines the representation of pixel coordinates on monitor, defaults to ‘degree’

pregap_dur : float, optional

duration of gap period before stimulus, measured in seconds, defaults to 2.

postgap_dur : float, optional

duration of gap period after stimulus, measured in seconds, defaults to 3.

Attributes:
postgap_frame_num
pregap_frame_num

Methods

generate_frames(self) place holder of function “generate_frames” for each specific stimulus
generate_movie(self) place holder of function ‘generate_movie’ for each specific stimulus
generate_movie_by_index(self) place holder of function generate_movie_by_index() for each specific stimulus
clear  
set_background  
set_coordinate  
set_indicator  
set_monitor  
set_postgap_dur  
set_pregap_dur  

UniformContrast

class retinotopic_mapping.StimulusRoutines.UniformContrast(monitor, indicator, duration, color=0.0, pregap_dur=2.0, postgap_dur=3.0, background=0.0, coordinate='degree')

Generate full field uniform luminance for recording spontaneous activity. Inherits from Stim.

The full field uniform luminance stimulus presents a fixed background color which is normally taken to be grey.

Parameters:
monitor : monitor object

contains display monitor information

indicator : indicator object

contains indicator information

coordinate : str from {‘degree’,’linear’}, optional

specifies coordinates, defaults to ‘degree’

background : float, optional

color of background. Takes values in [-1,1] where -1 is black and 1 is white

pregap_dur : float, optional

amount of time (in seconds) before the stimulus is presented, defaults to 2.

postgap_dur : float, optional

amount of time (in seconds) after the stimulus is presented, defaults to 3.

duration: float

number of seconds of the duration of the uniform luminance.

color : float, optional

the choice of color to display in the stimulus, defaults to 0. which is grey

Attributes:
postgap_frame_num
pregap_frame_num

Methods

generate_frames(self) generate a tuple of parameters with information for each frame.
generate_movie(self) generate movie for uniform contrast display frame by frame.
generate_movie_by_index(self) compute the stimulus movie to be displayed by index.
clear  
set_background  
set_coordinate  
set_indicator  
set_monitor  
set_postgap_dur  
set_pregap_dur  
generate_frames(self)

generate a tuple of parameters with information for each frame.

Information contained in each frame:
first element -
during display frames, value takes on 1 and value is 0 otherwise
second element - color of indicator
during display value is equal to 1 and during gaps value is equal to -1
generate_movie(self)

generate movie for uniform contrast display frame by frame.

Returns:
full_seq : nd array, uint8

3-d array of the stimulus to be displayed.

full_dict : dict

dictionary containing the information of the stimulus.

generate_movie_by_index(self)

compute the stimulus movie to be displayed by index.

FlashingCircle

class retinotopic_mapping.StimulusRoutines.FlashingCircle(monitor, indicator, coordinate='degree', center=(0.0, 60.0), radius=10.0, is_smooth_edge=False, smooth_width_ratio=0.2, smooth_func=<function blur_cos>, color=-1.0, flash_frame_num=3, pregap_dur=2.0, postgap_dur=3.0, background=0.0, midgap_dur=1.0, iteration=1)

Generate flashing circle stimulus.

Stimulus routine presents a circle centered at the position center with given radius.

Parameters:
monitor : monitor object

contains display monitor information

indicator : indicator object

contains indicator information

coordinate : str from {‘degree’,’linear’}, optional

specifies coordinates, defaults to ‘degree’

background : float, optional

color of background. Takes values in [-1,1] where -1 is black and 1 is white

pregap_dur : float, optional

amount of time (in seconds) before the stimulus is presented, defaults to 2.

postgap_dur : float, optional

amount of time (in seconds) after the stimulus is presented, defaults to 3.

center : 2-tuple, optional

center coordinate (altitude, azimuth) of the circle in degrees, defaults to (0.,60.).

radius : float, optional

radius of the circle, defaults to 10.

is_smooth_edge : bool

True, smooth circle edge with smooth_width_ratio and smooth_func False, do not smooth edge

smooth_width_ratio : float, should be smaller than 1.

the ratio between smooth band width and radius, circle edge is the middle of smooth band

smooth_func : function object
this function take to inputs

first, ndarray storing the distance from each pixel to smooth band center second, smooth band width

returns smoothed mask with same shape as input ndarray

color : float, optional

color of the circle, takes values in [-1,1], defaults to -1.

iteration : int, optional

total number of flashes, defaults to 1.

flash_frame : int, optional

number of frames that circle is displayed during each presentation of the stimulus, defaults to 3.

Attributes:
midgap_frame_num
postgap_frame_num
pregap_frame_num

Methods

generate_frames(self) function to generate all the frames needed for the stimulation.
generate_movie(self) generate movie frame by frame.
generate_movie_by_index(self) compute the stimulus movie to be displayed by index.
clear  
set_background  
set_center  
set_color  
set_coordinate  
set_flash_frame_num  
set_indicator  
set_monitor  
set_postgap_dur  
set_pregap_dur  
set_radius  
generate_frames(self)

function to generate all the frames needed for the stimulation.

Information contained in each frame:
first element :
during a gap, the value is equal to 0 and during display the value is equal to 1
second element :
corresponds to the color of indicator if indicator.is_sync is True, during stimulus the value is equal to 1., whereas during a gap the value isequal to -1.; if indicator.is_sync is False, indicator color will alternate between 1. and -1. at the frequency as indicator.freq
frames : list
list of information defining each frame.
generate_movie(self)

generate movie frame by frame.

generate_movie_by_index(self)

compute the stimulus movie to be displayed by index.

SparseNoise

class retinotopic_mapping.StimulusRoutines.SparseNoise(monitor, indicator, background=0.0, coordinate='degree', grid_space=(10.0, 10.0), probe_size=(10.0, 10.0), probe_orientation=0.0, probe_frame_num=6, subregion=None, sign='ON-OFF', iteration=1, pregap_dur=2.0, postgap_dur=3.0, is_include_edge=True)

generate sparse noise stimulus integrates flashing indicator for photodiode

This stimulus routine presents quasi-random noise in a specified region of the monitor. The background color can be customized but defaults to a grey value. Can specify the subregion of the monitor where the pixels will flash on and off (black and white respectively)

Parameters:
monitor : monitor object

contains display monitor information

indicator : indicator object

contains indicator information

coordinate : str from {‘degree’,’linear’}, optional

specifies coordinates, defaults to ‘degree’

background : float, optional

color of background. Takes values in [-1,1] where -1 is black and 1 is white

pregap_dur : float, optional

amount of time (in seconds) before the stimulus is presented, defaults to 2.

postgap_dur : float, optional

amount of time (in seconds) after the stimulus is presented, defaults to 3.

grid_space : 2-tuple of floats, optional

first coordinate is altitude, second coordinate is azimuth

probe_size : 2-tuple of floats, optional

size of flicker probes. First coordinate defines the width, and second coordinate defines the height

probe_orientation : float, optional

orientation of flicker probes

probe_frame_num : int, optional

number of frames for each square presentation

subregion : list or tuple

the region on the monitor that will display the sparse noise, list or tuple, [min_alt, max_alt, min_azi, max_azi]

sign : {‘ON-OFF’, ‘ON’, ‘OFF’}, optional

determines which pixels appear in the subregion, defaults to ‘ON-Off’ so that both on and off pixels appear. If ‘ON selected only on pixels (white) are displayed in the noise subregion while if `’OFF’ is selected only off (black) pixels are displayed in the noise

iteration : int, optional

number of times to present stimulus, defaults to 1

is_include_edge : bool, default True,

if True, the displayed probes will cover the edge case and ensure that the entire subregion is covered. If False, the displayed probes will exclude edge case and ensure that all the centers of displayed probes are within the subregion.

Attributes:
postgap_frame_num
pregap_frame_num

Methods

generate_frames(self) function to generate all the frames needed for SparseNoise stimulus
generate_movie(self) generate movie for display frame by frame
generate_movie_by_index(self) compute the stimulus movie to be displayed by index.
clear  
set_background  
set_coordinate  
set_indicator  
set_monitor  
set_postgap_dur  
set_pregap_dur  
generate_frames(self)

function to generate all the frames needed for SparseNoise stimulus

returns a list of information of all frames as a list of tuples

Information contained in each frame:
first element - int
when stimulus is displayed value is equal to 1, otherwise equal to 0,
second element - tuple,
retinotopic location of the center of current square,[alt, azi]
third element -
polarity of current square, 1 -> bright, -1-> dark
forth element - color of indicator
if synchronized : value equal to 0 when stimulus is not
begin displayed, and 1 for onset frame of stimulus for each square, -1 for the rest.
if non-synchronized: values alternate between -1 and 1
at defined frequency

for gap frames the second and third elements should be ‘None’

generate_movie(self)

generate movie for display frame by frame

generate_movie_by_index(self)

compute the stimulus movie to be displayed by index.

LocallySparseNoise

class retinotopic_mapping.StimulusRoutines.LocallySparseNoise(monitor, indicator, min_distance=20.0, background=0.0, coordinate='degree', grid_space=(10.0, 10.0), probe_size=(10.0, 10.0), probe_orientation=0.0, probe_frame_num=6, subregion=None, sign='ON-OFF', iteration=1, repeat=1, pregap_dur=2.0, postgap_dur=3.0, is_include_edge=True)

generate locally sparse noise stimulus integrates flashing indicator for photodiode

This stimulus routine presents quasi-random noise in a specified region of the monitor. The background color can be customized but defaults to a grey value. Can specify the subregion of the monitor where the pixels will flash on and off (black and white respectively)

Different from SparseNoise stimulus which presents only one probe at a time, the LocallySparseNoise presents multiple probes simultaneously to speed up the sampling frequency. The sparsity of probes is defined by minimum distance in visual degree: in any given frame, the centers of any pair of two probes will have distance larger than minimum distance in visual degrees. The method generate locally sparse noise here insures, for each iteration, all the locations in the subregion will be sampled once and only once.

Parameters:
monitor : monitor object

contains display monitor information

indicator : indicator object

contains indicator information

coordinate : str from {‘degree’,’linear’}, optional

specifies coordinates, defaults to ‘degree’

background : float, optional

color of background. Takes values in [-1,1] where -1 is black and 1 is white

pregap_dur : float, optional

amount of time (in seconds) before the stimulus is presented, defaults to 2.

postgap_dur : float, optional

amount of time (in seconds) after the stimulus is presented, defaults to 3.

min_distance : float, default 20.

the minimum distance in visual degree for any pair of probe centers in a given frame

grid_space : 2-tuple of floats, optional

first coordinate is altitude, second coordinate is azimuth

probe_size : 2-tuple of floats, optional

size of flicker probes. First coordinate defines the width, and second coordinate defines the height

probe_orientation : float, optional

orientation of flicker probes

probe_frame_num : int, optional

number of frames for each square presentation

subregion : list or tuple

the region on the monitor that will display the sparse noise, list or tuple, [min_alt, max_alt, min_azi, max_azi]

sign : {‘ON-OFF’, ‘ON’, ‘OFF’}, optional

determines which pixels appear in the subregion, defaults to ‘ON-Off’ so that both on and off pixels appear. If ‘ON selected only on pixels (white) are displayed in the noise subregion while if `’OFF’ is selected only off (black) pixels are displayed in the noise

iteration : int, optional

number of times to present stimulus with random order, the total number a paticular probe will be displayded will be iteration * repeat, defaults to 1

repeat : int, optional

number of repeat of whole sequence, the total number a paticular probe will be displayded will be iteration * repeat, defaults to 1

is_include_edge : bool, default True,

if True, the displayed probes will cover the edge case and ensure that the entire subregion is covered. If False, the displayed probes will exclude edge case and ensure that all the centers of displayed probes are within the subregion.

Attributes:
postgap_frame_num
pregap_frame_num

Methods

generate_frames(self) place holder of function “generate_frames” for each specific stimulus
generate_movie(self) place holder of function ‘generate_movie’ for each specific stimulus
clear  
generate_movie_by_index  
set_background  
set_coordinate  
set_indicator  
set_monitor  
set_postgap_dur  
set_pregap_dur  
generate_frames(self)

place holder of function “generate_frames” for each specific stimulus

generate_movie(self)

place holder of function ‘generate_movie’ for each specific stimulus

generate_movie_by_index(self)

place holder of function generate_movie_by_index() for each specific stimulus

DriftingGratingCircle

class retinotopic_mapping.StimulusRoutines.DriftingGratingCircle(monitor, indicator, background=0.0, coordinate='degree', center=(0.0, 60.0), sf_list=(0.08, ), tf_list=(4.0, ), dire_list=(0.0, ), con_list=(0.5, ), radius_list=(10.0, ), block_dur=2.0, midgap_dur=0.5, iteration=1, pregap_dur=2.0, postgap_dur=3.0, is_smooth_edge=False, smooth_width_ratio=0.2, smooth_func=<function blur_cos>, is_blank_block=True)

Generate drifting grating circle stimulus

Stimulus routine presents drifting grating stimulus inside of a circle centered at center. The drifting gratings are determined by spatial and temporal frequencies, directionality, contrast, and radius. The routine can generate several different gratings within one presentation by specifying multiple values of the parameters which characterize the stimulus.

Parameters:
monitor : monitor object

contains display monitor information

indicator : indicator object

contains indicator information

coordinate : str from {‘degree’,’linear’}, optional

specifies coordinates, defaults to ‘degree’

background : float, optional

color of background. Takes values in [-1,1] where -1 is black and 1 is white

pregap_dur : float, optional

amount of time (in seconds) before the stimulus is presented, defaults to 2.

postgap_dur : float, optional

amount of time (in seconds) after the stimulus is presented, defaults to 3.

center : 2-tuple of floats, optional

coordintes for center of the stimulus (altitude, azimuth)

sf_list : n-tuple, optional

list of spatial frequencies in cycles/unit, defaults to (0.08)

tf_list : n-tuple, optional

list of temportal frequencies in Hz, defaults to (4.)

dire_list : n-tuple, optional

list of directions in degrees, defaults to (0.)

con_list : n-tuple, optional

list of contrasts taking values in [0.,1.], defaults to (0.5)

radius_list : n-tuple

list of radii of circles, unit defined by self.coordinate, defaults to (10.)

block_dur : float, optional

duration of each condition in seconds, defaults to 2.

midgap_dur : float, optional

duration of gap between conditions, defaults to 0.5

iteration : int, optional

number of times the stimulus is displayed, defaults to 1

is_smooth_edge : bool

True, smooth circle edge with smooth_width_ratio and smooth_func False, do not smooth edge

smooth_width_ratio : float, should be smaller than 1.

the ratio between smooth band width and radius, circle edge is the middle of smooth band

smooth_func : function object

this function take two inputs: 1) ndarray storing the distance from each pixel to smooth band center; 2) smooth band width. returns smoothed mask with same shape as input ndarray

is_blank_block : bool

if True, one blank block (full screen background with the same duration of other blocks) will be displayed for each iteration. The frames of this condition will be: (1, 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0), the meaning of these numbers can be found in self.frame_config

Attributes:
block_frame_num
midgap_frame_num
postgap_frame_num
pregap_frame_num

Methods

generate_frames(self) function to generate all the frames needed for DriftingGratingCircle returns a list of information of all frames as a list of tuples
generate_movie(self) Generate movie frame by frame
generate_movie_by_index(self) compute the stimulus movie to be displayed by index.
clear  
set_background  
set_coordinate  
set_indicator  
set_monitor  
set_postgap_dur  
set_pregap_dur  
generate_frames(self)

function to generate all the frames needed for DriftingGratingCircle returns a list of information of all frames as a list of tuples

Information contained in each frame:
first element -
value equal to 1 during stimulus and 0 otherwise
second element -
on first frame in a cycle value takes on 1, and otherwise is equal to 0.
third element -
spatial frequency
forth element -
temporal frequency
fifth element -
direction, [0, 2*pi)
sixth element -
contrast, [-1., 1.]
seventh element -
size, float (radius of the circle in visual degree)
eighth element -
phase, [0, 2*pi)
ninth element -
indicator color [-1, 1]. Value is equal to 1 on the first frame of each cycle, -1 during gaps and otherwise 0.

during gap frames the second through the eighth elements should be ‘None’.

generate_movie(self)

Generate movie frame by frame

generate_movie_by_index(self)

compute the stimulus movie to be displayed by index.

StaticGratingCircle

class retinotopic_mapping.StimulusRoutines.StaticGratingCircle(monitor, indicator, background=0.0, coordinate='degree', center=(0.0, 60.0), sf_list=(0.08, ), ori_list=(0.0, 90.0), con_list=(0.5, ), radius_list=(10.0, ), phase_list=(0.0, 90.0, 180.0, 270.0), display_dur=0.25, midgap_dur=0.0, iteration=1, pregap_dur=2.0, postgap_dur=3.0, is_smooth_edge=False, smooth_width_ratio=0.2, smooth_func=<function blur_cos>, is_blank_block=True)

Generate static grating circle stimulus

Stimulus routine presents flashing static grating stimulus inside of a circle centered at center. The static gratings are determined by spatial frequencies, orientation, contrast, radius and phase. The routine can generate several different gratings within one presentation by specifying multiple values of the parameters which characterize the stimulus.

Parameters:
monitor : monitor object

contains display monitor information

indicator : indicator object

contains indicator information

coordinate : str from {‘degree’,’linear’}, optional

specifies coordinates, defaults to ‘degree’

background : float, optional

color of background. Takes values in [-1,1] where -1 is black and 1 is white

pregap_dur : float, optional

amount of time (in seconds) before the stimulus is presented, defaults to 2.

postgap_dur : float, optional

amount of time (in seconds) after the stimulus is presented, defaults to 3.

center : 2-tuple of floats, optional

coordintes for center of the stimulus (altitude, azimuth)

sf_list : n-tuple, optional

list of spatial frequencies in cycles/unit, defaults to (0.08)

ori_list : n-tuple, optional

list of directions in degrees, defaults to (0., 90.)

con_list : n-tuple, optional

list of contrasts taking values in [0.,1.], defaults to (0.5)

radius_list : n-tuple, optional

list of radii of circles, unit defined by self.coordinate, defaults to (10.)

phase_list : n-tuple, optional

list of phase of gratings in degrees, default (0., 90., 180., 270.)

display_dur : float, optional

duration of each condition in seconds, defaults to 0.25

midgap_dur, float, optional

duration of gap between conditions, defaults to 0.

iteration, int, optional

number of times the stimulus is displayed, defaults to 1

is_smooth_edge : bool

True, smooth circle edge with smooth_width_ratio and smooth_func False, do not smooth edge

smooth_width_ratio : float, should be smaller than 1.

the ratio between smooth band width and radius, circle edge is the middle of smooth band

smooth_func : function object

this function take two inputs: 1) ndarray storing the distance from each pixel to smooth band center; 2) smooth band width. returns smoothed mask with same shape as input ndarray

is_blank_block : bool, optional

if True, a full screen background will be displayed as an additional grating. The frames of this condition will be: (1, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 or 0.0), the meaning of these numbers can be found in self.frame_config

Attributes:
display_frame_num
midgap_frame_num
postgap_frame_num
pregap_frame_num

Methods

generate_frames(self) place holder of function “generate_frames” for each specific stimulus
generate_movie(self) place holder of function ‘generate_movie’ for each specific stimulus
generate_movie_by_index(self) compute the stimulus movie to be displayed by index.
clear  
set_background  
set_coordinate  
set_indicator  
set_monitor  
set_postgap_dur  
set_pregap_dur  
generate_frames(self)

place holder of function “generate_frames” for each specific stimulus

generate_movie(self)

place holder of function ‘generate_movie’ for each specific stimulus

generate_movie_by_index(self)

compute the stimulus movie to be displayed by index.

StaticImages

class retinotopic_mapping.StimulusRoutines.StaticImages(monitor, indicator, background=0.0, coordinate='degree', img_center=(0.0, 60.0), deg_per_pixel=(0.1, 0.1), display_dur=0.25, midgap_dur=0.0, iteration=1, pregap_dur=2.0, postgap_dur=3.0, is_blank_block=True)

Generate static images stimulus

Stimulus routine presents a sequence of static images in a random order. Currently the input image stack should be a tif file. The size of the image should be exactly same as the pixel dimension of downsized monitor pixel resolution. For example if self.monitor.resolution = (1200,1920) and self.monitor.downsample_rate = 10. The shape of input image stack should be n x 120 x 192. Value of the input image stack should be within the range of [-1., 1.]. The values out of this range will be handled by psychopy.visual.ImageStim() function. The reason of this seemingly stringent requirement is that, for visual physiological experiments, the parameters of visual stimuli should be very well controlled. Any imaging cropping, zooming, transformating etc. will affect luminance, contrast, spatial resolution etc. and produce unexpected effects.

This stimulus routing provides a method to generate such image stacks. StaticImages.wrap_images() takes a list of image files transform them into a desired spherically corrected and luminance normalized image stack into visual degree coordinates and save it as a tif file.

Parameters:
monitor : monitor object

contains display monitor information

indicator : indicator object

contains indicator information

coordinate : str from {‘degree’,’linear’}, optional

specifies coordinates, defaults to ‘degree’

background : float, optional

color of background. Takes values in [-1,1] where -1 is black and 1 is white

pregap_dur : float, optional

amount of time (in seconds) before the stimulus is presented, defaults to 2.

postgap_dur : float, optional

amount of time (in seconds) after the stimulus is presented, defaults to 3.

img_center : 2-tuple of floats, optional

coordintes for center of the images (altitude, azimuth)

deg_per_pixel: float, or list/tuple of two floats

pixel size in visual degrees of unwrapped image (altitude, azimuth), if float, assume sizes in altitude and azimuth are the same

display_dur : float, optional

duration of each condition in seconds, defaults to 0.25

midgap_dur : float, optional

duration of gap between conditions, defaults to 0.

iteration : int, optional

number of times the stimulus is displayed, defaults to 1

is_blank_block : bool, optional

if True, a full screen background will be displayed as an additional image. index of this image will be -1.

Attributes:
display_frame_num
midgap_frame_num
postgap_frame_num
pregap_frame_num

Methods

generate_frames(self) place holder of function “generate_frames” for each specific stimulus
generate_movie(self) place holder of function ‘generate_movie’ for each specific stimulus
generate_movie_by_index(self) compute the stimulus movie to be displayed by index.
set_imgs_from_hdf5(self, imgs_file_path) set 3d arrays from a hdf5 file for display.
wrap_images(self, work_dir) look for the ‘images_original.tif’ in the work_dir, load the images, warp and luminance correct images, save wrapping results in an HDF5 file with name “wrapped_images_for_display.hdf5” in the work_dir
clear  
set_background  
set_coordinate  
set_imgs_from_tif  
set_indicator  
set_monitor  
set_postgap_dur  
set_pregap_dur  
generate_frames(self)

place holder of function “generate_frames” for each specific stimulus

generate_movie(self)

place holder of function ‘generate_movie’ for each specific stimulus

generate_movie_by_index(self)

compute the stimulus movie to be displayed by index.

set_imgs_from_hdf5(self, imgs_file_path)

set 3d arrays from a hdf5 file for display. Ideally the hdf5 file should be the result from self.wrap_images() method. Only designed to work with wrapped images

Parameters:
imgs_file_path : str

system path ot the hdf5 file. It should have at least one dataset named ‘images_wrapped’ containing a 3d array of wrapped images to display

wrap_images(self, work_dir)

look for the ‘images_original.tif’ in the work_dir, load the images, warp and luminance correct images, save wrapping results in an HDF5 file with name “wrapped_images_for_display.hdf5” in the work_dir

StimulusSeparator

class retinotopic_mapping.StimulusRoutines.StimulusSeparator(monitor, indicator, coordinate='degree', background=0.0, indicator_on_frame_num=4, indicator_off_frame_num=4, cycle_num=10, pregap_dur=0.0, postgap_dur=0.0)

a quick flash of indicator to separate different visual stimuli when displayed in the same session

Parameters:
monitor : monitor object

contains display monitor information

indicator : indicator object

contains indicator information

coordinate : str from {‘degree’,’linear’}, optional

specifies coordinates, defaults to ‘degree’

background : float, optional

color of background. Takes values in [-1,1] where -1 is black and 1 is white

pregap_dur : float, optional

amount of time (in seconds) before the stimulus is presented, defaults to 2.

postgap_dur : float, optional

amount of time (in seconds) after the stimulus is presented, defaults to 3.

indicator_on_frame_num : int

number of frames the indicator is white, should be positive.

indicator_off_frame_num : int

number of frames the indicator is black, should be positive.

cycle_num : int

number of repeat of the indicator flash, should be positive.

Attributes:
postgap_frame_num
pregap_frame_num

Methods

generate_frames(self) place holder of function “generate_frames” for each specific stimulus
generate_movie(self) place holder of function ‘generate_movie’ for each specific stimulus
clear  
generate_movie_by_index  
set_background  
set_coordinate  
set_indicator  
set_monitor  
set_postgap_dur  
set_pregap_dur  
generate_frames(self)

place holder of function “generate_frames” for each specific stimulus

generate_movie(self)

place holder of function ‘generate_movie’ for each specific stimulus

generate_movie_by_index(self)

place holder of function generate_movie_by_index() for each specific stimulus

CombinedStimuli

class retinotopic_mapping.StimulusRoutines.CombinedStimuli(monitor, indicator, background=0.0, coordinate='degree', pregap_dur=2.0, postgap_dur=3.0)

the stimulus class that can combine different stimuli into one session.

example: >>> import retinotopic_mapping.StimulusRoutines as stim >>> from retinotopic_mapping.MonitorSetup import Monitor, Indicator >>> from retinotopic_mapping.DisplayStimulus import DisplaySequence >>> mon = Monitor(resolution=(1200, 1920), dis=15., mon_width_cm=52., mon_height_cm=32.) >>> ind = Indicator(mon) >>> uc = stim.UniformContrast(mon, ind, duration=10., color=-1.) >>> ss = stim.StimulusSeparator(mon, ind) >>> cs = stim.CombinedStimuli(mon, ind) >>> cs.set_stimuli([ss, uc, ss]) >>> ds = DisplaySequence(log_dir=’C:/data’) >>> ds.set_stim(cs) >>> ds.trigger_display()

Parameters:
monitor : monitor object

contains display monitor information

indicator : indicator object

contains indicator information

coordinate : str from {‘degree’,’linear’}, optional

specifies coordinates, defaults to ‘degree’

background : float, optional

color of background. Takes values in [-1,1] where -1 is black and 1 is white

pregap_dur : float, optional

amount of time (in seconds) before the stimulus is presented, defaults to 2.

postgap_dur : float, optional

amount of time (in seconds) after the stimulus is presented, defaults to 3.

Attributes:
postgap_frame_num
pregap_frame_num

Methods

generate_frames(self) place holder of function “generate_frames” for each specific stimulus
generate_movie(self) place holder of function ‘generate_movie’ for each specific stimulus
set_stimuli(self, stimuli[, static_images_path])
Parameters:
clear  
generate_movie_by_index  
set_background  
set_coordinate  
set_indicator  
set_monitor  
set_postgap_dur  
set_pregap_dur  
generate_movie_by_index(self)

place holder of function generate_movie_by_index() for each specific stimulus

set_stimuli(self, stimuli, static_images_path=None)
Parameters:
stimuli : list of above stimulus object
static_images_path : str

system path to the hdf5 file storing the wrapped images for display. If there is StaticImages stimulus in the stimuli list, it will try to load images and display

KSstim

class retinotopic_mapping.StimulusRoutines.KSstim(monitor, indicator, background=0.0, coordinate='degree', square_size=25.0, square_center=(0, 0), flicker_frame=10, sweep_width=20.0, step_width=0.15, direction='B2U', sweep_frame=1, iteration=1, pregap_dur=2.0, postgap_dur=3.0)

generate Kalatsky & Stryker stimulus

Kalatsky & Stryker (KS) stimulus routine presents checkerboard gratings that drift against a fixed background color.

Parameters:
monitor : monitor object

object storing experimental monitor setup information

indicator : indicator object

object storing photodiode indicator information

background : float, optional

background color of stimulus, takes values in [-1,1]. defaults to 0.

coordinate : str, optional

coordinate representation, either ‘degree’ or ‘linear’, defaults to ‘degree’

square_size : float, optional

size of flickering square, defaults to 25.

square_center: tuple, optional

coordinate of center point, defaults to (0,0)

flicker_frame : int, optional

number of frames in one flicker, defaults to 10

sweep_width : float, optional

width of sweeps measured in units cm or degs if coordinate value is ‘linear’ or ‘degree’ respectively. defaults to 20

step_width : float, optional

width of steps measured in units cm or degs if coordinate value is ‘linear’ or ‘degree’ respectively. defaults to 0.15

direction : {‘B2U’,’U2B’,’L2R’,’R2L’}, optional

the direction of sweep movement, defaults to ‘B2U’. ‘B2U’ means stim is presented from the bottom to the top of the screen, whereas ‘U2B’ is from the top to the bottom. ‘L2R’ is left to right and ‘R2L’ is right to left

sweep_frame : int, optional

roughly determines speed of the drifting grating, defaults to 1

iteration : int, optional

number of times that the stimulus will be repeated, defaults to 1

pregap_dur : float, optional

number of seconds before stimulus is presented, defaults to 2

postgap_dur : float, optional

number of seconds after stimulus is presented, defaults to 2

Attributes:
postgap_frame_num
pregap_frame_num

Methods

generate_frames(self) function to generate all the frames needed for KS stimulation returnins a list of information of all frames as a list of tuples
generate_movie(self) Function to Generate Kalatsky & Stryker visual stimulus frame by frame
generate_movie_by_index(self) place holder of function generate_movie_by_index() for each specific stimulus
generate_squares(self) generate checker board squares
generate_sweeps(self) generate full screen sweep sequence
plot_squares(self) plot checkerboard squares
clear  
set_background  
set_coordinate  
set_direction  
set_indicator  
set_monitor  
set_postgap_dur  
set_pregap_dur  
set_sweep_sigma  
set_sweep_width  
generate_frames(self)

function to generate all the frames needed for KS stimulation returnins a list of information of all frames as a list of tuples

Information contained in each frame:
first element -
during stimulus value is equal to 1 and 0 otherwise
second element -
square polarity, 1->not reversed; -1->reversed
third element:
sweeps, index in sweep table
forth element -
color of indicator
synchronized: gap->-1, sweep on -> 1 non-synchronized: alternating between -1 and 1 at defined frequency

for gap frames the second and third elements should be ‘None’

generate_movie(self)

Function to Generate Kalatsky & Stryker visual stimulus frame by frame

generate_movie_by_index(self)

place holder of function generate_movie_by_index() for each specific stimulus

generate_squares(self)

generate checker board squares

generate_sweeps(self)

generate full screen sweep sequence

plot_squares(self)

plot checkerboard squares

KSstimAllDir

class retinotopic_mapping.StimulusRoutines.KSstimAllDir(monitor, indicator, coordinate='degree', background=0.0, square_size=25, square_center=(0, 0), flicker_frame=6, sweep_width=20.0, step_width=0.15, sweep_frame=1, iteration=1, pregap_dur=2.0, postgap_dur=3.0)

generate Kalatsky & Stryker stimulation in all four direction contiuously

Generalizes the KS stimulus routine so that the drifting gratings can go in all four directions

Parameters:
monitor : monitor object

contains display monitor information

indicator : indicator object

contains indicator information

coordinate : str from {‘degree’,’linear’}, optional

specifies coordinates, defaults to ‘degree’

background : float, optional

color of background. Takes values in [-1,1] where -1 is black and 1 is white

square_size : int, optional

size of flickering square, defaults to 25.

square_center : tuple, optional

coordinate of center point of the square, defaults to (0,0)

flicker_frame : int, optional

number of frames per flicker while stimulus is being presented, defaults to 6

sweep_width : float, optional

width of sweeps. defaults to 20.

step_width : float, optional

width of steps. defaults to 0.15.

sweep_frame : int, optional

roughly determines speed of the drifting grating, defaults to 1

iteration : int, optional

number of times stimulus will be presented, defaults to 1

pregap_dur : float, optional

number of seconds before stimulus is presented, defaults to 2.

postgap_dur : float, optional

number of seconds after stimulus is presented, defaults to 3.

Methods

generate_movie(self) Generate stimulus movie frame by frame
generate_movie(self)

Generate stimulus movie frame by frame