• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python stimulus_model.StimulusModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_vocal_protocol

    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,代码行数:26,代码来源:test_acq_manager.py


示例2: test_chart_tone_protocol

    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,代码行数:34,代码来源:test_acq_manager.py


示例3: test_tone_protocol_uncalibrated

    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,代码行数:33,代码来源:test_acq_manager.py


示例4: test_insert_remove_stim

    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,代码行数:27,代码来源:test_protocol_model.py


示例5: createView

 def createView(self):
     view = ProtocolView()
     tests = ProtocolTabelModel()
     tests.setReferenceVoltage(100, 0.1)
     model = QProtocolTabelModel(tests)
     view.setModel(model)
     stim = TCFactory.create()
     StimulusModel.setMaxVoltage(5.0, 5.0)
     model.insertTest(stim, 0)
     return view, stim
开发者ID:boylea,项目名称:sparkle,代码行数:10,代码来源:test_protocol_view.py


示例6: test_verify_success

    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,代码行数:10,代码来源:test_protocol_model.py


示例7: setUp

    def setUp(self):
        StimulusModel.setMaxVoltage(1.5, 10.0)
        StimulusModel.setMinVoltage(0.005)
        self.tempfolder = os.path.join(os.path.abspath(os.path.dirname(__file__)), u"tmp")
        self.done = True

        log = logging.getLogger('main')
        log.setLevel(logging.DEBUG)
        self.stream = StringIO.StringIO()
        self.handler = logging.StreamHandler(self.stream)
        log.addHandler(self.handler)
开发者ID:boylea,项目名称:sparkle,代码行数:11,代码来源:test_acq_manager.py


示例8: __init__

    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,代码行数:12,代码来源:microphone_calibration_runner.py


示例9: create

 def create(self):
     stim = StimulusModel()
     # load saved settings into stimulus
     fname = QtGui.QFileDialog.getOpenFileName(None, u"Load Stimulus from File", 
                                 self.save_folder, "Stimulus Settings (*.json)")
     if fname:
         with open(fname, 'r') as jf:
             state = json.load(jf)
         stim.loadFromTemplate(state, stim)
         self._editor = get_stimulus_editor(stim.stimType())
     else:
         return None
     return stim
开发者ID:pdroberts,项目名称:sparkle,代码行数:13,代码来源:factory.py


示例10: launchAdvancedDlg

 def launchAdvancedDlg(self):
     dlg = AdvancedOptionsDialog(self.advanced_options)
     if dlg.exec_():
         self.advanced_options = dlg.getValues()
         StimulusModel.setMaxVoltage(self.advanced_options['max_voltage'], self.advanced_options['device_max_voltage'])
         self.display.setAmpConversionFactor(self.advanced_options['volt_amp_conversion'])
         if self.advanced_options['use_attenuator']:
             # could check for return value here? It will try
             # to re-connect every time start is pressed anyway
             self.acqmodel.attenuator_connection(True)
         else:
             self.acqmodel.attenuator_connection(False)
         self.reset_device_channels()
     dlg.deleteLater()
开发者ID:boylea,项目名称:sparkle,代码行数:14,代码来源:main_control.py


示例11: test_template_with_auto_params

    def test_template_with_auto_params(self):
        self.model.setRepCount(7)
        component = PureTone()
        component.setIntensity(34)
        self.model.insertComponent(component, 0,0)
        nsteps = self.add_auto_param(self.model) 

        template = self.model.templateDoc()

        clone = StimulusModel.loadFromTemplate(template)
        clone.setReferenceVoltage(100, 0.1)

        signals0, docs0, ovld = self.model.expandedStim()
        signals1, docs1, ovld = clone.expandedStim()

        assert clone.stimid != self.model.stimid
        assert len(signals0) == len(signals1)
        for i in range(len(signals0)):
            signal0, atten0 = signals0[i]
            signal1, atten1 = signals1[i]
            np.testing.assert_array_equal(signal0, signal1)
            assert atten0 == atten1
            assert_equal(docs0[i], docs1[i])

        assert clone.repCount() == self.model.repCount()
开发者ID:boylea,项目名称:sparkle,代码行数:25,代码来源:test_stim_model.py


示例12: test_protocol_timing_vocal_batlab

    def test_protocol_timing_vocal_batlab(self):
        winsz = 0.280 #seconds
        acq_rate = 100000
        nreps = 4
        manager, fname = self.create_acqmodel(winsz, acq_rate)

        with open(sample.batlabvocal(), 'r') as jf:
            state = json.load(jf)

        stim_model = StimulusModel.loadFromTemplate(state)
        manager.protocol_model().insert(stim_model,0)

        interval = 333
        manager.setup_protocol(interval)
        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']
        stims = json.loads(test.attrs['stim'])
        
        hfile.close()

        # aggregate all time intervals
        intervals = []
        for stim in stims:
            intervals.extend(stim['time_stamps'])
        intervals = np.diff(intervals)
        intervals = abs(intervals*1000 - interval)
        print 'all intervals', intervals.shape, intervals

        # ms tolerance, not as good as I would like
        assert all(map(lambda x: x < 20, intervals))
开发者ID:boylea,项目名称:sparkle,代码行数:35,代码来源:test_acq_manager.py


示例13: tone_protocol

    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,代码行数:16,代码来源:test_acq_manager.py


示例14: test_calibration_template

    def test_calibration_template(self):
        ccf = CCFactory()
        model = ccf.create()
        model.setReferenceVoltage(100, 0.1)
        model.setRepCount(7)

        template = model.templateDoc()

        clone = StimulusModel.loadFromTemplate(template)
        clone.setReferenceVoltage(100, 0.1)

        signals0, docs0, ovld = model.expandedStim()
        signals1, docs1, ovld = clone.expandedStim()

        assert clone.stimid != model.stimid
        assert len(signals0) == len(signals1)
        assert clone.repCount() == model.repCount()
        for i in range(len(signals0)):
            print 'comparing signal', i
            signal0, atten0 = signals0[i]
            signal1, atten1 = signals1[i]
            np.testing.assert_array_equal(signal0, signal1)
            print 'atten0 {}, atten1 {}'.format(atten0, atten1)
            assert atten0 == atten1
            assert_equal(docs0[i], docs1[i])
开发者ID:boylea,项目名称:sparkle,代码行数:25,代码来源:test_stim_model.py


示例15: __init__

    def __init__(self, *args):
        self._stimulus = StimulusModel()

        super(SearchRunner, self).__init__(*args)

        self.player = FinitePlayer()
        self.save_data = False
        self.set_name = 'explore_1'
开发者ID:boylea,项目名称:sparkle,代码行数:8,代码来源:search_runner.py


示例16: __init__

    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,代码行数:18,代码来源:calibration_runner.py


示例17: loadFromTemplate

    def loadFromTemplate(template, stim=None):
        """Initialized this stimulus from a saved *template*

        :param template: doc from a previously stored stimulus via :class:`templateDoc`
        :type template: dict
        """
        stim = StimulusModel.loadFromTemplate(template, stim=stim)
        qstim = QStimulusModel(stim)
        qstim.setEditor(template['testtype'])
        return qstim
开发者ID:Joel-U,项目名称:sparkle,代码行数:10,代码来源:qstimulus.py


示例18: test_abort_protocol

    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,代码行数:32,代码来源:test_acq_manager.py


示例19: test_edit_model

    def test_edit_model(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 stim.repCount() == 1

        newreps = 3
        headers = model.allHeaders()
        repidx = headers.index('Reps')
        lenidx = headers.index('Length')
        totalidx = headers.index('Total')
        model.setData(model.index(0,repidx), newreps, QtCore.Qt.EditRole)

        assert stim.repCount() == newreps
        assert model.data(model.index(0,repidx), role=QtCore.Qt.DisplayRole) == newreps
        assert model.data(model.index(0,lenidx), role=QtCore.Qt.DisplayRole) == 1
        assert model.data(model.index(0,totalidx), role=QtCore.Qt.DisplayRole) == newreps
开发者ID:boylea,项目名称:sparkle,代码行数:22,代码来源:test_protocol_model.py


示例20: stim_with_double_auto

    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,代码行数:12,代码来源:test_stim_model.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python configuration.override_all函数代码示例发布时间:2022-05-27
下一篇:
Python models.get_api函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap