@@ -50,37 +50,40 @@ def test_ad_output_filenames():
50
50
ad = ra .ArtifactDetect ()
51
51
outputdir = '/tmp'
52
52
f = 'motion.nii'
53
- outlierfile , intensityfile , statsfile , normfile , plotfile = ad ._get_output_filenames (f , outputdir )
53
+ (outlierfile , intensityfile , statsfile , normfile , plotfile ,
54
+ displacementfile , maskfile ) = ad ._get_output_filenames (f , outputdir )
54
55
yield assert_equal , outlierfile , '/tmp/art.motion_outliers.txt'
55
56
yield assert_equal , intensityfile , '/tmp/global_intensity.motion.txt'
56
57
yield assert_equal , statsfile , '/tmp/stats.motion.txt'
57
58
yield assert_equal , normfile , '/tmp/norm.motion.txt'
58
59
yield assert_equal , plotfile , '/tmp/plot.motion.png'
60
+ yield assert_equal , displacementfile , '/tmp/disp.motion.nii'
61
+ yield assert_equal , maskfile , '/tmp/mask.motion.nii'
59
62
60
63
61
64
def test_ad_get_affine_matrix ():
62
65
ad = ra .ArtifactDetect ()
63
- matrix = ad ._get_affine_matrix (np .array ([0 ]))
66
+ matrix = ra ._get_affine_matrix (np .array ([0 ]), 'SPM' )
64
67
yield assert_equal , matrix , np .eye (4 )
65
68
# test translation
66
69
params = [1 , 2 , 3 ]
67
- matrix = ad ._get_affine_matrix (params )
70
+ matrix = ra ._get_affine_matrix (params , 'SPM' )
68
71
out = np .eye (4 )
69
72
out [0 :3 , 3 ] = params
70
73
yield assert_equal , matrix , out
71
74
# test rotation
72
75
params = np .array ([0 , 0 , 0 , np .pi / 2 , np .pi / 2 , np .pi / 2 ])
73
- matrix = ad ._get_affine_matrix (params )
76
+ matrix = ra ._get_affine_matrix (params , 'SPM' )
74
77
out = np .array ([0 , 0 , 1 , 0 , 0 , - 1 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ]).reshape ((4 , 4 ))
75
78
yield assert_almost_equal , matrix , out
76
79
# test scaling
77
80
params = np .array ([0 , 0 , 0 , 0 , 0 , 0 , 1 , 2 , 3 ])
78
- matrix = ad ._get_affine_matrix (params )
81
+ matrix = ra ._get_affine_matrix (params , 'SPM' )
79
82
out = np .array ([1 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 0 , 0 , 3 , 0 , 0 , 0 , 0 , 1 ]).reshape ((4 , 4 ))
80
83
yield assert_equal , matrix , out
81
84
# test shear
82
85
params = np .array ([0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 2 , 3 ])
83
- matrix = ad ._get_affine_matrix (params )
86
+ matrix = ra ._get_affine_matrix (params , 'SPM' )
84
87
out = np .array ([1 , 1 , 2 , 0 , 0 , 1 , 3 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 ]).reshape ((4 , 4 ))
85
88
yield assert_equal , matrix , out
86
89
@@ -90,9 +93,9 @@ def test_ad_get_norm():
90
93
params = np .array ([0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , np .pi / 4 , np .pi / 4 ,
91
94
np .pi / 4 , 0 , 0 , 0 , - np .pi / 4 ,
92
95
- np .pi / 4 , - np .pi / 4 ]).reshape ((3 , 6 ))
93
- norm = ad ._calc_norm (params , False )
96
+ norm , _ = ra ._calc_norm (params , False , 'SPM' )
94
97
yield assert_almost_equal , norm , np .array ([18.86436316 , 37.74610158 , 31.29780829 ])
95
- norm = ad ._calc_norm (params , True )
98
+ norm , _ = ra ._calc_norm (params , True , 'SPM' )
96
99
yield assert_almost_equal , norm , np .array ([0. , 143.72192614 , 173.92527131 ])
97
100
98
101
0 commit comments