docs: def fmap_info(metadata, img, config, layout):
      """
      Generate a paragraph describing field map acquisition information.
  
      Parameters
      ----------
      metadata : :obj:`dict`
          Data from the json file associated with the field map, in dictionary
          form.
      img : :obj:`nibabel.Nifti1Image`
          The nifti image of the field map.
      config : :obj:`dict`
          A dictionary with relevant information regarding sequences, sequence
          variants, phase encoding directions, and task names.
  
      Returns
      -------
      desc : :obj:`str`
          A description of the field map's acquisition information.
      """
      dir_ = config['dir'][metadata['PhaseEncodingDirection']]
      n_slices, vs_str, ms_str, fov_str = get_sizestr(img)
      seqs, variants = get_seqstr(config, metadata)
  
      if 'EchoTime' in metadata.keys():
          te = num_to_str(metadata['EchoTime']*1000)
      else:
          te = 'UNKNOWN'
  
      if 'IntendedFor' in metadata.keys():
          scans = metadata['IntendedFor']
          run_dict = {}
          for scan in scans:
              fn = basename(scan)
              iff_file = [f for f in layout.get(extensions='nii.gz') if fn in f.path][0]
              run_num = int(iff_file.run)
              ty = iff_file.entities['suffix'].upper()
              if ty == 'BOLD':
                  iff_meta = layout.get_metadata(iff_file.path)
                  task = iff_meta.get('TaskName', iff_file.entities['task'])
                  ty_str = '{0} {1} scan'.format(task, ty)
              else:
                  ty_str = '{0} scan'.format(ty)
  
              if ty_str not in run_dict.keys():
                  run_dict[ty_str] = []
              run_dict[ty_str].append(run_num)
  
          for scan in run_dict.keys():
              run_dict[scan] = [num2words(r, ordinal=True) for r in sorted(run_dict[scan])]
  
          out_list = []
          for scan in run_dict.keys():
              if len(run_dict[scan]) > 1:
                  s = 's'
              else:
                  s = ''
              run_str = list_to_str(run_dict[scan])
              string = '{rs} run{s} of the {sc}'.format(rs=run_str,
                                                        s=s,
                                                        sc=scan)
              out_list.append(string)
          for_str = ' for the {0}'.format(list_to_str(out_list))
      else:
          for_str = ''
  
      desc = '''
             A {variants} {seqs} field map (phase encoding:
             {dir_}; {n_slices} slices; repetition time, TR={tr}ms;
             echo time, TE={te}ms; flip angle, FA={fa}<deg>;
             field of view, FOV={fov}mm; matrix size={ms};
             voxel size={vs}mm) was acquired{for_str}.
             '''.format(variants=variants,
                        seqs=seqs,
                        dir_=dir_,
                        for_str=for_str,
                        n_slices=n_slices,
                        tr=num_to_str(metadata['RepetitionTime']*1000),
                        te=te,
                        fa=metadata.get('FlipAngle', 'UNKNOWN'),
                        vs=vs_str,
                        fov=fov_str,
                        ms=ms_str)
      desc = desc.replace('\n', ' ').lstrip()
      while '  ' in desc:
          desc = desc.replace('  ', ' ')
  
      return desc