class_docstr: Calculates the diffusion tensor model parameters
  
  Example
  -------
  
  >>> import nipype.interfaces.dipy as dipy
  >>> dti = dipy.DTI()
  >>> dti.inputs.in_file = 'diffusion.nii'
  >>> dti.inputs.in_bvec = 'bvecs'
  >>> dti.inputs.in_bval = 'bvals'
  >>> dti.run()                                   # doctest: +SKIP
class_docstr_tok: ["Calculates","the","diffusion","tensor","model","parameters","Example","--","--","--","-",">",">",">","import","nipype.interfaces.dipy","as","dipy",">",">",">","dti","=","dipy.DTI","(",")",">",">",">","dti.inputs.in_file","=","'diffusion.nii'",">",">",">","dti.inputs.in_bvec","=","'bvecs'",">",">",">","dti.inputs.in_bval","=","'bvals'",">",">",">","dti.run","(",")","#","doctest",":","+SKIP"]
code: def _run_interface(self, runtime):
      from dipy.reconst import dti
      from dipy.io.utils import nifti1_symmat
  
      gtab = self._get_gradient_table()
  
      img = nb.load(self.inputs.in_file)
      data = img.get_fdata()
      affine = img.affine
      mask = None
      if isdefined(self.inputs.mask_file):
          mask = np.asanyarray(nb.load(self.inputs.mask_file).dataobj)
  
      # Fit it
      tenmodel = dti.TensorModel(gtab)
      ten_fit = tenmodel.fit(data, mask)
      lower_triangular = ten_fit.lower_triangular()
      img = nifti1_symmat(lower_triangular, affine)
      out_file = self._gen_filename("dti")
      nb.save(img, out_file)
      IFLOGGER.info("DTI parameters image saved as %s", out_file)
  
      # FA MD RD and AD
      for metric in ["fa", "md", "rd", "ad", "color_fa"]:
          data = getattr(ten_fit, metric).astype("float32")
          out_name = self._gen_filename(metric)
          nb.Nifti1Image(data, affine).to_filename(out_name)
          IFLOGGER.info("DTI %s image saved as %s", metric, out_name)
  
      return runtime
  
imports: import numpy
  import nibabel
  from ...None import logging
  from ..base import TraitedSpec, File, isdefined
  from .base import DipyDiffusionInterface, DipyBaseInterfaceInputSpec
label_desc: Use image node_id 1 for calling the DTI obj's underlying member method code with example usage: obj._run_interface(runtime) and returns: runtime