本文整理汇总了Python中sparkle.stim.stimulus_model.StimulusModel.setReferenceVoltage方法的典型用法代码示例。如果您正苦于以下问题:Python StimulusModel.setReferenceVoltage方法的具体用法?Python StimulusModel.setReferenceVoltage怎么用?Python StimulusModel.setReferenceVoltage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sparkle.stim.stimulus_model.StimulusModel
的用法示例。
在下文中一共展示了StimulusModel.setReferenceVoltage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stim_with_double_auto
# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import setReferenceVoltage [as 别名]
def stim_with_double_auto(self):
model = StimulusModel()
model.setReferenceVoltage(100, 0.1)
model.setRepCount(7)
component = Vocalization()
component.setFile(sample.samplewav())
model.insertComponent(component, 0,0)
nsteps0 = self.add_vocal_param(model)
nsteps1 = self.add_auto_param(model)
nsteps = nsteps0*nsteps1
return model
示例2: create_tone_stim
# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import setReferenceVoltage [as 别名]
def create_tone_stim(stepsize, dur):
component = PureTone()
component.setDuration(dur)
stim_model = StimulusModel()
stim_model.setReferenceVoltage(100,1.0)
stim_model.insertComponent(component, 0,0)
auto_model = stim_model.autoParams()
auto_model.insertRow(0)
auto_model.toggleSelection(0,component)
values = ['frequency', 0, 100, stepsize]
auto_model.setParamValue(0, parameter=values[0], start=values[1],
stop=values[2], step=values[3])
print 'Number of traces: {}, num samples: {}'.format(stim_model.traceCount(), stim_model.traceCount()*(dur*5e5))
return stim_model
示例3: test_verify_with_bad_frequency_auto_parameter_disallowed
# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import setReferenceVoltage [as 别名]
def test_verify_with_bad_frequency_auto_parameter_disallowed(self):
component = PureTone()
stim_model = StimulusModel()
stim_model.setReferenceVoltage(100, 0.1)
stim_model.insertComponent(component, 0,0)
model = QStimulusModel(stim_model)
ap_model = model.autoParams()
ap_model.insertRows(0,1)
ap_model.toggleSelection(ap_model.index(0,0), component)
# setData always deals with base units
values = ['frequency', 100000, 300000, 25000]
for i, value in enumerate(values):
ap_model.setData(ap_model.index(0,i), value, QtCore.Qt.EditRole)
invalid = stim_model.verify(windowSize=0.1)
print 'msg', invalid
assert invalid == 0
assert stim_model.containsPval('frequency', 75000)
示例4: setUp
# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import setReferenceVoltage [as 别名]
def setUp(self):
self.tempfile = os.path.join(os.path.abspath(os.path.dirname(__file__)), u"tmp", 'testsave.json')
model = StimulusModel()
model.setMaxVoltage(1.5, 10.0)
model.setReferenceVoltage(100, 0.1)
model.setRepCount(7)
# add tone, vocalization, and silence components
component = PureTone()
component.setIntensity(34)
component.setDuration(0.2)
model.insertComponent(component, 0,0)
vocal = Vocalization()
vocal.setFile(sample.samplewav())
model.insertEmptyRow()
model.insertComponent(vocal, 1,0)
silence = Silence()
# have gap between tone and vocal
silence.setDuration(0.5)
model.insertComponent(silence, 1,0)
nsteps = self.add_auto_param(model)
editor = StimulusEditor()
editor.setModel(QStimulusModel(model))
self.editor = editor
self.stim = model
示例5: TestStimModel
# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import setReferenceVoltage [as 别名]
class TestStimModel():
def setup(self):
self.model = StimulusModel()
self.model.setReferenceVoltage(100, 0.1)
self.model.setMaxVoltage(MAXV, DEVICE_MAXV)
self.model.setMinVoltage(0.005)
def test_insert_data(self):
fake_component0 = 'ducks'
fake_component1 = 'frogs'
self.model.insertComponent(fake_component0, 0, 0)
self.model.insertComponent(fake_component1, 0, 0)
assert self.model.component(0,0) == fake_component1
assert self.model.component(0,1) == fake_component0
def test_remove_data(self):
fake_component0 = 'ducks'
self.model.insertComponent(fake_component0, 0, 0)
self.model.removeComponent(0,0)
assert self.model.component(0,0) == None
def test_component_index(self):
fake_component0 = 'ducks'
# component will be added to the lowest index in row
self.model.insertComponent(fake_component0, 0, 2)
index = self.model.indexByComponent(fake_component0)
assert index == (0,0)
@raises(IndexError)
def test_set_data(self):
fake_component0 = 'ducks'
self.model.overwriteComponent(fake_component0, 0, 0)
def test_row_column_count(self):
fake_component0 = 'ducks'
self.model.insertComponent(fake_component0, 0, 0)
assert self.model.columnCountForRow(0) == 1
assert self.model.rowCount() == 1
def test_trace_count_no_auto(self):
component0 = PureTone()
component1 = PureTone()
self.model.insertComponent(component0, 0,0)
self.model.insertComponent(component1, 0,0)
assert self.model.traceCount() == 1
def test_trace_count_no_components(self):
self.add_auto_param(self.model)
assert self.model.traceCount() == 0
def test_trace_count_with_auto(self):
component = PureTone()
self.model.insertComponent(component, 0,0)
nsteps = self.add_auto_param(self.model)
assert self.model.traceCount() == nsteps
def test_model_contains(self):
component = PureTone()
self.model.insertComponent(component, 0,0)
assert self.model.contains('PureTone')
def test_expanded_stim_no_auto(self):
"""signal of a model without any auto parameters"""
component = PureTone()
self.model.insertComponent(component, 0,0)
signals, doc, ovld = self.model.expandedStim()
assert len(signals) == 1
assert_equal(signals[0][0].shape[0], component.duration()*self.model.samplerate())
assert len(doc) == 1
assert doc[0]['samplerate_da'] == self.model.samplerate()
def test_expanded_stim_with_auto(self):
component = PureTone()
self.model.insertComponent(component, 0,0)
nsteps = self.add_auto_param(self.model)
signals, doc, ovld = self.model.expandedStim()
assert len(signals) == nsteps
assert len(doc) == nsteps
assert doc[0]['samplerate_da'] == self.model.samplerate()
def test_expaned_stim_with_vocal_auto(self):
component = Vocalization()
component.setFile(sample.samplewav())
self.model.insertComponent(component, 0,0)
nsteps = self.add_vocal_param(self.model)
signals, doc, ovld = self.model.expandedStim()
assert len(signals) == nsteps
assert len(doc) == nsteps
assert doc[0]['samplerate_da'] == self.model.samplerate()
def test_signal_eq_caldb(self):
caldb = 100
#.........这里部分代码省略.........
示例6: SearchRunner
# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import setReferenceVoltage [as 别名]
class SearchRunner(AbstractAcquisitionRunner):
"""Handles the presentation of data where changes are allowed to
be made to the stimulus while running"""
def __init__(self, *args):
self._stimulus = StimulusModel()
super(SearchRunner, self).__init__(*args)
self.player = FinitePlayer()
self.save_data = False
self.set_name = 'explore_1'
# stimuli_types = get_stimuli_models()
# self._explore_stimuli = [x() for x in stimuli_types if x.explore]
# self.delay = Silence()
# self._stimulus.insertfComponent(self.delay)
def stimulus(self):
"""Gets a list of all the stimuli this runner has access to. Order
of the list matches the index order which stimuli can be set by.
:returns: (subclasses of) list<:class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>`>
"""
return self._stimulus
def set_calibration(self, attenuations, freqs, frange, calname):
"""See :meth:`AbstractAcquisitionRunner<sparkle.run.abstract_acquisition.AbstractAcquisitionRunner.set_calibration>`"""
self._stimulus.setCalibration(attenuations, freqs, frange)
def update_reference_voltage(self):
"""See :meth:`AbstractAcquisitionRunner<sparkle.run.abstract_acquisition.AbstractAcquisitionRunner.update_reference_voltage>`"""
self._stimulus.setReferenceVoltage(self.caldb, self.calv)
# def set_delay(self, duration):
# self.delay.setDuration(duration)
# def set_stim_by_index(self, index):
# """Sets the stimulus to be generated to the one referenced by index
# :param index: index number of stimulus to set from this class's internal list of stimuli
# :type index: int
# """
# # remove any current components
# self._stimulus.clearComponents()
# self._stimulus.insertComponent(self.delay)
# self._stimulus.insertComponent(self._explore_stimuli[index], 0, 1)
# signal, atten, overload = self._stimulus.signal()
# self.player.set_stim(signal, self._stimulus.samplerate(), attenuation=atten)
# self.putnotify('over_voltage', (overload,))
# return signal, overload
def reset_stim(self):
signal, atten, overload = self._stimulus.signal()
self.player.set_stim(signal, self._stimulus.samplerate(), attenuation=atten)
self.putnotify('over_voltage', (overload,))
self.nreps = self._stimulus.repCount()
self.irep = 0
return signal, overload
def set_current_stim_parameter(self, param, val):
"""Sets a parameter on the current stimulus
:param param: name of the parameter of the stimulus to set
:type param: str
:param val: new value to set the parameter to
"""
component = self._stimulus.component(0,1)
component.set(param, val)
def current_signal(self):
"""Signal of the currently set stimulus
:returns: numpy.ndarray
"""
return self._stimulus.signal()
# def stim_names(self):
# """The names of the all the stimuli this class can generate, in order
# :returns: list<str>
# """
# stim_names = []
# for stim in self._explore_stimuli:
# stim_names.append(stim.name)
# return stim_names
def run(self, interval):
"""See :meth:`AbstractAcquisitionRunner<sparkle.run.abstract_acquisition.AbstractAcquisitionRunner.run>`"""
self._halt = False
# TODO: some error checking to make sure valid paramenters are set
if self.save_data:
# initize data set
self.current_dataset_name = self.set_name
self.datafile.init_data(self.current_dataset_name, self.aitimes.shape, mode='open')
self.set_name = increment_title(self.set_name)
# save the start time and set last tick to expired, so first
# acquisition loop iteration executes immediately
#.........这里部分代码省略.........
示例7: PureTone
# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import setReferenceVoltage [as 别名]
tone3 = PureTone()
tone3.setDuration(0.03)
tone4 = PureTone()
tone4.setDuration(0.030)
tone5 = PureTone()
tone5.setDuration(0.030)
vocal0 = Vocalization()
test_file = os.path.join(os.path.expanduser('~'),r'Dropbox\daqstuff\M1_FD024\M1_FD024_syl_12.wav')
vocal0.setFile(test_file)
silence0 = Silence()
silence0.setDuration(0.025)
stim = StimulusModel()
stim.setReferenceVoltage(100, 0.1)
stim.insertComponent(tone2)
stim.insertComponent(tone1)
# stim.insertComponent(tone0)
# stim.insertComponent(tone4, (1,0))
# stim.insertComponent(tone5, (1,0))
stim.insertEmptyRow()
stim.insertComponent(vocal0, 1,0)
stim.insertComponent(tone3, 1,0)
# stim.insertComponent(silence0, (2,0))
ptype = 'duration'
start = .1
step = .2