Skip to content

Commit a8ccd27

Browse files
authored
Revert "Remove non-alphanumeric characters from workflow names and output entities"
1 parent b10de08 commit a8ccd27

File tree

5 files changed

+10
-24
lines changed

5 files changed

+10
-24
lines changed

sdcflows/fieldmaps.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,7 @@ def get_workflow(self, set_inputs=True, **kwargs):
446446
return self._wf
447447

448448
# Override workflow name
449-
clean_bids_id = re.sub(r'[^a-zA-Z0-9]', '', self.bids_id)
450-
kwargs["name"] = f"wf_{clean_bids_id}"
449+
kwargs["name"] = f"wf_{self.bids_id}"
451450

452451
if self.method in (EstimatorType.MAPPED, EstimatorType.PHASEDIFF):
453452
from .workflows.fit.fieldmap import init_fmap_wf

sdcflows/workflows/base.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
# https://www.nipreps.org/community/licensing/
2222
#
2323
"""Estimate fieldmaps for :abbr:`SDC (susceptibility distortion correction)`."""
24-
import re
25-
2624
from nipype import logging
2725
from nipype.pipeline import engine as pe
2826
from nipype.interfaces import utility as niu
@@ -108,7 +106,6 @@ def init_fmap_preproc_wf(
108106
)
109107

110108
for n, estimator in enumerate(estimators, 1):
111-
clean_bids_id = re.sub(r'[^a-zA-Z0-9]', '', estimator.bids_id)
112109
est_wf = estimator.get_workflow(
113110
omp_nthreads=omp_nthreads,
114111
debug=debug,
@@ -119,15 +116,15 @@ def init_fmap_preproc_wf(
119116
]
120117

121118
out_map = pe.Node(
122-
niu.IdentityInterface(fields=out_fields), name=f"out_{clean_bids_id}"
119+
niu.IdentityInterface(fields=out_fields), name=f"out_{estimator.bids_id}"
123120
)
124121
out_map.inputs.fmap_id = estimator.bids_id
125122

126123
fmap_derivatives_wf = init_fmap_derivatives_wf(
127124
output_dir=str(output_dir),
128125
write_coeff=True,
129126
bids_fmap_id=estimator.bids_id,
130-
name=f"fmap_derivatives_wf_{clean_bids_id}",
127+
name=f"fmap_derivatives_wf_{estimator.bids_id}",
131128
)
132129
fmap_derivatives_wf.inputs.inputnode.source_files = source_files
133130
fmap_derivatives_wf.inputs.inputnode.fmap_meta = [
@@ -138,15 +135,15 @@ def init_fmap_preproc_wf(
138135
output_dir=str(output_dir),
139136
fmap_type=str(estimator.method).rpartition(".")[-1].lower(),
140137
bids_fmap_id=estimator.bids_id,
141-
name=f"fmap_reports_wf_{clean_bids_id}",
138+
name=f"fmap_reports_wf_{estimator.bids_id}",
142139
)
143140
fmap_reports_wf.inputs.inputnode.source_files = source_files
144141

145142
if estimator.method not in (EstimatorType.MAPPED, EstimatorType.PHASEDIFF):
146143
fields = INPUT_FIELDS[estimator.method]
147144
inputnode = pe.Node(
148145
niu.IdentityInterface(fields=fields),
149-
name=f"in_{clean_bids_id}",
146+
name=f"in_{estimator.bids_id}",
150147
)
151148
# fmt:off
152149
workflow.connect([

sdcflows/workflows/fit/base.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
def init_sdcflows_wf():
2727
"""Create a multi-subject, multi-estimator *SDCFlows* workflow."""
28-
import re
29-
3028
from nipype.pipeline.engine import Workflow
3129
from niworkflows.utils.bids import collect_participants
3230

@@ -53,8 +51,6 @@ def init_sdcflows_wf():
5351

5452
for subject, sub_estimators in estimators_record.items():
5553
for estim in sub_estimators:
56-
clean_bids_id = re.sub(r'[^a-zA-Z0-9]', '', estim.bids_id)
57-
5854
estim_wf = estim.get_workflow(
5955
omp_nthreads=config.nipype.omp_nthreads,
6056
sloppy=False,
@@ -65,7 +61,7 @@ def init_sdcflows_wf():
6561
output_dir=config.execution.output_dir,
6662
bids_fmap_id=estim.bids_id,
6763
write_coeff=True,
68-
name=f"fmap_derivatives_{clean_bids_id}",
64+
name=f"fmap_derivatives_{estim.bids_id}",
6965
)
7066

7167
source_paths = [
@@ -80,7 +76,7 @@ def init_sdcflows_wf():
8076
fmap_type=estim.method,
8177
output_dir=config.execution.output_dir,
8278
bids_fmap_id=estim.bids_id,
83-
name=f"fmap_reports_{clean_bids_id}",
79+
name=f"fmap_reports_{estim.bids_id}",
8480
)
8581
reportlets_wf.inputs.inputnode.source_files = source_paths
8682

sdcflows/workflows/outputs.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
# https://www.nipreps.org/community/licensing/
2222
#
2323
"""Writing out outputs."""
24-
import re
25-
2624
from nipype.pipeline import engine as pe
2725
from nipype.interfaces import utility as niu
2826
from niworkflows.interfaces.bids import DerivativesDataSink as _DDS
@@ -79,7 +77,7 @@ def init_fmap_reports_wf(
7977

8078
custom_entities = custom_entities or {}
8179
if bids_fmap_id:
82-
custom_entities["fmapid"] = re.sub(r'[^a-zA-Z0-9]', '', bids_fmap_id)
80+
custom_entities["fmapid"] = bids_fmap_id.replace("_", "")
8381

8482
workflow = pe.Workflow(name=name)
8583
inputnode = pe.Node(
@@ -158,7 +156,7 @@ def init_fmap_derivatives_wf(
158156
"""
159157
custom_entities = custom_entities or {}
160158
if bids_fmap_id:
161-
custom_entities["fmapid"] = re.sub(r'[^a-zA-Z0-9]', '', bids_fmap_id)
159+
custom_entities["fmapid"] = bids_fmap_id.replace("_", "")
162160

163161
workflow = pe.Workflow(name=name)
164162
inputnode = pe.Node(

sdcflows/workflows/tests/test_base.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
"""Test the base workflow."""
2424
from pathlib import Path
2525
import os
26-
import re
27-
2826
import pytest
29-
3027
from sdcflows import fieldmaps as fm
3128
from sdcflows.utils.wrangler import find_estimators
3229
from sdcflows.workflows.base import init_fmap_preproc_wf
@@ -58,8 +55,7 @@ def test_fmap_wf(tmpdir, workdir, outdir, bids_layouts, dataset, subject):
5855
if estimator.method != fm.EstimatorType.PEPOLAR:
5956
continue
6057

61-
clean_bids_id = re.sub(r'[^a-zA-Z0-9]', '', estimator.bids_id)
62-
inputnode = wf.get_node(f"in_{clean_bids_id}")
58+
inputnode = wf.get_node(f"in_{estimator.bids_id}")
6359
inputnode.inputs.in_data = [str(f.path) for f in estimator.sources]
6460
inputnode.inputs.metadata = [f.metadata for f in estimator.sources]
6561

0 commit comments

Comments
 (0)