Skip to content

Commit 9371c49

Browse files
committed
enh: integrate new identifier mapper from sdcflows
1 parent 9a6b7d5 commit 9371c49

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

dmriprep/workflows/dwi/base.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ def init_dwi_preproc_wf(dwi_file, has_fieldmap=False):
8080
f"Creating DWI preprocessing workflow for <{dwi_file.name}>"
8181
)
8282

83+
if has_fieldmap:
84+
from sdcflows.fieldmaps import get_identifier
85+
86+
estimator_key = get_identifier(dwi_file)
87+
if not estimator_key:
88+
has_fieldmap = False
89+
config.loggers.workflow.critical(
90+
f"None of the available B0 fieldmaps are associated to <{dwi_file}>"
91+
)
92+
8393
# Build workflow
8494
workflow = Workflow(name=_get_wf_name(dwi_file.name))
8595

@@ -157,8 +167,7 @@ def init_dwi_preproc_wf(dwi_file, has_fieldmap=False):
157167

158168
ds_report_reg = pe.Node(
159169
DerivativesDataSink(
160-
base_directory=str(config.execution.output_dir),
161-
datatype="figures",
170+
base_directory=str(config.execution.output_dir), datatype="figures",
162171
),
163172
name="ds_report_reg",
164173
run_without_submitting=True,
@@ -216,9 +225,6 @@ def _bold_reg_suffix(fallback):
216225
from sdcflows.workflows.apply.registration import init_coeff2epi_wf
217226
from sdcflows.workflows.apply.correction import init_unwarp_wf
218227

219-
# TODO: Requires nipreps/sdcflows#148
220-
# from sdcflows.utils.fieldmap import get_identifier
221-
222228
coeff2epi_wf = init_coeff2epi_wf(
223229
omp_nthreads=config.nipype.omp_nthreads, write_coeff=True
224230
)
@@ -230,12 +236,12 @@ def _bold_reg_suffix(fallback):
230236
name="output_select",
231237
run_without_submitting=True,
232238
)
233-
# estimator_key = get_identifier(dwi_file)
234-
# if len(estimator_key) != 1:
235-
# raise RuntimeError(
236-
# f"Incorrect number of fieldmap estimator IDs ({len(estimator_key)})."
237-
# )
238-
# output_select.inputs.key = estimator_key
239+
output_select.inputs.key = estimator_key[0]
240+
if len(estimator_key) > 1:
241+
config.loggers.workflow.warning(
242+
f"Several fieldmaps <{', '.join(estimator_key)}> are "
243+
f"'IntendedFor' <{dwi_file}>, using {estimator_key[0]}"
244+
)
239245

240246
# fmt: off
241247
workflow.connect([

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ install_requires =
2929
numpy
3030
pybids >= 0.11.1
3131
pyyaml
32-
sdcflows @ git+https://github.com/nipreps/sdcflows.git@ecc3d0d43100dbb6fa7f8d1d4f067a18aea1bbf6
32+
sdcflows @ git+https://github.com/nipreps/sdcflows.git@9b5c167d81e7670ef2121151b2d59fe190c0167c
3333
smriprep >= 0.8.0rc0
3434
templateflow ~= 0.6
3535
toml

0 commit comments

Comments
 (0)