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


Python StimulusModel.testDoc方法代码示例

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


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

示例1: SearchRunner

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

#.........这里部分代码省略.........
    #     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
        self.start_time = time.time()
        self.last_tick = self.start_time - (interval/1000)
        self.interval = interval
        self.acq_thread = threading.Thread(target=self._worker)

        # arm the first read
        self.player.set_aochan(self.aochan)
        self.player.set_aichan(self.aichan)

        # make sure a signal is loaded
        self.reset_stim()
        
        # and go!
        self.acq_thread.start()

        return self.acq_thread

    def _worker(self):
        try:
            spike_counts = []
            spike_latencies = []
            spike_rates = []
            self.irep = 0
            times = self.aitimes
            # report inital stim
            trace_doc = self._stimulus.componentDoc()
            trace_doc['overloaded_attenuation'] = np.nan
            self.putnotify('current_trace', (0,0,trace_doc))

            # self.player.start_timer(self.reprate)
            stim = self.player.start()
            while not self._halt:
                self.interval_wait()

                response = self.player.run()
                stamp = time.time()

                self.putnotify('response_collected', (times, response, -1, -1, self.irep, {}))
                if stim is not None:
                    self.putnotify('stim_generated', (stim, self.player.get_samplerate()))
                    trace_doc = self._stimulus.componentDoc()
                    trace_doc['overloaded_attenuation'] = np.nan
                    self.putnotify('current_trace', (0,0,trace_doc))

                #lock it so we don't get a times mismatch
                self.player_lock.acquire()
                stim = self.player.reset()
                times = self.aitimes
                self.player_lock.release()

                if self.save_data:
                    # save response data
                    self.save_to_file(response, stamp)

                self.irep +=1
                if self.irep == self.nreps:
                    self.irep = 0

            self.player.stop()
            # self.player.stop_timer()
            if self.save_data:
                self.datafile.trim(self.current_dataset_name)

        except:
            logger = logging.getLogger('main')
            logger.exception("Uncaught Exception from Explore Thread:")

    def save_to_file(self, data, stamp):
        """Saves data to current dataset.

        :param data: data to save to file
        :type data: numpy.ndarray
        :param stamp: time stamp of when the data was acquired
        :type stamp: str
        """
        self.datafile.append(self.current_dataset_name, data)
        # save stimulu info
        info = dict(self._stimulus.componentDoc().items() + self._stimulus.testDoc().items())
        print 'saving doc', info
        info['time_stamps'] = [stamp]
        info['samplerate_ad'] = self.player.aifs
        self.datafile.append_trace_info(self.current_dataset_name, info)
开发者ID:boylea,项目名称:sparkle,代码行数:104,代码来源:search_runner.py


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