Stimulation¶
One of the main purposes of stytra is to provide a framework to design and run sequences of stimuli to be presented to the fish.
Stimuli and Protocols in stytra¶
The Stimulus
class constitutes
the building block for an experiment in stytra.
A sequence of Stimuli is bundled together and parameterized by the
Protocol
class.
See Create stimulus sequence
for a description of how to create a protocol in stytra.
The ProtocolRunner
class is used to
keep track of time and set the Stimuli in the Protocol sequence with the proper pace.
Stimuli examples¶
Full-field luminance¶
def get_stim_sequence(self):
lum = pd.DataFrame(dict(t=[0, 1, 2], luminance=[0.0, 1.0, 0.0]))
return [
DynamicLuminanceStimulus(df_param=lum, clip_mask=(0.0, 0.0, 0.5, 0.5)),
DynamicLuminanceStimulus(df_param=lum, clip_mask=(0.5, 0.5, 0.5, 0.5)),
]
Gratings¶
def get_stim_sequence(self):
Stim = type("stim", (InterpolatedStimulus, GratingStimulus), dict())
return [
Stim(df_param=pd.DataFrame(dict(t=[0, 2], vel_x=[10, 10], theta=np.pi / 4)))
]
OKR inducing rotating windmill stimulus¶
def get_stim_sequence(self):
Stim = type(
"stim", (InterpolatedStimulus, WindmillStimulus), {} # order is important!
)
return [Stim(df_param=pd.DataFrame(dict(t=[0, 2, 4], theta=[0, np.pi / 8, 0])))]
Seamlessly-tiled image¶
def get_stim_sequence(self):
Stim = type("stim", (SeamlessImageStimulus, InterpolatedStimulus), {})
return [
Stim(
background="caustics.png",
df_param=pd.DataFrame(dict(t=[0, 2], vel_x=[10, 10], vel_y=[5, 5])),
)
]
Radial sine (freely-swimming fish centering stimulus)¶
def get_stim_sequence(self):
return [RadialSineStimulus(duration=2, period=10, velocity=5)]