Skip to content

Commit beae8e6

Browse files
authored
[FIX] Sanitize plus signs in from entities in workflow names (#3604)
1 parent d1e486e commit beae8e6

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

fmriprep/workflows/bold/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,10 @@ def _get_wf_name(bold_fname, prefix):
877877
from nipype.utils.filemanip import split_filename
878878

879879
fname = split_filename(bold_fname)[1]
880-
fname_nosub = '_'.join(fname.split('_')[1:-1])
881-
return f'{prefix}_{fname_nosub.replace("-", "_")}_wf'
880+
fname_sanitized = '_'.join(fname.split('_')[1:-1])
881+
for char in '-+':
882+
fname_sanitized = fname_sanitized.replace(char, '_')
883+
return f'{prefix}_{fname_sanitized}_wf'
882884

883885

884886
def extract_entities(file_list):

fmriprep/workflows/tests/test_base.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,27 @@ def test_init_fmriprep_wf_sanitize_fmaps(tmp_path):
255255
generate_expanded_graph(wf._create_flat_graph())
256256

257257

258+
def test_init_fmriprep_wf_sanitize_plus(tmp_path):
259+
bids_dir = tmp_path / 'bids'
260+
261+
spec = deepcopy(BASE_LAYOUT)
262+
spec['01']['func'][0]['acquisition'] = 'mb4+pf68th'
263+
spec['01']['anat'][0]['acquisition'] = 'memprage+rms'
264+
spec['01']['anat'][1]['acquisition'] = 'memprage'
265+
spec['01']['fmap'][2]['acquisition'] = 'sbref+pf68th'
266+
spec['01']['fmap'][3]['acquisition'] = 'sbref+pf68th'
267+
del spec['01']['func'][4:]
268+
269+
generate_bids_skeleton(bids_dir, spec)
270+
img = nb.Nifti1Image(np.zeros((10, 10, 10, 10)), np.eye(4))
271+
for img_path in bids_dir.glob('sub-01/*/*.nii.gz'):
272+
img.to_filename(img_path)
273+
274+
with mock_config(bids_dir=bids_dir):
275+
wf = init_fmriprep_wf()
276+
generate_expanded_graph(wf._create_flat_graph())
277+
278+
258279
def test_get_estimator_none(tmp_path):
259280
bids_dir = tmp_path / 'bids'
260281

0 commit comments

Comments
 (0)