def __init__(self, kwd, dtype_to=None): if isinstance(kwd, string_types): kwd = open_file(kwd, 'r') self.to_close = True else: self.to_close = False self._kwd = kwd super(KwdRawDataReader, self).__init__(dtype_to=dtype_to)
def __init__(self, kwd, dtype_to=None): if isinstance(kwd, string_types): kwd = open_file(kwd, 'r') self.to_close = True else: self.to_close = False self._kwd = kwd nrecordings = self._kwd.root.recordings._v_nchildren super(KwdRawDataReader, self).__init__(dtype_to=dtype_to)
def convert_dat_to_kwd(dat_reader, kwd_file, chunk_size=20000): with open_file(kwd_file, 'a') as kwd: for chunk in dat_reader.chunks(chunk_size): data = chunk.data_chunk_full rec = chunk.recording try: # Add the data to the KWD file, in /recordings/[X]/data. kwd.root.recordings._f_getChild(str(rec)).data.append(data) except tb.NoSuchNodeError: # If /recordings/[X] does not exist, add this recording # to the KWD file and the data as well. add_recording_in_kwd(kwd, recording_id=rec, nchannels=chunk.nchannels, nsamples=chunk.nsamples, data=data)