34 lines
905 B
Python
34 lines
905 B
Python
|
|
from stimuli.AbstractStimulus import AbstractStimulus
|
|
|
|
|
|
class StepStimulus(AbstractStimulus):
|
|
|
|
def __init__(self, start, duration, value, base_value=0, seconds=True):
|
|
if duration < 0:
|
|
raise ValueError("Duration cannot be negative")
|
|
|
|
self.base_value = base_value
|
|
self.value = value
|
|
if seconds:
|
|
self.start = start
|
|
self.duration = duration
|
|
else:
|
|
self.start = start / 1000
|
|
self.duration = duration / 1000
|
|
|
|
def value_at_time_in_s(self, time_point):
|
|
if self.start <= time_point <= self.start + self.duration:
|
|
return self.value
|
|
else:
|
|
return self.base_value
|
|
|
|
def get_stimulus_start_s(self):
|
|
return self.start
|
|
|
|
def get_stimulus_duration_s(self):
|
|
return self.duration
|
|
|
|
def get_amplitude(self):
|
|
return self.value - self.base_value
|