<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def new_image_like(self, data):
 """ Create a new ANTsImage with the same header information, but with a new image array. Arguments --------- data : ndarray or py::capsule New array or pointer for the image. It must have the same shape as the current image data. Returns ------- ANTsImage """

        if not isinstance(data, np.ndarray):
            raise ValueError('data must be a numpy array')
        if not self.has_components:
            if data.shape != self.shape:
                raise ValueError('given array shape (%s) and image array shape (%s) do not match' % (data.shape, self.shape))
        else:
            if (data.shape[-1] != self.components) or (data.shape[:-1] != self.shape):
                raise ValueError('given array shape (%s) and image array shape (%s) do not match' % (data.shape[1:], self.shape))

        return iio2.from_numpy(data, origin=self.origin, 
            spacing=self.spacing, direction=self.direction, 
            has_components=self.has_components)