code: def image_reduce(img, reduce_op, axis="t"):
      """
      Take an Image, perform some reduce operation on it, over
      a specified axis, and return a new Image.
  
      For the sake of testing things out, we will assume that
      the operation reduces over the first axis only.
  
      Parameters
      ----------
      image : Image
      reduce_op : callable
          An operation that reduces over the first axis,
          such as lambda x: x.sum(0)
      axis : str or int
          Specification of axis of Image
  
      Returns
      -------
      newim : Image, missing axis
      """
      img = rollimg(img, axis)
      axis_name = img.axes.coord_names[0]
      output_axes = list(img.axes.coord_names)
      output_axes.remove(axis_name)
      newdata = reduce_op(img.get_fdata())
      return Image(newdata, drop_io_dim(img.coordmap, axis))
  
file_path: nipy/nipy/core/image/tests/test_rollimg.py
imports: import numpy
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_equal
  from ...image.image_spaces import xyz_affine
  from ...reference.coordinate_map import AffineTransform
  from ...reference.coordinate_map import AxisError, drop_io_dim
  from ...reference.coordinate_system import CoordinateSystem
  from ...reference.spaces import mni_csm
  from ..image import Image, rollimg, synchronized_order
label_desc: Use image node_id 1 for calling a global function with example usage: image_reduce(img, reduce_op, axis) and returns: Image