<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def slice_image(image, axis=None, idx=None):
 """ Slice an image. Example ------- """

    if image.dimension < 3:
        raise ValueError('image must have at least 3 dimensions')

    inpixeltype = image.pixeltype
    ndim = image.dimension
    if image.pixeltype != 'float':
        image = image.clone('float')

    libfn = utils.get_lib_fn('sliceImageF%i' % ndim)
    itkimage = libfn(image.pointer, axis, idx)

    return iio.ANTsImage(pixeltype='float', dimension=ndim-1, 
                         components=image.components, pointer=itkimage).clone(inpixeltype)