def slices_from_global_coords(self, slices):
"""
Used for converting from mip 0 coordinates to upper mip level
coordinates. This is mainly useful for debugging since the neuroglancer
client displays the mip 0 coordinates for your cursor.
"""
maxsize = list(self.mip_volume_size(0)) + [ self.num_channels ]
minsize = list(self.mip_voxel_offset(0)) + [ 0 ]
slices = generate_slices(slices, minsize, maxsize)[:3]
lower = Vec(*map(lambda x: x.start, slices))
upper = Vec(*map(lambda x: x.stop, slices))
step = Vec(*map(lambda x: x.step, slices))
lower /= self.downsample_ratio
upper /= self.downsample_ratio
signs = step / np.absolute(step)
step = signs * max2(np.absolute(step / self.downsample_ratio), Vec(1,1,1))
step = Vec(*np.round(step))
return [
slice(lower.x, upper.x, step.x),
slice(lower.y, upper.y, step.y),
slice(lower.z, upper.z, step.z)
]
评论列表
文章目录