def pos2idx(pos, image_size):
	"""
	Given a position in the 3D image space, return a flattened idx.

	Args:

		pos (list of 3 int):		Position in 3D volume
		image_size (list of 3 int):	Size of 3D volume
	"""
	assert(len(pos)==3)
	assert(len(image_size)==3)

	return (pos[0] * image_size[1]*image_size[2]) + (pos[1] * image_size[2]) + pos[2];