Skip to content

Commit dab6bba

Browse files
committed
enh: DTI returns fa and stuff
1 parent c46b932 commit dab6bba

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

nipype/interfaces/dipy/tensors.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class DTIInputSpec(DipyBaseInterfaceInputSpec):
2121

2222
class DTIOutputSpec(TraitedSpec):
2323
out_file = File(exists=True)
24+
fa_file = File(exists=True)
25+
md_file = File(exists=True)
26+
rd_file = File(exists=True)
27+
ad_file = File(exists=True)
2428

2529

2630
class DTI(DipyDiffusionInterface):
@@ -55,16 +59,28 @@ def _run_interface(self, runtime):
5559
# Fit it
5660
tenmodel = dti.TensorModel(gtab)
5761
ten_fit = tenmodel.fit(data, mask)
58-
lower_triangular = tenfit.lower_triangular()
62+
lower_triangular = ten_fit.lower_triangular()
5963
img = nifti1_symmat(lower_triangular, affine)
6064
out_file = self._gen_filename('dti')
6165
nb.save(img, out_file)
6266
IFLOGGER.info('DTI parameters image saved as {i}'.format(i=out_file))
67+
68+
#FA MD RD and AD
69+
for metric in ["fa", "md", "rd", "ad"]:
70+
data = getattr(ten_fit,metric).astype("float32")
71+
out_name = self._gen_filename(metric)
72+
nb.Nifti1Image(data, affine).to_filename(out_name)
73+
IFLOGGER.info('DTI {metric} image saved as {i}'.format(i=out_name, metric=metric))
74+
6375
return runtime
6476

6577
def _list_outputs(self):
6678
outputs = self._outputs().get()
6779
outputs['out_file'] = self._gen_filename('dti')
80+
81+
for metric in ["fa", "md", "rd", "ad"]:
82+
outputs["{}_file".format(metric)] = self._gen_filename(metric)
83+
6884
return outputs
6985

7086

0 commit comments

Comments
 (0)