Skip to content

Commit edaa53b

Browse files
committed
fix problems
1 parent da18127 commit edaa53b

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

fmriprep/workflows/bold/tests/test_util.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
''' Testing module for fmriprep.workflows.bold.util '''
22
import pytest
33
import os
4+
from pathlib import Path
45

56
import numpy as np
67
from nipype.pipeline import engine as pe
@@ -62,32 +63,33 @@ def test_masking(input_fname, expected_fname):
6263

6364
# Reconstruct base_fname from above
6465
dirname, basename = os.path.split(input_fname)
65-
newpath = os.path.join(os.getenv('FMRIPREP_REGRESSION_REPORTS', '.'),
66-
os.path.basename(dirname))
66+
dsname = os.path.basename(dirname)
67+
reports_dir = Path(os.getenv('FMRIPREP_REGRESSION_REPORTS', ''))
68+
newpath = reports_dir / dirname
6769
out_fname = fname_presuffix(basename, suffix='_masks.svg', use_ext=False,
68-
newpath=newpath)
69-
os.makedirs(newpath, exist_ok=True)
70+
newpath=str(newpath))
71+
newpath.mkdir(parents=True, exist_ok=True)
7072

7173
mask_diff_plot = pe.Node(ROIsPlot(), name='mask_diff_plot')
7274
mask_diff_plot.inputs.in_mask = expected_fname
7375
mask_diff_plot.inputs.out_report = out_fname
7476

75-
mask_dir = os.path.join(newpath, 'fmriprep_bold_mask')
76-
save_mask = pe.Node(niu.Function(function=copyfile), name='save_mask')
77-
save_mask.inputs.copy = True
78-
save_mask.inputs.newfile = fname_presuffix(basename, suffix='_mask',
79-
use_ext=True, newpath=mask_dir)
80-
8177
outputnode = bold_reference_wf.get_node('outputnode')
8278
bold_reference_wf.connect([
83-
(bold_reference_wf.get_node('outputnode'), mask_diff_plot, [
84-
('ref_image', 'in_file'),
85-
('bold_mask', 'in_rois'),
86-
])])
79+
(outputnode, mask_diff_plot, [('ref_image', 'in_file'),
80+
('bold_mask', 'in_rois')])
81+
])
8782
res = bold_reference_wf.run(plugin='MultiProc')
8883

8984
combine_masks = [node for node in res.nodes if node.name.endswith('combine_masks')][0]
9085
overlap = symmetric_overlap(expected_fname,
9186
combine_masks.result.outputs.out_file)
9287

9388
assert overlap > 0.95, input_fname
89+
90+
mask_dir = reports_dir / 'fmriprep_bold_mask' / dsname
91+
mask_dir.mkdir(parents=True, exist_ok=True)
92+
copyfile(combine_masks.result.outputs.out_file,
93+
fname_presuffix(basename, suffix='_mask',
94+
use_ext=True, newpath=str(mask_dir)),
95+
copy=True)

0 commit comments

Comments
 (0)