def compute_centralvoxel_frequencies(segment,minlength):
if isinstance(segment,list):
segment = np.asarray(segment)
shape = segment.shape[-3:]
middle_coordinate = np.zeros(3,int)
for it_coordinate,coordinate in enumerate(shape):
if coordinate%2==0:
middle_coordinate[it_coordinate] = coordinate / 2 - 1
else:
middle_coordinate[it_coordinate] = coordinate/2
segment = segment.reshape((-1,) + shape)
f = 1.0 * np.bincount(segment[:,middle_coordinate[0],middle_coordinate[1],middle_coordinate[2]].reshape(-1,).astype(int),minlength=minlength) / np.prod(segment.shape[:-3])
return f
评论列表
文章目录