File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
fmriprep/interfaces/tests Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1
1
from pathlib import Path
2
2
3
+ import numpy as np
4
+ import pandas as pd
3
5
from nipype .pipeline import engine as pe
4
6
5
7
from fmriprep .interfaces import confounds
@@ -29,3 +31,36 @@ def test_FilterDropped(tmp_path, data_dir):
29
31
target_meta = Path .read_text (data_dir / 'component_metadata_filtered.tsv' )
30
32
filtered_meta = Path (res .outputs .out_file ).read_text ()
31
33
assert filtered_meta == target_meta
34
+
35
+
36
+ def test_FSLMotionParams (tmp_path , data_dir ):
37
+ base = 'sub-01_task-mixedgamblestask_run-01'
38
+ xfms = data_dir / f'{ base } _from-orig_to-boldref_mode-image_desc-hmc_xfm.txt'
39
+ boldref = data_dir / f'{ base } _desc-hmc_boldref.nii.gz'
40
+ orig_timeseries = data_dir / f'{ base } _desc-motion_timeseries.tsv'
41
+
42
+ motion = pe .Node (
43
+ confounds .FSLMotionParams (xfm_file = str (xfms ), boldref_file = str (boldref )),
44
+ name = 'fsl_motion' ,
45
+ base_dir = str (tmp_path ),
46
+ )
47
+ res = motion .run ()
48
+
49
+ orig_params = pd .read_csv (orig_timeseries , sep = '\t ' )
50
+ derived_params = pd .read_csv (res .outputs .out_file , sep = '\t ' )
51
+
52
+ # Motion parameters are in mm and rad
53
+ # These are empirically determined bounds, but they seem reasonable
54
+ # for the units
55
+ limits = pd .DataFrame (
56
+ {
57
+ 'trans_x' : [1e-4 ],
58
+ 'trans_y' : [1e-4 ],
59
+ 'trans_z' : [1e-4 ],
60
+ 'rot_x' : [1e-6 ],
61
+ 'rot_y' : [1e-6 ],
62
+ 'rot_z' : [1e-6 ],
63
+ }
64
+ )
65
+ max_diff = (orig_params - derived_params ).abs ().max ()
66
+ assert np .all (max_diff < limits )
You can’t perform that action at this time.
0 commit comments