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


Python StimulusModel.signalFromDoc方法代码示例

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


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

示例1: displayOldData

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import signalFromDoc [as 别名]
    def displayOldData(self, path, tracenum, repnum=0):
        if self.activeOperation is None:
            # requires use of AcquisitionData API
            path = str(path)
            if '/' in path:
                group_path = os.path.dirname(path)
            else:
                group_path = path

            group_info = dict(self.acqmodel.datafile.get_info(group_path))
            aifs = group_info['samplerate_ad']

            if repnum == -1:
                showall = True
                response = self.acqmodel.datafile.get_data(path, (tracenum,))
                repnum = response.shape[0] -1
                if len(response.shape) == 2:
                    # backwards compatibility: reshape old data to have channel dimension
                    response = response.reshape((response.shape[0], 1, response.shape[1]))
            else:
                showall = False
                response = self.acqmodel.datafile.get_data(path, (tracenum, repnum))
                if len(response.shape) == 1:
                    # backwards compatibility: reshape old data to have channel dimension
                    response = response.reshape((1, response.shape[0]))
            npoints = response.shape[-1]            
            nchans = response.shape[-2]

            winsz = float(npoints)/aifs
            times = np.linspace(0, winsz, npoints)

            # plot response signal
            self.ui.plotDock.switchDisplay('standard')
            self.display.setXlimits((0,winsz))

            if len(self._aichans) != nchans:
                cnames = get_ai_chans(self.advanced_options['device_name'])
                self.setNewChannels(cnames[:nchans])

            for chan, name in enumerate(self._aichans):
                if len(response.shape) == 3:
                    # overlay plot
                    self.display.updateSpiketrace(times, response[:,chan,:], name)
                else:
                    self.display.updateSpiketrace(times, response[chan,:], name)

            stimuli = self.acqmodel.datafile.get_trace_stim(path)

            stimulus = stimuli[tracenum]

            # show the stimulus details
            self.reportProgress(-1, tracenum, stimulus)
            self.reportRep(repnum)

            # need to also recreate the stim
            if repnum == 0:
                # assume user must first access the first presentation
                # before being able to browse through reps

                # recreate stim signal
                stim_signal = StimulusModel.signalFromDoc(stimulus, self.calvals['calv'], self.calvals['caldb'])
                fs = stimulus['samplerate_da']
                timevals = np.arange(len(stim_signal)).astype(float)/fs
                freq, spectrum = calc_spectrum(stim_signal, fs)
                spectrum = calc_db(spectrum, self.calvals['calv']) + self.calvals['caldb']
                self.display.updateSignal(timevals, stim_signal)
                self.display.updateFft(freq, spectrum)
                self.display.updateSpec(stim_signal, fs)

            self.ui.psth.clearData()
            self.display.clearRaster()

            # recreate PSTH for current threshold and current rep
            tracedata = self.acqmodel.datafile.get_data(path, (tracenum,))
            if len(tracedata.shape) == 2:
                # backwards compatibility: reshape old data to have channel dimension
                tracedata = tracedata.reshape((tracedata.shape[0], 1, tracedata.shape[1]))

            self.display.setNreps(tracedata.shape[0])

            binsz = float(self.ui.binszSpnbx.value())
            winsz = float(tracedata.shape[-1])/aifs
            # set the max of the PSTH subwindow to the size of this data
            self.ui.psthStopField.setMaximum(winsz)
            self.ui.psthStartField.setMaximum(winsz)

            nbins = np.ceil(winsz/binsz)
            bin_centers = (np.arange(nbins)*binsz)+(binsz/2)
            self.ui.psth.setBins(bin_centers)

            # because we can scroll forwards or backwards, re-do entire plot every time 
            spike_counts = []
            spike_latencies = []
            spike_rates = []
            for irep in range(repnum+1):
                count, latency, rate, response_bins = self.do_spike_stats(tracedata[irep], aifs)
                spike_counts.extend(count)
                spike_latencies.extend(latency)
                spike_rates.extend(rate)
                for chan, name in enumerate(self._aichans):
#.........这里部分代码省略.........
开发者ID:boylea,项目名称:sparkle,代码行数:103,代码来源:main_control.py


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