def read_data_file(self, fullpath, trodes='all'): if fullpath.endswith('.gz'): infile = gzip.open(fullpath, 'rb') else: infile = open(fullpath, 'rb') data = cPickle.load(infile) if trodes is 'all': voltage_traces = data['voltage_traces'] else: vtrace_arrays = [] all_voltage_traces = data['voltage_traces'] for i in trodes: vtrace_arrays.append(all_voltage_traces[i]) voltage_traces = numpy.vstack(vtrace_arrays) sampling_freq = data['sampling_freq'] infile.close() if len(voltage_traces) == 16: voltage_traces = voltage_traces[[i-1 for i in SHANK_CHANNEL_INDEX]] display_name = os.path.splitext(os.path.split(fullpath)[-1])[0] trials = [Trial.from_raw_traces(sampling_freq, voltage_traces, origin=fullpath, display_name=display_name)] return trials
def load_archive(archive): results = [] for ta in archive['trials']: trial = Trial.from_dict(ta) results.append(trial) results.append(Strategy.from_dict(archive['strategy'])) return results
def read_data_file(self, fullpath): # I don't want this plugin to fail (if TEP is not installed on the system) # until it is tried. from tep.utils.file_io.read_data_file import read_data_file as rdf self.db_path = fullpath app = wx.GetApp() start_loop = False if app is None: start_loop = True app = wx.PySimpleApp() if start_loop: # if we're not already in the MainLoop, we have to have to start it # up and then have it call the startup_search. wx.CallLater(300, self._startup_search) app.MainLoop() else: self._startup_search() # make trial objects and return them. trials = [] for path, display_name in self.data_paths: data = rdf(path, determine_pulse_onset=False) voltage_traces = data["voltage_traces"] sampling_freq = data["sampling_freq"] if len(voltage_traces) == 16: voltage_traces = voltage_traces[[i - 1 for i in SHANK_CHANNEL_INDEX]] trial = Trial.from_raw_traces(sampling_freq, voltage_traces, origin=path, display_name=display_name) trials.append(trial) return trials
def read_data_file(self, fullpath): data = numpy.loadtxt(fullpath) raw_traces = data.T[:4] times = data.T[-1] sampling_freq = int((len(times)-1)/ (times[-1]-times[0])*1000) # 1000 kHz->Hz display_name = os.path.splitext(os.path.split(fullpath)[-1])[0] trial = Trial.from_raw_traces(sampling_freq, raw_traces, origin=fullpath, display_name=display_name) return [trial]
def read_data_file(self, fullpath): if fullpath.endswith('.pgz'): infile = gzip.open(fullpath) else: infile = open(fullpath) data = cPickle.load(infile) voltage_trace = data['voltage_trace'] sampling_freq = data['sampling_freq'] display_name = os.path.splitext(os.path.split(fullpath)[-1])[0] trial = Trial.from_raw_traces(sampling_freq, [voltage_trace], origin=fullpath, display_name=display_name) return [trial]
def read_data_file(self, fullpath): # open file and read in the data stim = xd.Stimulation(fullpath) sampling_freq = float(stim.params['adFc']) voltage_traces = stim.traces[:500,:] # must be a list of traces, even if only one trace # display_name can be anything, here we just use the filename. display_name = os.path.splitext(os.path.split(fullpath)[-1])[0] trial = Trial.from_raw_traces(sampling_freq, voltage_traces, origin=fullpath, display_name=display_name) return [trial] # need to return a list of trials.
def read_data_file(self, fullpath): if fullpath.endswith('.gz'): infile = gzip.open(fullpath, 'rb') else: infile = open(fullpath, 'rb') data = cPickle.load(infile) voltage_traces = data['voltage_traces'] sampling_freq = data['sampling_freq'] if len(voltage_traces) == 16: voltage_traces = voltage_traces[[i-1 for i in SHANK_CHANNEL_INDEX]] display_name = os.path.splitext(os.path.split(fullpath)[-1])[0] trials = [Trial.from_raw_traces(sampling_freq, voltage_traces, origin=fullpath, display_name=display_name)] return trials
def read_data_file(self, fullpath): mat_obj = loadmat(fullpath) # edit so that names match the variables in the .mat file. signal_name = 'raw_traces' times_name = 'times' infer_sampling_freq = True sf = None # mat_obj[signal_name] should be a 2D array, rows=channels cols=time. voltage_traces = mat_obj[signal_name] if infer_sampling_freq: times = mat_obj[times_name] # times are assumed to be in ms. sampling_freq = int(len(times)/(times[-1]-times[0]))*1000 else: sampling_freq = sf # display_name can be anything, here we just use the filename. display_name = os.path.splitext(os.path.split(fullpath)[-1])[0] trial = Trial.from_raw_traces(sampling_freq, voltage_traces, origin=fullpath, display_name=display_name) return [trial] # need to return a list of trials.
def read_data_file(self, fullpath, channels=None, start_time_s=None, end_time_s=None, skip_points=0): with open(fullpath) as infile: open_dlg = (channels == None or start_time_s == None or end_time_s == None) if open_dlg: # allow user to choose channels and times settings_dialog = SettingsDialog(wx.GetApp().GetTopWindow(), -1, 'Specify settings') if settings_dialog.ShowModal() == wx.ID_OK: info_dict = settings_dialog.get_info() start_time_s = info_dict['start_time_s'] end_time_s = info_dict['end_time_s'] channels = info_dict['channels'] infile.seek(286) period = struct.unpack('<I', infile.read(4))[0] sampling_freq = 30000.0/period recording_length_s = self.get_recording_length(infile, sampling_freq) end_time_s = min(end_time_s, recording_length_s) infile.seek(310) num_channels = struct.unpack('<I', infile.read(4))[0] vtrace_arrays = [] for channel in channels: vtrace_arrays.append(self.read_channel(infile, channel, start_time_s, end_time_s, sampling_freq, num_channels, skip_points=skip_points)) voltage_traces = numpy.vstack(vtrace_arrays)/1000.0 display_name = os.path.splitext(os.path.split(fullpath)[-1])[0] new_sampling_freq = sampling_freq/float(skip_points+1) trial = Trial.from_raw_traces(new_sampling_freq, voltage_traces, origin=fullpath, display_name=display_name) return [trial]