1
1
#!/usr/bin/env python
2
2
import sys
3
- import os
4
3
from nipype .pipeline import engine as pe
5
4
from nipype .interfaces import utility as niu
6
- from nipype .utils .filemanip import fname_presuffix , copyfile
7
5
from fmriprep .workflows .bold .util import init_bold_reference_wf
8
6
9
7
10
8
def sink_ref_file (in_file , orig_file , out_dir ):
9
+ import os
10
+ from nipype .utils .filemanip import fname_presuffix , copyfile
11
+ os .makedirs (out_dir , exist_ok = True )
11
12
out_file = fname_presuffix (orig_file , suffix = '_ref' , newpath = out_dir )
12
- copyfile (in_file , out_file )
13
+ copyfile (in_file , out_file , copy = True , use_hardlink = True )
13
14
return out_file
14
15
15
16
@@ -20,9 +21,10 @@ def init_main_wf(bold_file, out_dir, base_dir=None, name='main_wf'):
20
21
wf .base_dir = base_dir
21
22
wf .inputs .inputnode .bold_file = bold_file
22
23
23
- sink = pe .Node (niu .Function (function = sink_ref_file , out_dir = out_dir ,
24
- orig_file = bold_file ),
24
+ sink = pe .Node (niu .Function (function = sink_ref_file ),
25
25
name = 'sink' )
26
+ sink .inputs .out_dir = out_dir
27
+ sink .inputs .orig_file = bold_file
26
28
wf .connect ([
27
29
(wf .get_node ('outputnode' ), sink , [('bold_mask' , 'in_file' )]),
28
30
])
0 commit comments