code: def display_diff(files, diff):
      """Format header differences into a nice string
  
      Parameters
      ----------
      files: list of files that were compared so we can print their names
      diff: dict of different valued header fields
  
      Returns
      -------
      str
        string-formatted table of differences
      """
      output = ""
      field_width = "{:<15}"
      filename_width = "{:<53}"
      value_width = "{:<55}"
  
      output += "These files are different.\n"
      output += field_width.format("Field/File")
  
      for i, f in enumerate(files, 1):
          output += "%d:%s" % (
              i,
              filename_width.format(os.path.basename(f)),
          )
  
      output += "\n"
  
      for key, value in diff.items():
          output += field_width.format(key)
  
          for item in value:
              if isinstance(item, dict):
                  item_str = ", ".join(
                      "%s: %s" % i for i in item.items()
                  )
              elif item is None:
                  item_str = "-"
              else:
                  item_str = str(item)
              # Value might start/end with some invisible spacing characters so we
              # would "condition" it on both ends a bit
              item_str = re.sub("^[ \t]+", "<", item_str)
              item_str = re.sub("[ \t]+$", ">", item_str)
              # and also replace some other invisible symbols with a question
              # mark
              item_str = re.sub("[\x00]", "?", item_str)
              output += value_width.format(item_str)
  
          output += "\n"
  
      return output
  
file_path: nibabel/nibabel/cmdline/diff.py
imports: import hashlib
  import os
  import re
  import sys
  from collections import OrderedDict
  from optparse import Option, OptionParser
  import numpy
  import nibabel
  import nibabel.cmdline.utils
label_desc: Use image node_id 6 for calling a global function with example usage: display_diff(files, diff) and returns: output