docstr: Generalized Q-Sampling Imaging [1]_
  
  This model has the same assumptions as the DSI method i.e. Cartesian
  grid sampling in q-space and fast gradient switching.
  
  Implements equations 2.14 from [2]_ for standard GQI and equation 2.16
  from [2]_ for GQI2. You can think of GQI2 as an analytical solution of
  the DSI ODF.
  
  Parameters
  ----------
  gtab : object,
      GradientTable
  method : str,
      'standard' or 'gqi2'
  sampling_length : float,
      diffusion sampling length (lambda in eq. 2.14 and 2.16)
  
  References
  ----------
  .. [1] Yeh F-C et al., "Generalized Q-Sampling Imaging", IEEE TMI, 2010
  
  .. [2] Garyfallidis E, "Towards an accurate brain tractography", PhD
  thesis, University of Cambridge, 2012.
  
  Notes
  -----
  As of version 0.9, range of the sampling length in GQI2 has changed
  to match the same scale used in the 'standard' method [1]_. This
  means that the value of `sampling_length` should be approximately
  1 - 1.3 (see [1]_, pg. 1628).
  
  Examples
  --------
  Here we create an example where we provide the data, a gradient table
  and a reconstruction sphere and calculate the ODF for the first
  voxel in the data.
  
  >>> from dipy.data import dsi_voxels
  >>> data, gtab = dsi_voxels()
  >>> from dipy.core.subdivide_octahedron import create_unit_sphere
  >>> sphere = create_unit_sphere(5)
  >>> from dipy.reconst.gqi import GeneralizedQSamplingModel
  >>> gq = GeneralizedQSamplingModel(gtab, 'gqi2', 1.1)
  >>> voxel_signal = data[0, 0, 0]
  >>> odf = gq.fit(voxel_signal).odf(sphere)
  
  See Also
  --------
  dipy.reconst.dsi.DiffusionSpectrumModel
docstr_tok: ["Generalized","Q-Sampling","Imaging","[","1","]","_","This","model","has","the","same","assumptions","as","the","DSI","method","i.e",".","Cartesian","grid","sampling","in","q-space","and","fast","gradient","switching",".","Implements","equations","2.14","from","[","2","]","_","for","standard","GQI","and","equation","2.16","from","[","2","]","_","for","GQI2",".","You","can","think","of","GQI2","as","an","analytical","solution","of","the","DSI","ODF",".","Parameters","--","--","--","--","--","gtab",":","object",",","GradientTable","method",":","str",",","'standard","'","or","'gqi2'","sampling_length",":","float",",","diffusion","sampling","length","(","lambda","in","eq",".","2.14","and","2.16",")","References","--","--","--","--","--","..","[","1","]","Yeh","F-C","et","al.",",","``","Generalized","Q-Sampling","Imaging","''",",","IEEE","TMI",",","2010","..","[","2","]","Garyfallidis","E",",","``","Towards","an","accurate","brain","tractography","''",",","PhD","thesis",",","University","of","Cambridge",",","2012",".","Notes","--","--","-","As","of","version","0.9",",","range","of","the","sampling","length","in","GQI2","has","changed","to","match","the","same","scale","used","in","the","'standard","'","method","[","1","]","_",".","This","means","that","the","value","of","`","sampling_length","`","should","be","approximately","1","-","1.3","(","see","[","1","]","_",",","pg",".","1628",")",".","Examples","--","--","--","--","Here","we","create","an","example","where","we","provide","the","data",",","a","gradient","table","and","a","reconstruction","sphere","and","calculate","the","ODF","for","the","first","voxel","in","the","data",".",">",">",">","from","dipy.data","import","dsi_voxels",">",">",">","data",",","gtab","=","dsi_voxels","(",")",">",">",">","from","dipy.core.subdivide_octahedron","import","create_unit_sphere",">",">",">","sphere","=","create_unit_sphere","(","5",")",">",">",">","from","dipy.reconst.gqi","import","GeneralizedQSamplingModel",">",">",">","gq","=","GeneralizedQSamplingModel","(","gtab",",","'gqi2","'",",","1.1",")",">",">",">","voxel_signal","=","data","[","0",",","0",",","0","]",">",">",">","odf","=","gq.fit","(","voxel_signal",")",".odf","(","sphere",")","See","Also","--","--","--","--","dipy.reconst.dsi.DiffusionSpectrumModel"]
code: def __init__(
      self,
      gtab,
      method="gqi2",
      sampling_length=1.2,
      normalize_peaks=False,
  ):
      r"""Generalized Q-Sampling Imaging [1]_
  
      This model has the same assumptions as the DSI method i.e. Cartesian
      grid sampling in q-space and fast gradient switching.
  
      Implements equations 2.14 from [2]_ for standard GQI and equation 2.16
      from [2]_ for GQI2. You can think of GQI2 as an analytical solution of
      the DSI ODF.
  
      Parameters
      ----------
      gtab : object,
          GradientTable
      method : str,
          'standard' or 'gqi2'
      sampling_length : float,
          diffusion sampling length (lambda in eq. 2.14 and 2.16)
  
      References
      ----------
      .. [1] Yeh F-C et al., "Generalized Q-Sampling Imaging", IEEE TMI, 2010
  
      .. [2] Garyfallidis E, "Towards an accurate brain tractography", PhD
      thesis, University of Cambridge, 2012.
  
      Notes
      -----
      As of version 0.9, range of the sampling length in GQI2 has changed
      to match the same scale used in the 'standard' method [1]_. This
      means that the value of `sampling_length` should be approximately
      1 - 1.3 (see [1]_, pg. 1628).
  
      Examples
      --------
      Here we create an example where we provide the data, a gradient table
      and a reconstruction sphere and calculate the ODF for the first
      voxel in the data.
  
      >>> from dipy.data import dsi_voxels
      >>> data, gtab = dsi_voxels()
      >>> from dipy.core.subdivide_octahedron import create_unit_sphere
      >>> sphere = create_unit_sphere(5)
      >>> from dipy.reconst.gqi import GeneralizedQSamplingModel
      >>> gq = GeneralizedQSamplingModel(gtab, 'gqi2', 1.1)
      >>> voxel_signal = data[0, 0, 0]
      >>> odf = gq.fit(voxel_signal).odf(sphere)
  
      See Also
      --------
      dipy.reconst.dsi.DiffusionSpectrumModel
  
      """
      OdfModel.__init__(self, gtab)
      self.method = method
      self.Lambda = sampling_length
      self.normalize_peaks = normalize_peaks
      # 0.01506 = 6*D where D is the free water diffusion coefficient
      # l_values sqrt(6 D tau) D free water diffusion coefficient and
      # tau included in the b-value
      scaling = np.sqrt(self.gtab.bvals * 0.01506)
      tmp = np.tile(scaling, (3, 1))
      gradsT = self.gtab.bvecs.T
      b_vector = gradsT * tmp  # element-wise product
      self.b_vector = b_vector.T
  
imports: import numpy
  from dipy.reconst.odf import OdfModel, OdfFit
  from dipy.reconst.cache import Cache
  import warnings
  from dipy.reconst.multi_voxel import multi_voxel_fit
label_desc: Use image node_id 1 to create a new GeneralizedQSamplingModel object from inherited base classes: OdfModel, Cache with example: obj = GeneralizedQSamplingModel(gtab, method, sampling_length, normalize_peaks)