docstr: Diffusion Spectrum Deconvolution
  
  The idea is to remove the convolution on the DSI propagator that is
  caused by the truncation of the q-space in the DSI sampling.
  
  ..math::
      :nowrap:
          \begin{eqnarray*}
              P_{dsi}(\mathbf{r}) & = & S_{0}^{-1}\iiint\limits_{\| \mathbf{q} \| \le \mathbf{q_{max}}} S(\mathbf{q})\exp(-i2\pi\mathbf{q}\cdot\mathbf{r})d\mathbf{q} \\
              & = & S_{0}^{-1}\iiint\limits_{\mathbf{q}} \left( S(\mathbf{q}) \cdot M(\mathbf{q}) \right) \exp(-i2\pi\mathbf{q}\cdot\mathbf{r})d\mathbf{q} \\
              & = & P(\mathbf{r}) \otimes \left( S_{0}^{-1}\iiint\limits_{\mathbf{q}}  M(\mathbf{q}) \exp(-i2\pi\mathbf{q}\cdot\mathbf{r})d\mathbf{q} \right) \\
          \end{eqnarray*}
  
  where $\mathbf{r}$ is the displacement vector and $\mathbf{q}$ is the
  wave vector which corresponds to different gradient directions,
  $M(\mathbf{q})$ is a mask corresponding to your q-space sampling and
  $\otimes$ is the convolution operator [1]_.
  
  
  Parameters
  ----------
  gtab : GradientTable,
      Gradient directions and bvalues container class
  qgrid_size : int,
      has to be an odd number. Sets the size of the q_space grid.
      For example if qgrid_size is 35 then the shape of the grid will be
      ``(35, 35, 35)``.
  r_start : float,
      ODF is sampled radially in the PDF. This parameters shows where the
      sampling should start.
  r_end : float,
      Radial endpoint of ODF sampling
  r_step : float,
      Step size of the ODf sampling from r_start to r_end
  filter_width : float,
      Strength of the hanning filter
  
  References
  ----------
  .. [1] Canales-Rodriguez E.J et al., "Deconvolution in Diffusion
  Spectrum Imaging", Neuroimage, 2010.
  
  .. [2] Biggs David S.C. et al., "Acceleration of Iterative Image
  Restoration Algorithms", Applied Optics, vol. 36, No. 8, p. 1766-1775,
  1997.
docstr_tok: ["Diffusion","Spectrum","Deconvolution","The","idea","is","to","remove","the","convolution","on","the","DSI","propagator","that","is","caused","by","the","truncation","of","the","q-space","in","the","DSI","sampling",".","..","math",":",":",":","nowrap",":","\\begin","{","eqnarray","*","}","P_","{","dsi","}","(","\\mathbf","{","r","}",")","&","=","&","S_","{","0","}","^","{","-1","}","\\iiint\\limits_","{","\\|","\\mathbf","{","q","}","\\|","\\le","\\mathbf","{","q_","{","max","}","}","}","S","(","\\mathbf","{","q","}",")","\\exp","(","-i2\\pi\\mathbf","{","q","}","\\cdot\\mathbf","{","r","}",")","d\\mathbf","{","q","}","\\\\","&","=","&","S_","{","0","}","^","{","-1","}","\\iiint\\limits_","{","\\mathbf","{","q","}","}","\\left","(","S","(","\\mathbf","{","q","}",")","\\cdot","M","(","\\mathbf","{","q","}",")","\\right",")","\\exp","(","-i2\\pi\\mathbf","{","q","}","\\cdot\\mathbf","{","r","}",")","d\\mathbf","{","q","}","\\\\","&","=","&","P","(","\\mathbf","{","r","}",")","\\otimes","\\left","(","S_","{","0","}","^","{","-1","}","\\iiint\\limits_","{","\\mathbf","{","q","}","}","M","(","\\mathbf","{","q","}",")","\\exp","(","-i2\\pi\\mathbf","{","q","}","\\cdot\\mathbf","{","r","}",")","d\\mathbf","{","q","}","\\right",")","\\\\","\\end","{","eqnarray","*","}","where","$","\\mathbf","{","r","}","$","is","the","displacement","vector","and","$","\\mathbf","{","q","}","$","is","the","wave","vector","which","corresponds","to","different","gradient","directions",",","$","M","(","\\mathbf","{","q","}",")","$","is","a","mask","corresponding","to","your","q-space","sampling","and","$","\\otimes","$","is","the","convolution","operator","[","1","]","_.","Parameters","--","--","--","--","--","gtab",":","GradientTable",",","Gradient","directions","and","bvalues","container","class","qgrid_size",":","int",",","has","to","be","an","odd","number",".","Sets","the","size","of","the","q_space","grid",".","For","example","if","qgrid_size","is","35","then","the","shape","of","the","grid","will","be","``","(","35",",","35",",","35",")","``",".","r_start",":","float",",","ODF","is","sampled","radially","in","the","PDF",".","This","parameters","shows","where","the","sampling","should","start",".","r_end",":","float",",","Radial","endpoint","of","ODF","sampling","r_step",":","float",",","Step","size","of","the","ODf","sampling","from","r_start","to","r_end","filter_width",":","float",",","Strength","of","the","hanning","filter","References","--","--","--","--","--","..","[","1","]","Canales-Rodriguez","E.J","et","al.",",","``","Deconvolution","in","Diffusion","Spectrum","Imaging","''",",","Neuroimage",",","2010",".","..","[","2","]","Biggs","David","S.C.","et","al.",",","``","Acceleration","of","Iterative","Image","Restoration","Algorithms","''",",","Applied","Optics",",","vol",".","36",",","No",".","8",",","p.","1766-1775",",","1997","."]
code: def __init__(
      self,
      gtab,
      qgrid_size=35,
      r_start=4.1,
      r_end=13.0,
      r_step=0.4,
      filter_width=np.inf,
      normalize_peaks=False,
  ):
      r""" Diffusion Spectrum Deconvolution
  
          The idea is to remove the convolution on the DSI propagator that is
          caused by the truncation of the q-space in the DSI sampling.
  
          ..math::
              :nowrap:
                  \begin{eqnarray*}
                      P_{dsi}(\mathbf{r}) & = & S_{0}^{-1}\iiint\limits_{\| \mathbf{q} \| \le \mathbf{q_{max}}} S(\mathbf{q})\exp(-i2\pi\mathbf{q}\cdot\mathbf{r})d\mathbf{q} \\
                      & = & S_{0}^{-1}\iiint\limits_{\mathbf{q}} \left( S(\mathbf{q}) \cdot M(\mathbf{q}) \right) \exp(-i2\pi\mathbf{q}\cdot\mathbf{r})d\mathbf{q} \\
                      & = & P(\mathbf{r}) \otimes \left( S_{0}^{-1}\iiint\limits_{\mathbf{q}}  M(\mathbf{q}) \exp(-i2\pi\mathbf{q}\cdot\mathbf{r})d\mathbf{q} \right) \\
                  \end{eqnarray*}
  
          where $\mathbf{r}$ is the displacement vector and $\mathbf{q}$ is the
          wave vector which corresponds to different gradient directions,
          $M(\mathbf{q})$ is a mask corresponding to your q-space sampling and
          $\otimes$ is the convolution operator [1]_.
  
  
          Parameters
          ----------
          gtab : GradientTable,
              Gradient directions and bvalues container class
          qgrid_size : int,
              has to be an odd number. Sets the size of the q_space grid.
              For example if qgrid_size is 35 then the shape of the grid will be
              ``(35, 35, 35)``.
          r_start : float,
              ODF is sampled radially in the PDF. This parameters shows where the
              sampling should start.
          r_end : float,
              Radial endpoint of ODF sampling
          r_step : float,
              Step size of the ODf sampling from r_start to r_end
          filter_width : float,
              Strength of the hanning filter
  
          References
          ----------
          .. [1] Canales-Rodriguez E.J et al., "Deconvolution in Diffusion
          Spectrum Imaging", Neuroimage, 2010.
  
          .. [2] Biggs David S.C. et al., "Acceleration of Iterative Image
          Restoration Algorithms", Applied Optics, vol. 36, No. 8, p. 1766-1775,
          1997.
  
          """
      DiffusionSpectrumModel.__init__(
          self,
          gtab,
          qgrid_size,
          r_start,
          r_end,
          r_step,
          filter_width,
          normalize_peaks,
      )
  
imports: import numpy
  from scipy.ndimage import map_coordinates
  from scipy.fftpack import fftn, fftshift, ifftshift
  from dipy.reconst.odf import OdfModel, OdfFit
  from dipy.reconst.cache import Cache
  from dipy.reconst.multi_voxel import multi_voxel_fit
label_desc: Use image node_id 1 to create a new DiffusionSpectrumDeconvModel object from inherited base classes: DiffusionSpectrumModel with example: obj = DiffusionSpectrumDeconvModel(gtab, qgrid_size, r_start, r_end, r_step, filter_width, normalize_peaks)