1+ import nipype .pipeline .engine as pe
2+ from nipype .interfaces import spm
3+ from nipype .interfaces import fsl
4+ import os
5+
6+ in_file = "feeds/data/fmri.nii.gz"
7+
8+ split = pe .Node (fsl .Split (dimension = "t" , output_type = "NIFTI" ), name = "split" )
9+ split .inputs .in_file = os .path .abspath (in_file )
10+
11+ stc = pe .Node (interface = spm .SliceTiming (), name = 'stc' )
12+ stc .inputs .num_slices = 21
13+ stc .inputs .time_repetition = 1.0
14+ stc .inputs .time_acquisition = 2. - 2. / 32
15+ stc .inputs .slice_order = range (21 ,0 ,- 1 )
16+ stc .inputs .ref_slice = 10
17+
18+ realign_estimate = pe .Node (interface = spm .Realign (), name = 'realign_estimate' )
19+ realign_estimate .inputs .jobtype = "estimate"
20+
21+ realign_write = pe .Node (interface = spm .Realign (), name = 'realign_write' )
22+ realign_write .inputs .jobtype = "write"
23+
24+ realign_estwrite = pe .Node (interface = spm .Realign (), name = 'realign_estwrite' )
25+ realign_estwrite .inputs .jobtype = "estwrite"
26+ realign_estwrite .inputs .register_to_mean = True
27+
28+ smooth = pe .Node (interface = spm .Smooth (), name = 'smooth' )
29+ smooth .inputs .fwhm = [6 , 6 , 6 ]
30+
31+ workflow3d = pe .Workflow (name = 'test_3d' )
32+ workflow3d .base_dir = "/tmp"
33+
34+ workflow3d .connect ([(split , stc , [("out_files" , "in_files" )]),
35+ (stc , realign_estimate , [('timecorrected_files' ,'in_files' )]),
36+ (realign_estimate , realign_write , [('modified_in_files' ,'in_files' )]),
37+ (stc , realign_estwrite , [('timecorrected_files' ,'in_files' )]),
38+ (realign_write , smooth , [('realigned_files' ,'in_files' )])])
39+
40+ workflow3d .run ()
41+
42+
43+ stc = pe .Node (interface = spm .SliceTiming (), name = 'stc' )
44+ stc .inputs .in_files = os .path .abspath (in_file )
45+ stc .inputs .num_slices = 25
46+ stc .inputs .time_repetition = 3.0
47+ stc .inputs .time_acquisition = 2. - 2. / 32
48+ stc .inputs .slice_order = range (25 ,0 ,- 1 )
49+ stc .inputs .ref_slice = 10
50+
51+ realign_estimate = pe .Node (interface = spm .Realign (), name = 'realign_estimate' )
52+ realign_estimate .inputs .jobtype = "estimate"
53+
54+ realign_write = pe .Node (interface = spm .Realign (), name = 'realign_write' )
55+ realign_write .inputs .jobtype = "write"
56+
57+ realign_estwrite = pe .Node (interface = spm .Realign (), name = 'realign_estwrite' )
58+ realign_estwrite .inputs .jobtype = "estwrite"
59+
60+ smooth = pe .Node (interface = spm .Smooth (), name = 'smooth' )
61+ smooth .inputs .fwhm = [6 , 6 , 6 ]
62+
63+ workflow4d = pe .Workflow (name = 'test_4d' )
64+ workflow4d .base_dir = "/tmp"
65+
66+ workflow4d .connect ([(stc , realign_estimate , [('timecorrected_files' ,'in_files' )]),
67+ (realign_estimate , realign_write , [('modified_in_files' ,'in_files' )]),
68+ (stc , realign_estwrite , [('timecorrected_files' ,'in_files' )]),
69+ (realign_write , smooth , [('realigned_files' ,'in_files' )])])
70+
71+ workflow4d .run ()
0 commit comments