Skip to content

Commit 90a8c30

Browse files
effigiesoesteban
authored andcommitted
FIX: File sinking
1 parent 348e37f commit 90a8c30

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

scripts/generate_reference_mask.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/usr/bin/env python
22
import sys
3-
import os
43
from nipype.pipeline import engine as pe
54
from nipype.interfaces import utility as niu
6-
from nipype.utils.filemanip import fname_presuffix, copyfile
75
from fmriprep.workflows.bold.util import init_bold_reference_wf
86

97

108
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)
1112
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)
1314
return out_file
1415

1516

@@ -20,9 +21,10 @@ def init_main_wf(bold_file, out_dir, base_dir=None, name='main_wf'):
2021
wf.base_dir = base_dir
2122
wf.inputs.inputnode.bold_file = bold_file
2223

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),
2525
name='sink')
26+
sink.inputs.out_dir = out_dir
27+
sink.inputs.orig_file = bold_file
2628
wf.connect([
2729
(wf.get_node('outputnode'), sink, [('bold_mask', 'in_file')]),
2830
])

0 commit comments

Comments
 (0)