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


Python StimulusModel.setCalibration方法代码示例

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


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

示例1: TestStimModel

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import setCalibration [as 别名]

#.........这里部分代码省略.........
        self.model.insertComponent(component, 0,0)

        ap_model = self.model.autoParams()
        ap_model.insertRow(0)
        ap_model.toggleSelection(0, component)
        
        values = ['duration', 0.020, 0.004, 0.001]
        ap_model.setParamValue(0, parameter=values[0], start=values[1],
                               stop=values[2], step=values[3])

        invalid = self.model.verify()
        print 'msg', invalid
        assert invalid

    def test_verify_with_long_auto_parameter(self):
        component = PureTone()
        self.model.insertComponent(component, 0,0)

        ap_model = self.model.autoParams()
        ap_model.insertRow(0)
        ap_model.toggleSelection(0, component)

        # default value is in ms
        values = ['duration', 0.050, 0.200, 0.025]
        ap_model.setParamValue(0, parameter=values[0], start=values[1],
                               stop=values[2], step=values[3])

        invalid = self.model.verify(windowSize=0.1)
        print 'msg', invalid
        assert invalid

    def test_calibration_samplerates_change(self):
        # get some calibration data
        frange = [5000, 100000]
        cal_data_file = open_acqdata(sample.calibration_filename(), filemode='r')
        calname = cal_data_file.calibration_list()[0]
        calibration_vector, calibration_freqs = cal_data_file.get_calibration(calname, reffreq=15000)

        assert self.model.impulseResponse is None
        self.model.setCalibration(calibration_vector, calibration_freqs, frange)
        assert self.model.impulseResponse is not None

        component = PureTone()

        self.model.insertComponent(component, 0,0)
        print self.model._calibration_fs, DEFAULT_SAMPLERATE
        assert self.model._calibration_fs == DEFAULT_SAMPLERATE

        component = Vocalization()
        component.setFile(sample.samplewav())
        self.model.insertComponent(component)

        assert self.model._calibration_fs == component.samplerate()

        self.model.removeComponent(0,0)

        assert self.model._calibration_fs == DEFAULT_SAMPLERATE

    def add_auto_param(self, model):
        # adds an autoparameter to the given model
        ptype = 'intensity'
        start = 0
        step = 1
        stop = 3

        parameter_model = model.autoParams()
        parameter_model.insertRow(0)
        # select first component
        parameter_model.toggleSelection(0, model.component(0,0))
        # set values for autoparams
        parameter_model.setParamValue(0, start=start, step=step, 
                                      stop=stop, parameter=ptype)

        return len(range(start,stop,step)) + 1

    def add_vocal_param(self, model):
        p = {'parameter' : 'filename',
                'names' : [sample.samplewav(), sample.samplewav()],
                'selection' : []
        }
        parameter_model = model.autoParams()
        parameter_model.insertRow(0)
        parameter_model.overwriteParam(0,p)
        # select first component
        parameter_model.toggleSelection(0, model.component(0,0))

        return parameter_model.numSteps(0)

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

示例2: SearchRunner

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import setCalibration [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
#.........这里部分代码省略.........
开发者ID:boylea,项目名称:sparkle,代码行数:103,代码来源:search_runner.py


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