1
1
#!/usr/bin/env python
2
2
# -*- coding: utf-8 -*-
3
3
import os
4
- from nipype .testing import (assert_equal , example_data , skipif )
5
- from nipype .algorithms .confounds import FramewiseDisplacement , ComputeDVARS
6
- import numpy as np
7
4
from tempfile import mkdtemp
8
5
from shutil import rmtree
9
6
7
+ from nipype .testing import (assert_equal , example_data , skipif , assert_true )
8
+ from nipype .algorithms .confounds import FramewiseDisplacement , ComputeDVARS
9
+ import numpy as np
10
+
11
+
10
12
nonitime = True
11
13
try :
12
14
import nitime
18
20
def test_fd ():
19
21
tempdir = mkdtemp ()
20
22
ground_truth = np .loadtxt (example_data ('fsl_motion_outliers_fd.txt' ))
21
- fd = FramewiseDisplacement (in_plots = example_data ('fsl_mcflirt_movpar.txt' ),
22
- out_file = tempdir + '/fd.txt' )
23
- res = fd .run ()
24
- yield assert_equal , np .allclose (ground_truth , np .loadtxt (res .outputs .out_file )), True
25
- yield assert_equal , np .abs (ground_truth .mean () - res .outputs .fd_average ) < 1e-4 , True
23
+ fdisplacement = FramewiseDisplacement (in_plots = example_data ('fsl_mcflirt_movpar.txt' ),
24
+ out_file = tempdir + '/fd.txt' )
25
+ res = fdisplacement .run ()
26
+
27
+ yield assert_true , np .allclose (ground_truth , np .loadtxt (res .outputs .out_file ), atol = .16 )
28
+ yield assert_true , np .abs (ground_truth .mean () - res .outputs .fd_average ) < 1e-2
26
29
rmtree (tempdir )
27
30
28
31
@skipif (nonitime )
@@ -31,9 +34,9 @@ def test_dvars():
31
34
ground_truth = np .loadtxt (example_data ('ds003_sub-01_mc.DVARS' ))
32
35
dvars = ComputeDVARS (in_file = example_data ('ds003_sub-01_mc.nii.gz' ),
33
36
in_mask = example_data ('ds003_sub-01_mc_brainmask.nii.gz' ),
34
- save_all = True )
37
+ save_all = True )
35
38
os .chdir (tempdir )
36
39
res = dvars .run ()
37
40
38
41
dv1 = np .loadtxt (res .outputs .out_std )
39
- yield assert_equal , (np .abs (dv1 - ground_truth ).sum ()/ len (dv1 )) < 0.05 , True
42
+ yield assert_equal , (np .abs (dv1 - ground_truth ).sum ()/ len (dv1 )) < 0.05 , True
0 commit comments