docstr: Calculates the analytical mean squared displacement (MSD) [1]_
  
  ..math::
      :nowrap:
          \begin{equation}
              MSD:{DSI}=\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}
              \int_{-\infty}^{\infty} P(\hat{\mathbf{r}}) \cdot
              \hat{\mathbf{r}}^{2} \ dr_x \ dr_y \ dr_z
          \end{equation}
  
  where $\hat{\mathbf{r}}$ is a point in the 3D propagator space (see Wu
  et al. [1]_).
  
  References
  ----------
  .. [1] Wu Y. et al., "Hybrid diffusion imaging", NeuroImage, vol 36,
  p. 617-629, 2007.
docstr_tok: ["Calculates","the","analytical","mean","squared","displacement","(","MSD",")","[","1","]","_","..","math",":",":",":","nowrap",":","\\begin","{","equation","}","MSD",":","{","DSI","}","=\\int_","{","-\\infty","}","^","{","\\infty","}","\\int_","{","-\\infty","}","^","{","\\infty","}","\\int_","{","-\\infty","}","^","{","\\infty","}","P","(","\\hat","{","\\mathbf","{","r","}","}",")","\\cdot","\\hat","{","\\mathbf","{","r","}","}","^","{","2","}","\\","dr_x","\\","dr_y","\\","dr_z","\\end","{","equation","}","where","$","\\hat","{","\\mathbf","{","r","}","}","$","is","a","point","in","the","3D","propagator","space","(","see","Wu","et","al",".","[","1","]","_",")",".","References","--","--","--","--","--","..","[","1","]","Wu","Y.","et","al.",",","``","Hybrid","diffusion","imaging","''",",","NeuroImage",",","vol","36",",","p.","617-629",",","2007","."]
code: def msd(self):
      r"""Calculates the analytical mean squared displacement (MSD) [1]_
  
      ..math::
          :nowrap:
              \begin{equation}
                  MSD:{DSI}=\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}
                  \int_{-\infty}^{\infty} P(\hat{\mathbf{r}}) \cdot
                  \hat{\mathbf{r}}^{2} \ dr_x \ dr_y \ dr_z
              \end{equation}
  
      where $\hat{\mathbf{r}}$ is a point in the 3D propagator space (see Wu
      et al. [1]_).
  
      References
      ----------
      .. [1] Wu Y. et al., "Hybrid diffusion imaging", NeuroImage, vol 36,
      p. 617-629, 2007.
      """
      msd = 0
      c = self._shore_coef
  
      for n in range(int(self.radial_order / 2) + 1):
          msd += (
              c[n]
              * (-1) ** n
              * (
                  9
                  * (gamma(n + 1.5))
                  / (8 * np.pi**6 * self.zeta**3.5 * factorial(n))
              )
              ** 0.5
              * hyp2f1(-n, 2.5, 1.5, 2)
          )
  
      return np.clip(msd, 0, msd.max())
  
imports: from warnings import warn
  from math import factorial
  import numpy
  from scipy.special import genlaguerre, gamma, hyp2f1
  from dipy.reconst.cache import Cache
  from dipy.reconst.multi_voxel import multi_voxel_fit
  from dipy.reconst.shm import real_sh_descoteaux_from_index
  from dipy.core.geometry import cart2sphere
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 8 for calling the ShoreFit obj's underlying member method code with example usage: obj.msd() and returns: np