2929 from dipy .io .utils import nifti1_symmat
3030
3131
32- def tensor_fitting (in_file , bvals , bvecs , mask_file = None )
32+ def tensor_fitting (data , bvals , bvecs , mask_file = None ):
3333 """
3434 Use dipy to fit DTI
3535
3636 Parameters
3737 ----------
3838 in_file : str
39- Full path to a DWI data file
39+ Full path to a DWI data file.
4040 bvals : str
41- Full path to a file containing gradient magnitude information (b-values)
41+ Full path to a file containing gradient magnitude information (b-values).
4242 bvecs : str
43- Full path to a file containing gradient direction information (b-vectors)
43+ Full path to a file containing gradient direction information (b-vectors).
4444 mask_file : str, optional
4545 Full path to a file containing a binary mask. Defaults to use the entire volume.
4646
4747 Returns
4848 -------
49- TensorFit object
49+ TensorFit object, affine
5050 """
51- img = nb .load (in_file )
51+ img = nb .load (in_file ). get_data ()
5252 data = img .get_data ()
5353 affine = img .get_affine ()
5454 if mask_file is not None :
@@ -58,11 +58,10 @@ def tensor_fitting(in_file, bvals, bvecs, mask_file=None)
5858
5959 # Load information about the gradients:
6060 gtab = grad .gradient_table (self .inputs .bvals , self .inputs .bvecs )
61- gtab .bvals = bvals
6261
6362 # Fit it
6463 tenmodel = dti .TensorModel (gtab )
65- return tenmodel .fit (data , mask )
64+ return tenmodel .fit (data , mask ), affine
6665
6766
6867class DTIInputSpec (TraitedSpec ):
@@ -90,19 +89,21 @@ class DTI(BaseInterface):
9089 -------
9190
9291 >>> import nipype.interfaces.dipy as dipy
93- >>> mode = dipy.DTI()
94- >>> mode .inputs.in_file = 'diffusion.nii'
95- >>> mode .inputs.bvecs = 'bvecs'
96- >>> mode .inputs.bvals = 'bvals'
97- >>> mode .inputs.mask_file = 'wm_mask.nii'
98- >>> mode .run() # doctest: +SKIP
92+ >>> dti = dipy.DTI()
93+ >>> dti .inputs.in_file = 'diffusion.nii'
94+ >>> dti .inputs.bvecs = 'bvecs'
95+ >>> dti .inputs.bvals = 'bvals'
96+ >>> dti .inputs.mask_file = 'wm_mask.nii'
97+ >>> dti .run() # doctest: +SKIP
9998 """
10099 input_spec = DTIInputSpec
101100 output_spec = DTIOutputSpec
102101
103102 def _run_interface (self , runtime ):
104- ten_fit = tensor_fitting (self .inputs .in_file , self .inputs .bvals , self .inputs .bvecs ,
105- self .inputs .mask_file )
103+ ten_fit , affine = tensor_fitting (self .inputs .in_file ,
104+ self .inputs .bvals ,
105+ self .inputs .bvecs ,
106+ self .inputs .mask_file )
106107 lower_triangular = tenfit .lower_triangular ()
107108 img = nifti1_symmat (lower_triangular , affine )
108109 out_file = op .abspath (self ._gen_outfilename ())
0 commit comments