rockverse.voxel_image.VoxelImage.get_closest_voxel_index#

VoxelImage.get_closest_voxel_index(x, y, z, allow_outside=False)[source]#

Get the voxel index closest to a given spatial position.

This method calculates the (i, j, k) indices of the image voxel closest to the specified spatial coordinates (x, y, z).

Parameters:
  • x (float) – The spatial coordinate in the x-direction.

  • y (float) – The spatial coordinate in the y-direction.

  • z (float) – The spatial coordinate in the z-direction.

  • allow_outside (Boolean) – If False (default) return None in case the spatial coordinates point to a region outside the image bounding box. If True, return the the voxel indices even if (x, y, z) falls outside the image bounding box.

Returns:

A tuple containing the voxel indices (i, j, k) corresponding to the specified spatial coordinates (x, y, z), or None.

Return type:

tuple or None