def binarize_top(m,q): threshold=mquantiles(np.triu(m).flatten(),q) new_m=copy.deepcopy(m) new_m[new_m<threshold]=0 new_m[new_m>=threshold]=1 return get_sqrtvc(new_m)