code: def test_specific_reduce():
      shape = (3, 5, 7, 9)
      x = np.random.standard_normal(shape)
      im = Image(x, AT(CS("ijkq"), MNI4, np.diag([3, 4, 5, 6, 1])))
      # we have to rename the axis before we can call the function
      # need_specific_axis_reduce on it
      pytest.raises(
          AxisError, need_specific_axis_reduce, im, lambda x: x.sum(0)
      )
      im = im.renamed_axes(q="specific")
      newim = need_specific_axis_reduce(im, lambda x: x.sum(0))
      assert_array_equal(xyz_affine(im), xyz_affine(newim))
      assert newim.axes.coord_names == tuple("ijk")
      assert newim.shape == (3, 5, 7)
      assert_almost_equal(newim.get_fdata(), x.sum(3))
  
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 6 for calling a global function with example usage: test_specific_reduce() without return types