code: def peaks_to_niftis(
      pam,
      fname_shm,
      fname_dirs,
      fname_values,
      fname_indices,
      fname_gfa,
      reshape_dirs=False,
  ):
      """Save SH, directions, indices and values of peaks to Nifti."""
  
      save_nifti(
          fname_shm, pam.shm_coeff.astype(np.float32), pam.affine
      )
  
      if reshape_dirs:
          pam_dirs = reshape_peaks_for_visualization(pam)
      else:
          pam_dirs = pam.peak_dirs.astype(np.float32)
  
      save_nifti(fname_dirs, pam_dirs, pam.affine)
  
      save_nifti(
          fname_values, pam.peak_values.astype(np.float32), pam.affine
      )
  
      save_nifti(fname_indices, pam.peak_indices, pam.affine)
  
      save_nifti(fname_gfa, pam.gfa, pam.affine)
  
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 4 for calling a global function with example usage: peaks_to_niftis(pam, fname_shm, fname_dirs, fname_values, fname_indices, fname_gfa, reshape_dirs) without return types