Skip to content

Commit 1afb134

Browse files
effigiesoesteban
authored andcommitted
ENH: Add reference_mask script
1 parent c7150bf commit 1afb134

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ RUN echo "${VERSION}" > /root/src/fmriprep/fmriprep/VERSION && \
164164
pip install .[all] && \
165165
rm -rf ~/.cache/pip
166166

167+
RUN install -m 0755 \
168+
/root/src/fmriprep/scripts/generate_reference_mask.py \
169+
/usr/local/bin/generate_reference_mask
170+
167171
RUN ldconfig
168172
WORKDIR /tmp/
169173
ENTRYPOINT ["/usr/local/miniconda/bin/fmriprep"]

scripts/generate_reference_mask.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
import sys
3+
import os
4+
from niworkflows.nipype.pipeline import engine as pe
5+
from niworkflows.nipype.interfaces import utility as niu
6+
from niworkflows.nipype.utils.filemanip import fname_presuffix, copyfile
7+
from fmriprep.workflows.bold.utils import init_bold_reference_wf
8+
9+
10+
def sink_ref_file(in_file, orig_file, out_dir):
11+
out_file = fname_presuffix(orig_file, suffix='_ref', newpath=out_dir)
12+
copyfile(in_file, out_file)
13+
return out_file
14+
15+
16+
def init_main_wf(bold_file, out_dir, base_dir=None, name='main_wf'):
17+
wf = init_bold_reference_wf(enhance_t2=True,
18+
base_dir=base_dir,
19+
name=name)
20+
wf.inputs.inputnode.bold_file = bold_file
21+
22+
sink = pe.Node(Function(function=sink_ref_file, out_dir=out_dir,
23+
orig_file=bold_file),
24+
name='sink')
25+
wf.connect([
26+
('outputnode', 'sink', [('bold_mask', 'in_file')]),
27+
])
28+
29+
30+
def main():
31+
main_wf = init_main_wf(sys.argv[1], sys.argv[2])
32+
main_wf.run()

0 commit comments

Comments
 (0)