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


Python stimulus_model.StimulusModel类代码示例

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


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


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