code: def load_peaks(fname, verbose=False):
      """Load a PeaksAndMetrics HDF5 file (PAM5)
  
      Parameters
      ----------
      fname : string
          Filename of PAM5 file.
      verbose : bool
          Print summary information about the loaded file.
  
      Returns
      -------
      pam : PeaksAndMetrics object
      """
  
      if os.path.splitext(fname)[1].lower() != ".pam5":
          raise OSError("This function supports only PAM5 (HDF5) files")
  
      f = h5py.File(fname, "r")
  
      pam = PeaksAndMetrics()
  
      pamh = f["pam"]
  
      version = f.attrs["version"]
  
      if version != "0.0.1":
          raise OSError(
              "Incorrect PAM5 file version {0}".format(
                  version,
              )
          )
  
      try:
          affine = pamh["affine"][:]
      except KeyError:
          affine = None
  
      peak_dirs = pamh["peak_dirs"][:]
      peak_values = pamh["peak_values"][:]
      peak_indices = pamh["peak_indices"][:]
  
      try:
          shm_coeff = pamh["shm_coeff"][:]
      except KeyError:
          shm_coeff = None
  
      sphere_vertices = pamh["sphere_vertices"][:]
  
      try:
          odf = pamh["odf"][:]
      except KeyError:
          odf = None
  
      pam.affine = affine
      pam.peak_dirs = peak_dirs
      pam.peak_values = peak_values
      pam.peak_indices = peak_indices
      pam.shm_coeff = shm_coeff
      pam.sphere = Sphere(xyz=sphere_vertices)
      pam.B = pamh["B"][:]
      pam.total_weight = pamh["total_weight"][:][0]
      pam.ang_thr = pamh["ang_thr"][:][0]
      pam.gfa = pamh["gfa"][:]
      pam.qa = pamh["qa"][:]
      pam.odf = odf
  
      f.close()
  
      if verbose:
          print("PAM5 version")
          print(version)
          print("Affine")
          print(pam.affine)
          print("Dirs shape")
          print(pam.peak_dirs.shape)
          print("SH shape")
          if pam.shm_coeff is not None:
              print(pam.shm_coeff.shape)
          else:
              print("None")
          print("ODF shape")
          if pam.odf is not None:
              print(pam.odf.shape)
          else:
              print("None")
          print("Total weight")
          print(pam.total_weight)
          print("Angular threshold")
          print(pam.ang_thr)
          print("Sphere vertices shape")
          print(pam.sphere.vertices.shape)
  
      return pam
  
file_path: dipy/dipy/io/peaks.py
imports: import os
  import numpy
  from dipy.direction.peaks import PeaksAndMetrics, reshape_peaks_for_visualization
  from dipy.core.sphere import Sphere
  from dipy.io.image import save_nifti
  import h5py
label_desc: Use image node_id 2 for calling a global function with example usage: load_peaks(fname, verbose) and returns: pam