code: def _index_img(img, index):
      from ..image import new_img_like  # avoid circular imports
  
      """Helper function for check_niimg_4d."""
      return new_img_like(
          img,
          _get_data(img)[:, :, :, index],
          img.affine,
          copy_header=True,
      )
  
file_path: nilearn/nilearn/_utils/niimg_conversions.py
imports: import glob
  import itertools
  import os.path
  import warnings
  import numpy
  from joblib import Memory
  import nilearn
  from .cache_mixin import cache
  from .exceptions import DimensionError
  from .helpers import stringify_path
  from .niimg import _get_data, load_niimg, safe_get_data
  from .path_finding import resolve_globbing
label_desc: Use image node_id 3 for calling a global function with example usage: _index_img(img, index) and returns: new_img_like