stytra.stimulation.stimuli package

Submodules

stytra.stimulation.stimuli.backgrounds module

stytra.stimulation.stimuli.backgrounds.noise_background(size, kernel_std_x=1, kernel_std_y=None)[source]
Parameters:
  • size
  • kernel_std_x – (Default value = 1)
  • kernel_std_y – (Default value = None)
stytra.stimulation.stimuli.backgrounds.existing_file_background(filepath)[source]

Returns a numpy array from an image stored at filepath

stytra.stimulation.stimuli.backgrounds.poisson_disk_background(size, distance, radius)[source]
A background with randomly spaced dots using the poisson disk
algorithm
Parameters:
  • size – image size
  • distance – approximate distance between the dots
  • radius – radius of the dots
Returns:

the generated background

Return type:

type

stytra.stimulation.stimuli.backgrounds.gratings(mm_px=1, spatial_period=10, orientation='horizontal', shape='square', ratio=0.5)[source]

Function for generating grids (assume usage of cv2.BORDER_WRAP for display)

Parameters:
  • mm_px – millimiters per pixel (Default value = 1)
  • spatial_period – spatial period (cycles/mm) (Default value = 10)
  • orientation – horizontal’ or ‘vertical’ (Default value = ‘horizontal’)
  • shape – square’, ‘sinusoidal’ (Default value = ‘square’)
  • ratio – ratio of white over dark (Default value = 0.5)
class stytra.stimulation.stimuli.backgrounds.Grid(r, *size)[source]

Bases: object

class for filling a rectangular prism of dimension >= 2 with poisson disc samples spaced at least r apart and k attempts per active sample override Grid.distance to change distance metric used and get different forms of ‘discs’

Adapted from code by Herman Tulleken (herman@luma.co.za)

clear()[source]

resets the grid active points and sample points

generate(point)[source]

generates new points in an annulus between self.r, 2*self.r

Parameters:point
poisson(seed, k=30)[source]

generates a set of poisson disc samples

Parameters:
  • seed
  • k – (Default value = 30)
make_points(k, point)[source]

uses generate to make up to k new points, stopping when it finds a good sample using self.check

Parameters:
  • k
  • point
check(point, new_point)[source]

checks the neighbors of the point and the new_point against the new_point returns True if none are closer than r

Parameters:
  • point
  • new_point
convert(point, rad, angs)[source]

converts the random point to rectangular coordinates from radial coordinates centered on the active point

Parameters:
  • point
  • rad
  • angs
cellify(point)[source]

returns the cell in which the point falls

Parameters:point
distance(tup1, tup2)[source]

returns squared distance between two points

Parameters:
  • tup1
  • tup2
cell_distance(tup1, tup2)[source]

returns true if the L1 distance is less than 2 for the two tuples

Parameters:
  • tup1
  • tup2
neighbors(cell)[source]

finds all occupied cells within a distance of the given point

Parameters:cell
update(point, index)[source]

updates the grid with the new point

Parameters:
  • point
  • index

stytra.stimulation.stimuli.closed_loop module

class stytra.stimulation.stimuli.closed_loop.Basic_CL_1D(*args, base_vel=10, swimming_threshold=-2, max_fish_vel=40, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.BackgroundStimulus, stytra.stimulation.stimuli.generic_stimuli.InterpolatedStimulus, stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus

Vigor-based closed loop stimulus.

The parameters can change in time if the df_param is supplied which specifies their values in time.

Parameters:
  • base_vel – the velocity of the background when the stimulus is not moving
  • shunting (bool) – if true, when the fish stops swimming its infulence on the background motion stops, immediately independent of lag
  • swimming_threshold (float) – the velocity at which the fish is considered to be performing a bout
  • fixed_vel (float) – if not None, fixed velocity for the stimulus when fish swims
get_fish_vel()[source]

Function that update estimated fish velocty. Change to add lag or shunting.

bout_started()[source]

Function called on bout start.

bout_occurring()[source]
bout_ended()[source]

Function called on bout end.

update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

calculate_final_vel()[source]
class stytra.stimulation.stimuli.closed_loop.CalibratingClosedLoop1D(target_avg_fish_vel=-15, calibrate_after=5, **kwargs)[source]

Bases: stytra.stimulation.stimuli.closed_loop.Basic_CL_1D

Vigor-based closed loop stimulus. Velocity is assumend to be calculated with the

The parameters can change in time if the df_param is supplied which specifies their values in time.

Parameters:
  • base_vel – the velocity of the background when the stimulus is not moving
  • swimming_threshold (float) – the velocity at which the fish is considered to be performing a bout
bout_started()[source]

Function called on bout start.

bout_occurring()[source]
bout_ended()[source]

Function called on bout end.

stop()[source]

Function called by the ProtocolRunner when a new stimulus is set.

class stytra.stimulation.stimuli.closed_loop.GainLagClosedLoop1D(gain=1, lag=0, shunted=False, fixed_vel=nan, gain_drop_start=nan, gain_drop_end=nan, **kwargs)[source]

Bases: stytra.stimulation.stimuli.closed_loop.Basic_CL_1D

get_fish_vel()[source]

Function that update estimated fish velocty. Change to add lag or shunting.

calculate_final_vel()[source]
class stytra.stimulation.stimuli.closed_loop.AcuteClosedLoop1D(conditions_list=None, **kwargs)[source]

Bases: stytra.stimulation.stimuli.closed_loop.GainLagClosedLoop1D

bout_started()[source]

Function called on bout start.

class stytra.stimulation.stimuli.closed_loop.PerpendicularMotion(*args, centre_relative=False, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.BackgroundStimulus, stytra.stimulation.stimuli.generic_stimuli.InterpolatedStimulus

A stimulus which is always kept perpendicular to the fish

update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

class stytra.stimulation.stimuli.closed_loop.FishTrackingStimulus(*args, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.PositionStimulus

update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

stytra.stimulation.stimuli.conditional module

class stytra.stimulation.stimuli.conditional.PauseOutsideStimulus(stim, reset_phase=0, **kwargs)[source]

Bases: stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus

dynamic_parameter_names
get_dynamic_state()[source]
initialise_external(experiment)[source]

Make a reference to the Experiment class inside the Stimulus. This is required to access from inside the Stimulus class to the Calibrator, the Pyboard, the asset directories with movies or the motor estimators for virtual reality. Also, the necessary preprocessing operations are handled here, such as loading images or videos.

Parameters:experiment – the experiment object to which link the stimulus
Returns:None
Return type:type
get_state()[source]

Returns a dictionary with stimulus features for logging. Ignores the properties which are private (start with _)

Returns:dictionary with all the current parameters of the stimulus
Return type:dict
start()[source]

Function called by the ProtocolRunner when a new stimulus is set.

check_condition()[source]
update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

paint(p, w, h)[source]
class stytra.stimulation.stimuli.conditional.ConditionalWrapper(stim_on, stim_off, reset_phase=False, reset_phase_shift=0, reset_to_mod_phase=None, **kwargs)[source]

Bases: stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus

A wrapper for stimuli which switches between two stimuli dependending on conditions: an on condition defined in the check_condition_on method and an off condition defined check_condition_on

Parameters:
  • stim_on (Stimulus) –
  • stim_off (Stimulus) –
  • reset_phase (bool) – whether to reset the phase of an InterpolatedStimulus if it goes from on to off
  • reset_phase_shift (int) – when the stim_on reappears and reset_phase is true, we can set this to 0, which resets the stim_on to the state at the beginning of the current phase, 1 to go to the next phase or -1 to go to the previous phase.
  • reset_to_mod_phase (tuple (int, int), optional, default None) – if the stim_on consists of paired phases (e.g. motion on, motion off), it can one can reset to the begging of the bigger phase. If the stimulation pattern is e.g. [no_motion, motion_left, motion_right] to always get to no_motion on reenter reset_to_mod_phase would be set to (0, 3) This paremeter can be combined with reset_phase_shift, but in usual cases it has to be set to 0
dynamic_parameter_names
get_dynamic_state()[source]
initialise_external(experiment)[source]

Make a reference to the Experiment class inside the Stimulus. This is required to access from inside the Stimulus class to the Calibrator, the Pyboard, the asset directories with movies or the motor estimators for virtual reality. Also, the necessary preprocessing operations are handled here, such as loading images or videos.

Parameters:experiment – the experiment object to which link the stimulus
Returns:None
Return type:type
get_state()[source]

Returns a dictionary with stimulus features for logging. Ignores the properties which are private (start with _)

Returns:dictionary with all the current parameters of the stimulus
Return type:dict
start()[source]

Function called by the ProtocolRunner when a new stimulus is set.

check_condition_on()[source]
check_condition_off()[source]
update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

paint(p, w, h)[source]
class stytra.stimulation.stimuli.conditional.SingleConditionalWrapper(stim_on, stim_off, reset_phase=False, reset_phase_shift=0, reset_to_mod_phase=None, **kwargs)[source]

Bases: stytra.stimulation.stimuli.conditional.ConditionalWrapper

chceck_condition_off()[source]
class stytra.stimulation.stimuli.conditional.CenteringWrapper(stimulus, *args, centering_stimulus=None, margin=400, **kwargs)[source]

Bases: stytra.stimulation.stimuli.conditional.SingleConditionalWrapper

check_condition_on()[source]
paint(p, w, h)[source]
class stytra.stimulation.stimuli.conditional.TwoRadiusCenteringWrapper(stimulus, *args, centering_stimulus=None, r_out=400, r_in=100, **kwargs)[source]

Bases: stytra.stimulation.stimuli.conditional.ConditionalWrapper

check_condition_on()[source]
check_condition_off()[source]
paint(p, w, h)[source]

stytra.stimulation.stimuli.external module

class stytra.stimulation.stimuli.external.PybPulseStimulus(burst_freq=100, pulse_amp=3.0, pulse_n=5, pulse_dur_ms=2, com_port='COM3', **kwargs)[source]

Bases: stytra.stimulation.stimuli.generic_stimuli.Stimulus

initialise_external(experiment)[source]
Parameters:experiment
start()[source]

stytra.stimulation.stimuli.generic_stimuli module

class stytra.stimulation.stimuli.generic_stimuli.Stimulus(duration=0.0)[source]

Bases: object

Abstract class for a Stimulus.

In stytra, a Stimulus is something that makes things happen at some point of an experiment. The Stimulus class is just a building block: successions of Stimuli are assembled in a meaningful order by Protocol. objects.

A Stimulus runs for a time defined by its duration. to do so, the ProtocolRunner compares at every time step the duration of the stimulus with the time elapsed from its beginning. Whenever the ProtocolRunner sets a new stimulus it calls its Stimulus.start() method. By defining this method in subclasses, we can trigger events at the beginning of the stimulus (e.g., activate a Pyboard, send a TTL pulse or similar). At every successive time, until the end of the Stimulus, its Stimulus.update() method is called. By defining this method in subclasses, we can trigger events throughout the length of the Stimulus time.

Note

Be aware that code in the Stimulus.start() and Stimulus.update() functions is executed within the Stimulus&main GUI process, therefore:

  1. Its temporal precision is limited to ? # TODO do some check here
  2. Slow functions would slow down the entire main process, especially if called at every time step.

Stimuli have parameters that are important to be logged in the final metadata and parameters that are not relevant. The get_state() method used to generate the log saves all attributes not starting with _.

Different stimuli categories are implemented subclassing this class, e.g.:

  • visual stimuli (children of PainterStimulus subclass);
Parameters:duration (float) – duration of the stimulus (s)
get_state()[source]

Returns a dictionary with stimulus features for logging. Ignores the properties which are private (start with _)

Returns:dictionary with all the current parameters of the stimulus
Return type:dict
update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

start()[source]

Function called by the ProtocolRunner when a new stimulus is set.

stop()[source]

Function called by the ProtocolRunner when a new stimulus is set.

initialise_external(experiment)[source]

Make a reference to the Experiment class inside the Stimulus. This is required to access from inside the Stimulus class to the Calibrator, the Pyboard, the asset directories with movies or the motor estimators for virtual reality. Also, the necessary preprocessing operations are handled here, such as loading images or videos.

Parameters:experiment – the experiment object to which link the stimulus
Returns:None
Return type:type
class stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus(*args, dynamic_parameters=None, **kwargs)[source]

Bases: stytra.stimulation.stimuli.generic_stimuli.Stimulus

Stimuli where parameters change during stimulation on a frame-by-frame base. It implements the recording changing parameters.

dynamic_parameter_names
get_dynamic_state()[source]
class stytra.stimulation.stimuli.generic_stimuli.InterpolatedStimulus(*args, df_param, **kwargs)[source]

Bases: stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus

Stimulus that interpolates its internal parameters with a data frame

Parameters:df_param (DataFrame) –

A Pandas DataFrame containing the values to be interpolated it has to contain a column named t for the defined time points, and additional columns for each parameter of the stimulus that is to be changed. A constant velocity of the parameter change can be specified, in that case the column name has to be prefixed with “vel_

Example: t | x ——- 0 | 1.0 4 | 7.8

update()[source]
class stytra.stimulation.stimuli.generic_stimuli.TriggerStimulus(**kwargs)[source]

Bases: stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus

A class that uses the Experiment trigger to trigger a sequence of stimuli.

start()[source]

Function called by the ProtocolRunner when a new stimulus is set.

update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

stytra.stimulation.stimuli.visual module

class stytra.stimulation.stimuli.visual.VisualStimulus(*args, clip_mask=None, **kwargs)[source]

Bases: stytra.stimulation.stimuli.generic_stimuli.Stimulus

Stimulus class to paint programmatically on a canvas. For this subclass of Stimulus, their core function (paint()) is not called by the ProtocolRunner, but directly from the StimulusDisplayWindow. Since a StimulusDisplayWindow is directly linked to a ProtocolRunner, at every time the paint() method that is called is the one from the correct current stimulus.

paint(p, w, h)[source]

Paint function. Called by the StimulusDisplayWindow update method.

Parameters:
  • p – QPainter object for drawing
  • w – width of the display window
  • h – height of the display window
clip(p, w, h)[source]

Clip image before painting

Parameters:
  • p – QPainter object used for painting
  • w – image width
  • h – image height
class stytra.stimulation.stimuli.visual.StimulusCombiner(stim_list)[source]

Bases: stytra.stimulation.stimuli.visual.VisualStimulus, stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus

start()[source]

Function called by the ProtocolRunner when a new stimulus is set.

stop()[source]

Function called by the ProtocolRunner when a new stimulus is set.

paint(p, w, h)[source]

Paint function. Called by the StimulusDisplayWindow update method.

Parameters:
  • p – QPainter object for drawing
  • w – width of the display window
  • h – height of the display window
update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

initialise_external(experiment)[source]

Make a reference to the Experiment class inside the Stimulus. This is required to access from inside the Stimulus class to the Calibrator, the Pyboard, the asset directories with movies or the motor estimators for virtual reality. Also, the necessary preprocessing operations are handled here, such as loading images or videos.

Parameters:experiment – the experiment object to which link the stimulus
Returns:None
Return type:type
dynamic_parameter_names
get_dynamic_state()[source]
class stytra.stimulation.stimuli.visual.FullFieldVisualStimulus(*args, color=(255, 0, 0), **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.VisualStimulus

Class for painting a full field flash of a specific color.

Parameters:color ((int, int, int) tuple) – color of the full field flash (int tuple)
paint(p, w, h)[source]

Paint function. Called by the StimulusDisplayWindow update method.

Parameters:
  • p – QPainter object for drawing
  • w – width of the display window
  • h – height of the display window
class stytra.stimulation.stimuli.visual.DynamicLuminanceStimulus(*args, color=(255, 0, 0), luminance=0.0, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.FullFieldVisualStimulus, stytra.stimulation.stimuli.generic_stimuli.InterpolatedStimulus, stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus

A luminance stimulus that has dynamically specified luminance.

Parameters:luminance (float) – a multiplier (0-1) from black to full luminance
update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

class stytra.stimulation.stimuli.visual.Pause(*args, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.FullFieldVisualStimulus

Class for painting full field black stimuli.

class stytra.stimulation.stimuli.visual.VideoStimulus(*args, video_path, framerate=None, duration=None, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.VisualStimulus, stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus

Displays videos using PIMS, at a specified framerate.

initialise_external(*args, **kwargs)[source]

Make a reference to the Experiment class inside the Stimulus. This is required to access from inside the Stimulus class to the Calibrator, the Pyboard, the asset directories with movies or the motor estimators for virtual reality. Also, the necessary preprocessing operations are handled here, such as loading images or videos.

Parameters:experiment – the experiment object to which link the stimulus
Returns:None
Return type:type
update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

paint(p, w, h)[source]

Paint function. Called by the StimulusDisplayWindow update method.

Parameters:
  • p – QPainter object for drawing
  • w – width of the display window
  • h – height of the display window
class stytra.stimulation.stimuli.visual.PositionStimulus(*args, centre_relative=False, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.VisualStimulus, stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus

Stimulus with a defined position and orientation to the fish.

class stytra.stimulation.stimuli.visual.BackgroundStimulus(*args, centre_relative=False, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.PositionStimulus

Stimulus with a tiling background

get_unit_dims(w, h)[source]
get_rot_transform(w, h)[source]
paint(p, w, h)[source]

Paint function. Called by the StimulusDisplayWindow update method.

Parameters:
  • p – QPainter object for drawing
  • w – width of the display window
  • h – height of the display window
draw_block(p, point, w, h)[source]

Has to be defined in each child of the class, defines what is to be painted per tile of the repeating stimulus

Parameters:
  • p
  • point
  • w
  • h
class stytra.stimulation.stimuli.visual.SeamlessImageStimulus(*args, background, background_name=None, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.BackgroundStimulus

Displays an image which should tile seamlessly.

The top of the image should match with the bottom and the left with the right, so there are no discontinuities). An even checkerboard works, but with some image editing any texture can be adjusted to be seamless.

initialise_external(experiment)[source]

Make a reference to the Experiment class inside the Stimulus. This is required to access from inside the Stimulus class to the Calibrator, the Pyboard, the asset directories with movies or the motor estimators for virtual reality. Also, the necessary preprocessing operations are handled here, such as loading images or videos.

Parameters:experiment – the experiment object to which link the stimulus
Returns:None
Return type:type
get_unit_dims(w, h)[source]
draw_block(p, point, w, h)[source]

Has to be defined in each child of the class, defines what is to be painted per tile of the repeating stimulus

Parameters:
  • p
  • point
  • w
  • h
class stytra.stimulation.stimuli.visual.GratingStimulus(*args, grating_angle=0, grating_period=10, wave_shape='square', grating_col_1=(255, 255, 255), grating_col_2=(0, 0, 0), center_relative=True, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.BackgroundStimulus

Displays a grating pattern with physical dimensions alternating two colors. Can be square or sinusoidal. For having moving grating stimulus, use subclass MovingGratingStimulus

Parameters:
  • grating_angle (float) – fixed angle for the stripes (in radiants)
  • grating_period (float) – spatial period of the gratings (in mm)
  • grating_col_1 ((int, int, int) tuple) – first color (default=(255, 255, 255))
  • grating_col_2 ((int, int, int) tuple) – first color (default=(0, 0, 0))
create_pattern()[source]
initialise_external(experiment)[source]

Make a reference to the Experiment class inside the Stimulus. This is required to access from inside the Stimulus class to the Calibrator, the Pyboard, the asset directories with movies or the motor estimators for virtual reality. Also, the necessary preprocessing operations are handled here, such as loading images or videos.

Parameters:experiment – the experiment object to which link the stimulus
Returns:None
Return type:type
get_unit_dims(w, h)[source]
draw_block(p, point, w, h)[source]

Has to be defined in each child of the class, defines what is to be painted per tile of the repeating stimulus

Parameters:
  • p
  • point
  • w
  • h
class stytra.stimulation.stimuli.visual.PaintGratingStimulus(*args, grating_angle=0, grating_period=10, grating_col_1=(255, 255, 255), grating_col_2=None, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.BackgroundStimulus

Class for moving a grating pattern.

get_unit_dims(w, h)[source]
draw_block(p, point, w, h)[source]

Function for drawing the gratings programmatically.

class stytra.stimulation.stimuli.visual.HalfFieldStimulus(*args, left=False, color=(255, 255, 255), center_dist=0, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.PositionStimulus

For phototaxis

paint(p, w, h)[source]

Paint function. Called by the StimulusDisplayWindow update method.

Parameters:
  • p – QPainter object for drawing
  • w – width of the display window
  • h – height of the display window
class stytra.stimulation.stimuli.visual.RadialSineStimulus(period=8, velocity=5, duration=1, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.VisualStimulus

Stimulus which makes the fish move to the center of the dish

update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

paint(p, w, h)[source]

Paint function. Called by the StimulusDisplayWindow update method.

Parameters:
  • p – QPainter object for drawing
  • w – width of the display window
  • h – height of the display window
class stytra.stimulation.stimuli.visual.FishOverlayStimulus(color=(255, 50, 0), **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.PositionStimulus

For testing freely-swimming closed loop

paint(p, w, h)[source]

Paint function. Called by the StimulusDisplayWindow update method.

Parameters:
  • p – QPainter object for drawing
  • w – width of the display window
  • h – height of the display window
class stytra.stimulation.stimuli.visual.MovingGratingStimulus(*args, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.PaintGratingStimulus, stytra.stimulation.stimuli.generic_stimuli.InterpolatedStimulus

stytra.stimulation.stimuli.visual.z_func_windmill(x, y, arms)[source]

Function for sinusoidal windmill of arbitrary number of arms symmetrical with respect to perpendicular axes (for even n)

class stytra.stimulation.stimuli.visual.WindmillStimulus(*args, color_1=(255, 255, 255), wave_shape='sinusoidal', color_2=(0, 0, 0), n_arms=8, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.BackgroundStimulus

Class for drawing a rotating windmill (radial wedges in alternating colors).

Parameters:
  • n_arms (int) – number of colored arms of the windmill
  • color ((int, int, int) tuple) – color for the non-black stripes (int tuple)
create_pattern(side_len=500)[source]
initialise_external(experiment)[source]

Make a reference to the Experiment class inside the Stimulus. This is required to access from inside the Stimulus class to the Calibrator, the Pyboard, the asset directories with movies or the motor estimators for virtual reality. Also, the necessary preprocessing operations are handled here, such as loading images or videos.

Parameters:experiment – the experiment object to which link the stimulus
Returns:None
Return type:type
draw_block(p, point, w, h)[source]

Has to be defined in each child of the class, defines what is to be painted per tile of the repeating stimulus

Parameters:
  • p
  • point
  • w
  • h
class stytra.stimulation.stimuli.visual.MovingWindmillStimulus(*args, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.WindmillStimulus, stytra.stimulation.stimuli.generic_stimuli.InterpolatedStimulus

class stytra.stimulation.stimuli.visual.HighResWindmillStimulus(*args, color=(255, 255, 255), n_arms=8, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.BackgroundStimulus

Class for drawing a rotating windmill with sharp edges. Instead of rotating an image, this class use a painter to draw triangles of the windmill at every timestep. Compared with the WindmillStimulus class, this windmill has better resolution because it avoids distortions and artifacts from image rotation. On the other side, it cannot be used for sinusoidal windmill and currently does not support a different background color, and takes slightly longer to draw the stimulus Ideally will be obsolete once the problems of the WindmillStimulus class are solved.

Parameters:
  • n_arms (int) – number of colored arms of the windmill
  • color ((int, int, int) tuple) – color for the non-black stripes (int tuple)
draw_block(p, point, w, h)[source]

Has to be defined in each child of the class, defines what is to be painted per tile of the repeating stimulus

Parameters:
  • p
  • point
  • w
  • h
class stytra.stimulation.stimuli.visual.HighResMovingWindmillStimulus(*args, **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.HighResWindmillStimulus, stytra.stimulation.stimuli.generic_stimuli.InterpolatedStimulus

class stytra.stimulation.stimuli.visual.CircleStimulus(*args, origin=(0.5, 0.5), radius=10, background_color=(0, 0, 0), circle_color=(255, 255, 255), **kwargs)[source]

Bases: stytra.stimulation.stimuli.visual.VisualStimulus, stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus

A filled circle stimulus, which in combination with interpolation can be used to make looming stimuli

Parameters:
  • origin (tuple(float, float)) – positions of the circle centre (in mm)
  • radius (float) – circle radius (in mm)
  • backgroud_color (tuple(int, int, int)) – RGB color of the background
  • circle_color (tuple(int, int, int)) – RGB color of the circle
paint(p, w, h)[source]

Paint function. Called by the StimulusDisplayWindow update method.

Parameters:
  • p – QPainter object for drawing
  • w – width of the display window
  • h – height of the display window

stytra.stimulation.stimuli.voltage_stimuli module

class stytra.stimulation.stimuli.voltage_stimuli.NIVoltageStimulus(*args, dev='Dev1', chan='ao0')[source]

Bases: stytra.stimulation.stimuli.generic_stimuli.Stimulus

class stytra.stimulation.stimuli.voltage_stimuli.SetVoltageStimulus(*args, voltage=0.0, **kwargs)[source]

Bases: stytra.stimulation.stimuli.voltage_stimuli.NIVoltageStimulus

start()[source]

Function called by the ProtocolRunner when a new stimulus is set.

class stytra.stimulation.stimuli.voltage_stimuli.InterpolatedVoltageStimulus(*args, **kwargs)[source]

Bases: stytra.stimulation.stimuli.voltage_stimuli.NIVoltageStimulus, stytra.stimulation.stimuli.generic_stimuli.InterpolatedStimulus

update()[source]

Function called by the ProtocolRunner every timestep until the Stimulus is over.

class stytra.stimulation.stimuli.voltage_stimuli.U3LabJackVoltageStimulus(*args, **kwargs)[source]

Bases: stytra.stimulation.stimuli.generic_stimuli.Stimulus

class stytra.stimulation.stimuli.voltage_stimuli.SetU3LabJackVoltageStimulus(*args, voltage=0.0, **kwargs)[source]

Bases: stytra.stimulation.stimuli.voltage_stimuli.U3LabJackVoltageStimulus

start()[source]

Function called by the ProtocolRunner when a new stimulus is set.

class stytra.stimulation.stimuli.voltage_stimuli.InterpolatedU3LabJackVoltageStimulus(*args, **kwargs)[source]

Bases: stytra.stimulation.stimuli.generic_stimuli.InterpolatedStimulus, stytra.stimulation.stimuli.generic_stimuli.DynamicStimulus, stytra.stimulation.stimuli.voltage_stimuli.U3LabJackVoltageStimulus

update()[source]

Module contents