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


Python StimulusModel.loadFromTemplate方法代码示例

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


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

示例1: create

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import loadFromTemplate [as 别名]
 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,代码行数:15,代码来源:factory.py

示例2: test_template_with_auto_params

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import loadFromTemplate [as 别名]
    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,代码行数:27,代码来源:test_stim_model.py

示例3: test_calibration_template

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import loadFromTemplate [as 别名]
    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,代码行数:27,代码来源:test_stim_model.py

示例4: test_protocol_timing_vocal_batlab

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import loadFromTemplate [as 别名]
    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,代码行数:37,代码来源:test_acq_manager.py

示例5: loadFromTemplate

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import loadFromTemplate [as 别名]
    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,代码行数:12,代码来源:qstimulus.py

示例6: test_template_with_auto_params_vocal

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import loadFromTemplate [as 别名]
    def test_template_with_auto_params_vocal(self):
        model = self.stim_with_double_auto()

        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)
        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() == model.repCount()
开发者ID:boylea,项目名称:sparkle,代码行数:23,代码来源:test_stim_model.py

示例7: test_template_no_auto_params

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import loadFromTemplate [as 别名]
    def test_template_no_auto_params(self):
        self.model.setRepCount(7)
        component = PureTone()
        component.setIntensity(34)
        self.model.insertComponent(component, 0,0)
        vocal = Vocalization()
        vocal.setFile(sample.samplewav())
        self.model.insertComponent(vocal, 1,0)

        template = self.model.templateDoc()

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

        signal0, atten0, ovld = clone.signal()
        signal1, atten1, ovld = self.model.signal()

        assert clone.stimid != self.model.stimid
        np.testing.assert_array_equal(signal0, signal1)
        assert atten0 == atten1
        assert clone.repCount() == self.model.repCount()
开发者ID:boylea,项目名称:sparkle,代码行数:23,代码来源:test_stim_model.py

示例8: test_template_with_auto_params_randomized

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import loadFromTemplate [as 别名]
    def test_template_with_auto_params_randomized(self):
        self.model.setRepCount(7)
        component = PureTone()
        component.setIntensity(34)
        self.model.insertComponent(component, 0,0)
        nsteps = self.add_auto_param(self.model) 
        self.model.setReorderFunc(order_function('random'), 'random')

        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)
        assert clone.reorderName == self.model.reorderName
        # how to check if signal sets are the same?

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


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