def view_templates(file_name, temp_id=0, best_elec=None, templates=None):
params = CircusParser(file_name)
N_e = params.getint('data', 'N_e')
N_total = params.getint('data', 'N_total')
sampling_rate = params.getint('data', 'sampling_rate')
do_temporal_whitening = params.getboolean('whitening', 'temporal')
do_spatial_whitening = params.getboolean('whitening', 'spatial')
spike_thresh = params.getfloat('detection', 'spike_thresh')
file_out_suff = params.get('data', 'file_out_suff')
N_t = params.getint('detection', 'N_t')
nodes, edges = get_nodes_and_edges(params)
chunk_size = N_t
N_total = params.getint('data', 'N_total')
inv_nodes = numpy.zeros(N_total, dtype=numpy.int32)
inv_nodes[nodes] = numpy.argsort(nodes)
if templates is None:
templates = load_data(params, 'templates')
clusters = load_data(params, 'clusters')
probe = params.probe
positions = {}
for i in probe['channel_groups'].keys():
positions.update(probe['channel_groups'][i]['geometry'])
xmin = 0
xmax = 0
ymin = 0
ymax = 0
scaling = 10*numpy.max(numpy.abs(templates[:,temp_id].toarray().reshape(N_e, N_t)))
for i in xrange(N_e):
if positions[i][0] < xmin:
xmin = positions[i][0]
if positions[i][0] > xmax:
xmax = positions[i][0]
if positions[i][1] < ymin:
ymin = positions[i][0]
if positions[i][1] > ymax:
ymax = positions[i][1]
if best_elec is None:
best_elec = clusters['electrodes'][temp_id]
elif best_elec == 'auto':
best_elec = numpy.argmin(numpy.min(templates[:, :, temp_id], 1))
pylab.figure()
for count, i in enumerate(xrange(N_e)):
x, y = positions[i]
xpadding = ((x - xmin)/(float(xmax - xmin) + 1))*(2*N_t)
ypadding = ((y - ymin)/(float(ymax - ymin) + 1))*scaling
if i == best_elec:
c='r'
elif i in inv_nodes[edges[nodes[best_elec]]]:
c='k'
else:
c='0.5'
pylab.plot(xpadding + numpy.arange(0, N_t), ypadding + templates[i, :, temp_id], color=c)
pylab.tight_layout()
pylab.setp(pylab.gca(), xticks=[], yticks=[])
pylab.xlim(xmin, 3*N_t)
pylab.show()
return best_elec
评论列表
文章目录