1
1
import os
2
2
3
- from nipype .testing import (skipif , example_data , assert_equal )
4
- import nipype .workflows .fmri .fsl as fsl_wf
3
+ from nipype .testing import skipif
5
4
import nipype .interfaces .fsl as fsl
6
5
import nipype .interfaces .utility as util
7
6
from nipype .interfaces .fsl import no_fsl , no_fsl_course_data
11
10
import tempfile
12
11
import shutil
13
12
from nipype .workflows .dmri .fsl .dti import create_bedpostx_pipeline
13
+ from nipype .utils .filemanip import list_to_filename
14
14
15
15
16
16
@skipif (no_fsl )
@@ -22,63 +22,64 @@ def test_create_bedpostx_pipeline():
22
22
bvecs_file = os .path .join (fsl_course_dir , "fdt2/subj1/bvecs" )
23
23
bvals_file = os .path .join (fsl_course_dir , "fdt2/subj1/bvals" )
24
24
dwi_file = os .path .join (fsl_course_dir , "fdt2/subj1/data.nii.gz" )
25
+ z_min = 62
26
+ z_size = 2
27
+
28
+ slice_mask = pe .Node (fsl .ExtractROI (x_min = 0 ,
29
+ x_size = - 1 ,
30
+ y_min = 0 ,
31
+ y_size = - 1 ,
32
+ z_min = z_min ,
33
+ z_size = z_size ), name = "slice_mask" )
34
+ slice_mask .inputs .in_file = mask_file
35
+
36
+ slice_dwi = pe .Node (fsl .ExtractROI (x_min = 0 ,
37
+ x_size = - 1 ,
38
+ y_min = 0 ,
39
+ y_size = - 1 ,
40
+ z_min = z_min ,
41
+ z_size = z_size ), name = "slice_dwi" )
42
+ slice_dwi .inputs .in_file = dwi_file
25
43
26
44
nipype_bedpostx = create_bedpostx_pipeline ("nipype_bedpostx" )
27
- nipype_bedpostx .inputs .inputnode .dwi = dwi_file
28
- nipype_bedpostx .inputs .inputnode .mask = mask_file
29
45
nipype_bedpostx .inputs .inputnode .bvecs = bvecs_file
30
46
nipype_bedpostx .inputs .inputnode .bvals = bvals_file
31
47
nipype_bedpostx .inputs .xfibres .n_fibres = 1
32
48
nipype_bedpostx .inputs .xfibres .fudge = 1
33
- nipype_bedpostx .inputs .xfibres .burn_in = 10
34
- nipype_bedpostx .inputs .xfibres .n_jumps = 25
35
- nipype_bedpostx .inputs .xfibres .sample_every = 25
49
+ nipype_bedpostx .inputs .xfibres .burn_in = 0
50
+ nipype_bedpostx .inputs .xfibres .n_jumps = 1
51
+ nipype_bedpostx .inputs .xfibres .sample_every = 1
52
+ nipype_bedpostx .inputs .xfibres .cnlinear = True
53
+ nipype_bedpostx .inputs .xfibres .seed = 0
36
54
37
55
with warnings .catch_warnings ():
38
56
warnings .simplefilter ("ignore" )
39
57
original_bedpostx = pe .Node (interface = fsl .BEDPOSTX (), name = "original_bedpostx" )
40
- original_bedpostx .inputs .dwi = dwi_file
41
- original_bedpostx .inputs .mask = mask_file
42
58
original_bedpostx .inputs .bvecs = bvecs_file
43
59
original_bedpostx .inputs .bvals = bvals_file
44
60
original_bedpostx .inputs .environ ['FSLPARALLEL' ] = ""
45
61
original_bedpostx .inputs .n_fibres = 1
46
62
original_bedpostx .inputs .fudge = 1
47
- original_bedpostx .inputs .burn_in = 10
48
- original_bedpostx .inputs .n_jumps = 25
49
- original_bedpostx .inputs .sample_every = 25
63
+ original_bedpostx .inputs .burn_in = 0
64
+ original_bedpostx .inputs .n_jumps = 1
65
+ original_bedpostx .inputs .sample_every = 1
66
+ original_bedpostx .inputs .seed = 0
50
67
51
68
test_f1 = pe .Node (util .AssertEqual (), name = "mean_f1_test" )
52
- test_f2 = pe .Node (util .AssertEqual (), name = "mean_f2_test" )
53
- test_th1 = pe .Node (util .AssertEqual (), name = "mean_th1_test" )
54
- test_th2 = pe .Node (util .AssertEqual (), name = "mean_th2_test" )
55
- test_ph1 = pe .Node (util .AssertEqual (), name = "mean_ph1_test" )
56
- test_ph2 = pe .Node (util .AssertEqual (), name = "mean_ph2_test" )
57
69
58
70
pipeline = pe .Workflow (name = "test_bedpostx" )
59
71
pipeline .base_dir = tempfile .mkdtemp (prefix = "nipype_test_bedpostx_" )
60
72
61
- def pickFirst (l ):
62
- return l [0 ]
63
-
64
- def pickSecond (l ):
65
- return l [1 ]
66
-
67
- pipeline .connect ([(nipype_bedpostx , test_f1 , [(("outputnode.mean_fsamples" , pickFirst ), "volume1" )]),
68
- (nipype_bedpostx , test_f2 , [(("outputnode.mean_fsamples" , pickSecond ), "volume1" )]),
69
- (nipype_bedpostx , test_th1 , [(("outputnode.mean_thsamples" , pickFirst ), "volume1" )]),
70
- (nipype_bedpostx , test_th2 , [(("outputnode.mean_thsamples" , pickSecond ), "volume1" )]),
71
- (nipype_bedpostx , test_ph1 , [(("outputnode.mean_phsamples" , pickFirst ), "volume1" )]),
72
- (nipype_bedpostx , test_ph2 , [(("outputnode.mean_phsamples" , pickSecond ), "volume1" )]),
73
-
74
- (original_bedpostx , test_f1 , [(("mean_fsamples" , pickFirst ), "volume2" )]),
75
- (original_bedpostx , test_f2 , [(("mean_fsamples" , pickSecond ), "volume2" )]),
76
- (original_bedpostx , test_th1 , [(("mean_thsamples" , pickFirst ), "volume2" )]),
77
- (original_bedpostx , test_th2 , [(("mean_thsamples" , pickSecond ), "volume2" )]),
78
- (original_bedpostx , test_ph1 , [(("mean_phsamples" , pickFirst ), "volume2" )]),
79
- (original_bedpostx , test_ph2 , [(("mean_phsamples" , pickSecond ), "volume2" )])
73
+ pipeline .connect ([(slice_mask , original_bedpostx , [("roi_file" , "mask" )]),
74
+ (slice_mask , nipype_bedpostx , [("roi_file" , "inputnode.mask" )]),
75
+
76
+ (slice_dwi , original_bedpostx , [("roi_file" , "dwi" )]),
77
+ (slice_dwi , nipype_bedpostx , [("roi_file" , "inputnode.dwi" )]),
78
+
79
+ (nipype_bedpostx , test_f1 , [(("outputnode.mean_fsamples" ,list_to_filename ), "volume1" )]),
80
+ (original_bedpostx , test_f1 , [("mean_fsamples" , "volume2" )]),
80
81
])
81
82
82
83
pipeline .run (plugin = 'Linear' )
83
- shutil .rmtree (pipeline .base_dir )
84
+ # shutil.rmtree(pipeline.base_dir)
84
85
0 commit comments