def get_svs(mat, bg_mat, sv_region, window_size, rolling=0):
if rolling > 0:
weights = numpy.ones((rolling*2+1, rolling*2+1))
mat = ndimage.convolve(mat, weights, mode="constant")
bg_mat = ndimage.convolve(bg_mat, weights, mode="constant")
norm = mat/bg_mat
norm[numpy.isnan(norm)] = 0
norm = numpy.ma.masked_array(norm, mask=False)
breakpoints = []
while not norm.mask.all():
where = numpy.ma.where(norm==norm.max())
where = (where[0][0], where[1][0])
is_good = (mat[where] > 25 and norm[where] > 0.05)
if is_good:
breakpoint = (where[1]*window_size + sv_region["startx"],
where[0]*window_size + sv_region["starty"])
breakpoints.append(breakpoint)
# TODO: constant for extend; this determines the closest
# any two breakpoints can be from one another
norm.mask[get_matrix_rect(norm, where, 10)] = True
else:
break
return breakpoints
评论列表
文章目录