code: def gfa(samples):
      r"""The general fractional anisotropy of a function evaluated
      on the unit sphere
  
      Parameters
      ----------
      samples : ndarray
          Values of data on the unit sphere.
  
      Returns
      -------
      gfa : ndarray
          GFA evaluated in each entry of the array, along the last dimension.
          An `np.nan` is returned for coordinates that contain all-zeros in
          `samples`.
  
      Notes
      -----
      The GFA is defined as [1]_ ::
  
          \sqrt{\frac{n \sum_i{(\Psi_i - <\Psi>)^2}}{(n-1) \sum{\Psi_i ^ 2}}}
  
      Where $\Psi$ is an orientation distribution function sampled discretely on
      the unit sphere and angle brackets denote average over the samples on the
      sphere.
  
      .. [1] Quality assessment of High Angular Resolution Diffusion Imaging
             data using bootstrap on Q-ball reconstruction. J. Cohen Adad, M.
             Descoteaux, L.L. Wald. JMRI 33: 1194-1208.
      """
      diff = samples - samples.mean(-1)[..., None]
      n = samples.shape[-1]
      numer = np.array([n * (diff**2).sum(-1)])
      denom = np.array([(n - 1) * (samples**2).sum(-1)])
      result = np.ones_like(denom) * np.nan
      idx = np.where(denom > 0)
      result[idx] = np.sqrt(numer[idx] / denom[idx])
      return result.squeeze()
  
file_path: dipy/dipy/reconst/odf.py
imports: from dipy.reconst.base import ReconstModel, ReconstFit
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: gfa(samples) and returns: result