code: def is_binary_niimg(niimg):
      """Return whether a given niimg is binary or not.
  
      Parameters
      ----------
      niimg: Niimg-like object
          See :ref:`extracting_data`.
          Image to test.
  
      Returns
      -------
      is_binary: Boolean
          True if binary, False otherwise.
  
      """
      niimg = load_niimg(niimg)
      data = safe_get_data(niimg, ensure_finite=True)
      unique_values = np.unique(data)
      if len(unique_values) != 2:
          return False
      return sorted(list(unique_values)) == [0, 1]
  
file_path: nilearn/nilearn/_utils/niimg.py
imports: import collections.abc
  import copy
  import gc
  from pathlib import Path
  from warnings import warn
  import nibabel
  import numpy
  from .helpers import stringify_path
label_desc: Use image node_id 5 for calling a global function with example usage: is_binary_niimg(niimg) and returns: unknown, False