当前位置: 首页>>代码示例>>Python>>正文


Python StimulusModel.insertComponent方法代码示例

本文整理汇总了Python中sparkle.stim.stimulus_model.StimulusModel.insertComponent方法的典型用法代码示例。如果您正苦于以下问题:Python StimulusModel.insertComponent方法的具体用法?Python StimulusModel.insertComponent怎么用?Python StimulusModel.insertComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sparkle.stim.stimulus_model.StimulusModel的用法示例。


在下文中一共展示了StimulusModel.insertComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_insert_remove_stim

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
    def test_insert_remove_stim(self):
        tests = ProtocolTabelModel()
        tests.setReferenceVoltage(100, 0.1)
        model = QProtocolTabelModel(tests)
        stim = StimulusModel()
        component = PureTone()
        stim.insertComponent(component, 0,0)
        model.insertTest(stim,0)        

        headers = model.allHeaders()
        repidx = headers.index('Reps')
        lenidx = headers.index('Length')
        totalidx = headers.index('Total')
        fsidx = headers.index('Generation rate')

        assert_equal(stim, model.data(model.index(0,0), role=QtCore.Qt.UserRole+1))
        assert_equal([stim], model.stimulusList())
        assert model.data(model.index(0,repidx), role=QtCore.Qt.DisplayRole) == 1
        assert model.data(model.index(0,lenidx), role=QtCore.Qt.DisplayRole) == 1
        assert model.data(model.index(0,totalidx), role=QtCore.Qt.DisplayRole) == 1
        assert model.data(model.index(0,fsidx), role=QtCore.Qt.DisplayRole) == stim.samplerate()
        assert model.rowCount() == 1

        model.removeTest(0)

        assert model.rowCount() == 0
        assert_equal([], model.stimulusList())
开发者ID:boylea,项目名称:sparkle,代码行数:29,代码来源:test_protocol_model.py

示例2: test_chart_tone_protocol

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
    def test_chart_tone_protocol(self):
        winsz = 0.1 #seconds
        acq_rate = 50000
        manager, fname = self.create_acqmodel(winsz, acq_rate)
        manager.set(savechart=True)

        #insert some stimuli

        tone0 = PureTone()
        tone0.setDuration(winsz)
        stim0 = StimulusModel()
        stim0.insertComponent(tone0)
        manager.protocol_model().insert(stim0,0)
        gen_rate = stim0.samplerate()

        manager.start_chart()
        t = manager.run_chart_protocol(0.15)
        t.join()

        manager.stop_chart()
        manager.close_data()

        # now check saved data
        hfile = h5py.File(os.path.join(self.tempfolder, fname))
        test = hfile['chart_1']
        stim = json.loads(test.attrs['stim'])

        # print 'stim', stim
        # assert_in('components', stim[0])
        # assert_equal(stim[0]['samplerate_da'], gen_rate)
        assert len(test.shape) == 1
        assert test.shape[0] >= winsz*acq_rate
        
        hfile.close()
开发者ID:boylea,项目名称:sparkle,代码行数:36,代码来源:test_acq_manager.py

示例3: test_abort_protocol

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
    def test_abort_protocol(self):
        winsz = 0.2 #seconds
        acq_rate = 50000
        manager, fname = self.create_acqmodel(winsz, acq_rate)
        manager.set_calibration(None)
        #insert some stimuli
        tone0 = PureTone()
        tone0.setDuration(0.02)
        stim0 = StimulusModel()
        stim0.insertComponent(tone0)
        stim0.setRepCount(500) # set really high so we don't miss
        manager.protocol_model().insert(stim0,0)
        gen_rate = stim0.samplerate()

        manager.setup_protocol(0.1)
        t = manager.run_protocol()
        manager.halt()
        t.join()
        manager.close_data()

        # now check saved data
        hfile = h5py.File(os.path.join(self.tempfolder, fname))
        group = hfile['segment_1']
        print 'AASERT AVERAGE', type(group.attrs['averaged'])
        assert group.attrs['averaged'] == False


        assert group.attrs.get('aborted') is not None
        abort_msg = group.attrs['aborted']
        assert abort_msg.startswith("test 1, trace 0, rep")

        hfile.close()
开发者ID:boylea,项目名称:sparkle,代码行数:34,代码来源:test_acq_manager.py

示例4: test_vocal_protocol

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
    def test_vocal_protocol(self):
        """Run protocol with single vocal wav stimulus"""
        winsz = 0.2 #seconds
        acq_rate = 50000
        manager, fname = self.create_acqmodel(winsz, acq_rate)

        vocal0 = Vocalization()
        vocal0.setFile(sample.samplewav())
        stim0 = StimulusModel()
        stim0.insertComponent(vocal0)
        manager.protocol_model().insert(stim0,0)

        manager.setup_protocol(0.1)
        t = manager.run_protocol()
        t.join()

        manager.close_data()

        # now check saved data
        hfile = h5py.File(os.path.join(self.tempfolder, fname))
        test = hfile['segment_1']['test_1']

        check_result(test, stim0, winsz, acq_rate)
        assert hfile['segment_1'].attrs['averaged'] == False

        hfile.close()
开发者ID:boylea,项目名称:sparkle,代码行数:28,代码来源:test_acq_manager.py

示例5: test_tone_protocol_uncalibrated

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
    def test_tone_protocol_uncalibrated(self):
        """Test a protocol with a single tone stimulus"""
        winsz = 0.2 #seconds
        acq_rate = 50000
        manager, fname = self.create_acqmodel(winsz, acq_rate)
        manager.set_calibration(None)
        #insert some stimuli

        tone0 = PureTone()
        tone0.setDuration(0.02)
        stim0 = StimulusModel()
        stim0.insertComponent(tone0)
        manager.protocol_model().insert(stim0,0)
        gen_rate = stim0.samplerate()

        manager.setup_protocol(0.1)
        t = manager.run_protocol()
        t.join()

        manager.close_data()

        # now check saved data
        hfile = h5py.File(os.path.join(self.tempfolder, fname))
        test = hfile['segment_1']['test_1']

        stim = json.loads(test.attrs['stim'])

        check_result(test, stim0, winsz, acq_rate)

        assert hfile['segment_1'].attrs['calibration_used'] == '' 
        assert hfile['segment_1'].attrs['averaged'] == False

        hfile.close()
开发者ID:boylea,项目名称:sparkle,代码行数:35,代码来源:test_acq_manager.py

示例6: test_verify_success

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
    def test_verify_success(self):
        tests = ProtocolTabelModel()
        tests.setReferenceVoltage(100, 0.1)
        model = QProtocolTabelModel(tests)
        stim = StimulusModel()
        component = PureTone()
        stim.insertComponent(component, 0,0)
        model.insertTest(stim,0)

        assert model.verify() == 0
开发者ID:boylea,项目名称:sparkle,代码行数:12,代码来源:test_protocol_model.py

示例7: stim_with_double_auto

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [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
开发者ID:boylea,项目名称:sparkle,代码行数:14,代码来源:test_stim_model.py

示例8: __init__

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
    def __init__(self, *args):
        super(MphoneCalibrationRunner, self).__init__(*args)

        self.save_data = False
        self.silence_window = False
        self.player = FinitePlayer()

        # acquistiion without a stimulus is not allowed, so use silence
        stim = StimulusModel()
        stim.setRepCount(self._reps)
        stim.insertComponent(Silence())
        self.protocol_model.insert(stim,0)
开发者ID:Joel-U,项目名称:sparkle,代码行数:14,代码来源:microphone_calibration_runner.py

示例9: create_tone_stim

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
def create_tone_stim(nreps):
    component = PureTone()
    stim_model = StimulusModel()
    stim_model.insertComponent(component, 0,0)
    stim_model.setRepCount(nreps)
    auto_model = stim_model.autoParams()
    auto_model.insertRow(0)
    
    auto_model.toggleSelection(0,component)

    # values = ['frequency', 0, 100, 10]
    values = ['duration', 0.065, 0.165, 0.010] # had caused problem in past
    auto_model.setParamValue(0, parameter=values[0], start=values[1], 
                            stop=values[2], step=values[3])

    return stim_model
开发者ID:boylea,项目名称:sparkle,代码行数:18,代码来源:test_acq_manager.py

示例10: tone_protocol

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
    def tone_protocol(self, manager, intensity=70):
        #insert some stimuli

        tone = PureTone()
        tone.setDuration(0.02)
        tone.setIntensity(intensity)
        stim = StimulusModel()
        stim.insertComponent(tone)
        stim.setRepCount(3)
        manager.protocol_model().insert(stim,0)

        manager.setup_protocol(0.1)
        t = manager.run_protocol()
        t.join()
        
        return stim
开发者ID:boylea,项目名称:sparkle,代码行数:18,代码来源:test_acq_manager.py

示例11: create

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
    def create():
        stim = StimulusModel()
        tone = PureTone()
        tone.setDuration(0.1)
        stim.insertComponent(tone)

        tuning_curve = stim.autoParams()

        tuning_curve.insertRow(0)
        tuning_curve.toggleSelection(0, tone)
        tuning_curve.setParamValue(0, parameter='frequency', start=1000, stop=100000, step=20000)
        tuning_curve.insertRow(1)
        tuning_curve.toggleSelection(1, tone)
        tuning_curve.setParamValue(1, parameter='intensity', start=90, stop=100, step=10)

        stim.setStimType(TuningCurveEditor.name)
        return stim
开发者ID:pdroberts,项目名称:sparkle,代码行数:19,代码来源:factory.py

示例12: create_tone_stim

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [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
开发者ID:boylea,项目名称:sparkle,代码行数:19,代码来源:test_memory_limit.py

示例13: __init__

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
    def __init__(self, *args):
        super(CalibrationCurveRunner, self).__init__(*args)

        self.group_name = 'calibration_test_'

        self.player = FinitePlayer()

        self.stimulus = CCFactory.create()

        self.protocol_model.insert(self.stimulus, 0)

        # add in a tone at the calibration frequency and intensity
        control_stim = StimulusModel()
        self.control_tone = PureTone()
        control_stim.insertComponent(self.control_tone)
        self.protocol_model.insert(control_stim, 0)

        self.save_data = False
开发者ID:Joel-U,项目名称:sparkle,代码行数:20,代码来源:calibration_runner.py

示例14: create_vocal_stim

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
def create_vocal_stim(nreps):
    component = Vocalization()
    component.setFile(sample.samplewav())
    delay = Silence()
    stim_model = StimulusModel()
    stim_model.insertComponent(delay, 0,0)
    stim_model.insertComponent(component, 0,0)
    stim_model.setRepCount(nreps)

    auto_model = stim_model.autoParams()
    auto_model.insertRow(0)
    p = {'parameter' : 'filename',
         'names' : [sample.samplewav(), sample.samplewav()],
         'selection' : []
        }
    auto_model.overwriteParam(0,p)
    auto_model.toggleSelection(0,component)

    return stim_model
开发者ID:boylea,项目名称:sparkle,代码行数:21,代码来源:test_acq_manager.py

示例15: create

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import insertComponent [as 别名]
    def create():
        stim = StimulusModel()
        tone = PureTone()
        tone.setDuration(CCFactory.defaultInputs['duration'])
        tone.setRisefall(CCFactory.defaultInputs['risefall'])
        stim.insertComponent(tone)

        tuning_curve = stim.autoParams()

        tuning_curve.insertRow(0)
        tuning_curve.toggleSelection(0, tone)
        tuning_curve.setParamValue(0, parameter='frequency', start=CCFactory.defaultInputs['freqStart'], stop=CCFactory.defaultInputs['freqStop'], step=CCFactory.defaultInputs['freqStep'])
        tuning_curve.insertRow(1)
        tuning_curve.toggleSelection(1, tone)
        tuning_curve.setParamValue(1, parameter='intensity', start=CCFactory.defaultInputs['intenStart'], stop=CCFactory.defaultInputs['intenStop'], step=CCFactory.defaultInputs['intenStep'])

        stim.setRepCount(CCFactory.defaultInputs['reps'])

        stim.setStimType(CCFactory.name)
        return stim
开发者ID:Joel-U,项目名称:sparkle,代码行数:22,代码来源:factory.py


注:本文中的sparkle.stim.stimulus_model.StimulusModel.insertComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。