commit all existing code
This commit is contained in:
8
stimuli/AbstractStimulus.py
Normal file
8
stimuli/AbstractStimulus.py
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
class AbstractStimulus:
|
||||
|
||||
def value_at_time_in_ms(self, time_point):
|
||||
raise NotImplementedError("This is an abstract class!")
|
||||
|
||||
def value_at_time_in_s(self, time_point):
|
||||
raise NotImplementedError("This is an abstract class!")
|
||||
26
stimuli/StepStimulus.py
Normal file
26
stimuli/StepStimulus.py
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
from stimuli.AbstractStimulus import AbstractStimulus
|
||||
|
||||
|
||||
class StepStimulus(AbstractStimulus):
|
||||
|
||||
def __init__(self, start, duration, value, base_value=0, seconds=True):
|
||||
self.start = 0
|
||||
self.duration = 0
|
||||
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_ms(self, time_point):
|
||||
return self.value_at_time_in_s(time_point/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
|
||||
0
stimuli/__init__.py
Normal file
0
stimuli/__init__.py
Normal file
Reference in New Issue
Block a user