def get_data(file, min, max, animation_time=animation_time, num_events=num_events_p_s * animation_time, offset=0): aefile = paer.aefile(file, max_events=max + 1) aedata = paer.aedata(aefile) #print 'Points: %i, Time: %0.2f. End Time: %0.2f. Start Time: %0.2f.Sparsity: %i' % (len(aefile.data), (aefile.timestamp[-1]-aefile.timestamp[0])/1000000, aefile.timestamp[-1]/1000000, aefile.timestamp[0]/1000000, # np.floor(len(aefile.data)/num_events)) sparse = aedata[min:max].make_sparse(np.floor((max - min) / num_events)) for i in range(1, len(sparse.ts)): #print sparse.y[-i] if (sparse.ts[-i] != 0): last_index = -i break print "last index: %d, last time stamp %d" % (last_index, sparse.ts[last_index]) actual_time = (sparse.ts[last_index] - sparse.ts[0]) / 1000000 scale = actual_time / animation_time sparse.ts = (offset * 1000000) + np.round( (sparse.ts - sparse.ts[0]) / scale) # print sparse_ts[0], sparse_ts[-1], sparse_ts[-1]-sparse_ts[0], (sparse_ts[-1]-sparse_ts[0])/1000000 print len(sparse[0:len(sparse.ts) + last_index + 1]) return sparse[0:len(sparse.ts) + last_index + 1]
def get_data(file, min, max, animation_time=animation_time, whitespace_time=whitespate_time, num_events=num_events_p_s*animation_time, offset=0): aefile = paer.aefile(file, max_events=max+1) aedata = paer.aedata(aefile) print 'Points: %i, Time: %0.2f. Sparsity: %i' % (len(aefile.data), (aefile.timestamp[-1]-aefile.timestamp[0])/1000000, np.floor(len(aefile.data)/num_events)) sparse = aedata[min:max].make_sparse(np.floor(len(aefile.data)/num_events)) actual_time = (sparse.ts[-1]-sparse.ts[0])/1000000 scale = actual_time/animation_time sparse.ts = (offset * 1000000) + np.round((sparse.ts-sparse.ts[0])/scale) # print sparse_ts[0], sparse_ts[-1], sparse_ts[-1]-sparse_ts[0], (sparse_ts[-1]-sparse_ts[0])/1000000 return sparse
def get_data(file, min, max, animation_time=animation_time, num_events=num_events_p_s * animation_time, offset=0): aefile = paer.aefile(file, max_events=max + 1) aedata = paer.aedata(aefile) print 'Points: %i, Time: %0.2f. Sparsity: %i' % ( len(aefile.data), (aefile.timestamp[-1] - aefile.timestamp[0]) / 1000000, np.floor(len(aefile.data) / num_events)) sparse = aedata[min:max].make_sparse( np.floor(len(aefile.data) / num_events)) actual_time = (sparse.ts[-1] - sparse.ts[0]) / 1000000 scale = actual_time / animation_time sparse.ts = (offset * 1000000) + np.round( (sparse.ts - sparse.ts[0]) / scale) # print sparse_ts[0], sparse_ts[-1], sparse_ts[-1]-sparse_ts[0], (sparse_ts[-1]-sparse_ts[0])/1000000 return sparse
from os import listdir from os.path import isfile, join import paer mypath = '/path/to/fyp-aedata-matlab' onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) and f.endswith('.aedat')] for file in onlyfiles: ae = paer.aefile('path/to/fyp-aedata-matlab/' + str(file)) aed= paer.aedata(ae).downsample((16,16)) paer.create_pngs(aed, '16x16_' + str(file) + '_',path='testing_something',step=3000, dim=(16,16))
import paer file = '/path/to/left_to_right_1.aedat' lib = paer.aefile(file, max_events=750001) data = paer.aedata(lib) sparse = data[300000:750000].make_sparse(64).downsample((16, 16)) sparse.save_to_mat('downsample_left_to_right_1_1.mat') lib.save(sparse, 'downsample_left_to_right_1_1.aedat')
import paer file = 'aedat/left_to_right_1.aedat' lib = paer.aefile(file, max_events=750001) data = paer.aedata(lib) sparse = data[300000:750000].make_sparse(64).downsample((16,16)) sparse.save_to_mat('mat/16_16_left_to_right_1_1.mat') lib.save(sparse, 'aedat/16_16_left_to_right_1_1.aedat')
def get_data(file, max=10**60): aefile = paer.aefile(file, max_events=max + 1) aedata = paer.aedata(aefile) aetime = (aefile.timestamp[-1] - aefile.timestamp[0]) print 'Points: %i, Time: %0.2f us' % (len(aefile.data), aetime) return aedata, aetime
import paer data = paer.aedata( paer.aefile('/path/to/left_to_right_1.aedat', max_events=1000000)) data = data.make_sparse(64).downsample((16, 16)) data.interactive_animation(step=1000, limits=(0, 16))
import paer data = paer.aedata(paer.aefile('aedat/left_to_right_1.aedat', max_events=1000000)) data = data.make_sparse(64).downsample((16,16)) data.interactive_animation(step=1000,limits=(0,16))
# Count aedat files for progress bar files = 0 for filename in os.listdir(directory): if filename.endswith(".aedat"): files += 1 # Timer output format widgets = [ 'Processing ' + str(files) + ' files:', pb.Percentage(), ' ', pb.Bar(marker='|'), ' ' ] # Start timer timer = pb.ProgressBar(widgets=widgets, maxval=files).start() iter = 0 for filename in os.listdir(directory): if filename.endswith(".aedat"): d = paer.aedata(paer.aefile(filename)) d = d.filter_events('OFF') d = d.take_v2(89).change_timescale(length=200, start=0) d.save_to_mat(os.path.splitext(filename)[0] + '.mat') #Update timer iter += 1 timer.update(iter) # Stop timer timer.finish()
def get_data(file): aefile = paer.aefile(file) aedata = paer.aedata(aefile) print 'Points: %i, Time: %0.2f' % (len( aefile.data), (aefile.timestamp[-1] - aefile.timestamp[0]) / (10**6)) return aedata
from os import listdir from os.path import isfile, join import paer mypath = '/path/to/fyp-aedata-matlab' onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath, f)) and f.endswith('.aedat') ] for file in onlyfiles: ae = paer.aefile('path/to/fyp-aedata-matlab/' + str(file)) aed = paer.aedata(ae).downsample((16, 16)) paer.create_pngs(aed, '16x16_' + str(file) + '_', path='testing_something', step=3000, dim=(16, 16))