Skip to content

Commit febf69d

Browse files
committed
adedd support for motion parameters produced by AFNI
1 parent 5744d60 commit febf69d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

nipype/algorithms/confounds.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ def _list_outputs(self):
195195

196196

197197
class FramewiseDisplacementInputSpec(BaseInterfaceInputSpec):
198-
in_plots = File(exists=True, mandatory=True, desc='motion parameters as written by FSL MCFLIRT')
198+
in_file = File(exists=True, mandatory=True, desc='motion parameters as written by FSL MCFLIRT or AFNI 3dvolreg')
199+
format = traits.Enum("FSL", "AFNI", desc="Format of the motion parameters file: FSL (radians), AFNI (degrees)")
199200
radius = traits.Float(50, usedefault=True,
200201
desc='radius in mm to calculate angular FDs, 50mm is the '
201202
'default since it is used in Power et al. 2012')
@@ -249,9 +250,11 @@ class FramewiseDisplacement(BaseInterface):
249250
}]
250251

251252
def _run_interface(self, runtime):
252-
mpars = np.loadtxt(self.inputs.in_plots) # mpars is N_t x 6
253+
mpars = np.loadtxt(self.inputs.in_file) # mpars is N_t x 6
253254
diff = mpars[:-1, :] - mpars[1:, :]
254255
diff[:, :3] *= self.inputs.radius
256+
if self.inputs.format == "AFNI":
257+
diff[:, :3] *= (np.pi / 180)
255258
fd_res = np.abs(diff).sum(axis=1)
256259

257260
self._results = {

nipype/algorithms/tests/test_confounds.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
def test_fd(tmpdir):
2222
tempdir = str(tmpdir)
2323
ground_truth = np.loadtxt(example_data('fsl_motion_outliers_fd.txt'))
24-
fdisplacement = FramewiseDisplacement(in_plots=example_data('fsl_mcflirt_movpar.txt'),
25-
out_file=tempdir + '/fd.txt')
24+
fdisplacement = FramewiseDisplacement(in_file=example_data('fsl_mcflirt_movpar.txt'),
25+
out_file=tempdir + '/fd.txt',
26+
format="FSL")
2627
res = fdisplacement.run()
2728

2829
with open(res.outputs.out_file) as all_lines:

0 commit comments

Comments
 (0)