當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。