code: def test_iterate_over_image():
      # Fit a model, iterating over the slices of an array
      # associated to an FmriImage.
      c = np.zeros(FDATA.shape[1:]) + 0.5
      res_gen = result_generator(
          flatten_generator(axis0_generator(FDATA))
      )
      write_data(c, unflatten_generator(contrast_generator(res_gen)))
      # Fit a model, iterating over the array associated to an
      # FmriImage, iterating over a list of ROIs defined by binary
      # regions of the same shape as a frame of FmriImage
  
      # this might really be an anatomical image or AR(1) coefficients
      a = np.asarray(FDATA[0])
      p = np.greater(a, a.mean())
      d = np.ones(FDATA.shape[1:]) * 2.0
      flat_gen = flatten_generator(axis0_generator(FDATA, parcels(p)))
      write_data(d, contrast_generator(result_generator(flat_gen)))
      assert_array_almost_equal(d, c)
  
      e = np.zeros(FDATA.shape[1:]) + 3.0
      flat_gen2 = flatten_generator(axis0_generator(FDATA, parcels(p)))
      write_data(e, f_generator(contrast, result_generator(flat_gen2)))
      assert_array_almost_equal(d, e)
  
file_path: nipy/nipy/modalities/fmri/fmristat/tests/test_iterables.py
imports: import numpy
  from numpy.random import standard_normal
  from numpy.testing import assert_array_almost_equal
  from nipy.algorithms.statistics.models.regression import OLSModel
  from nipy.core.image.image import rollimg
  from nipy.core.utils.generators import f_generator, parcels, write_data
  from nipy.io.api import load_image
  from nipy.modalities.fmri.api import FmriImageList, axis0_generator
  from nipy.testing import funcfile
label_desc: Use image node_id 7 for calling a global function with example usage: test_iterate_over_image() without return types