Skip to content

Commit 7d05e3c

Browse files
committed
improve gradient table building
1 parent 905e479 commit 7d05e3c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

nipype/interfaces/dipy/base.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class DipyBaseInterfaceInputSpec(BaseInterfaceInputSpec):
77
in_file = File(exists=True, mandatory=True, desc=('input diffusion data'))
88
in_bval = File(exists=True, mandatory=True, desc=('input b-values table'))
99
in_bvec = File(exists=True, mandatory=True, desc=('input b-vectors table'))
10+
b0_thres = traits.Int(700, usedefault=True, desc=('b0 threshold'))
1011
out_prefix = traits.Str(desc=('output prefix for file names'))
1112

1213

@@ -18,9 +19,17 @@ class DipyBaseInterface(BaseInterface):
1819
input_spec = DipyBaseInterfaceInputSpec
1920

2021
def _get_gradient_table(self):
21-
gtab = GradientTable(np.loadtxt(self.inputs.in_bvec).T)
22-
gtab.b0_threshold = 700
23-
gtab.bvals = np.loadtxt(self.inputs.in_bval)
22+
bval = np.loadtxt(self.inputs.in_bval)
23+
bvec = np.loadtxt(self.inputs.in_bvec).T
24+
try:
25+
from dipy.data import GradientTable
26+
gtab = GradientTable(bvec)
27+
gtab.bvals = bval
28+
except NameError:
29+
from dipy.core.gradients import gradient_table
30+
gtab = gradient_table(bval, bvec)
31+
32+
gtab.b0_threshold = self.inputs.b0_thres
2433
return gtab
2534

2635
def _gen_filename(self, name, ext=None):

0 commit comments

Comments
 (0)