Skip to content

Commit cb11a51

Browse files
committed
enh: use sdcflows.interfaces.fmap.get_trt instead of custom function
Addressing the weak spot identified by @dPys (https://github.com/nipreps/dmriprep/pull/97/files#r416242563).
1 parent 242bbb9 commit cb11a51

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

dmriprep/workflows/fmap/base.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def init_pepolar_estimate_wf(debug=False, generate_report=True, name="pepolar_es
9393
from nipype.interfaces.afni import Automask
9494
from nipype.interfaces.fsl.epi import TOPUP
9595
from niworkflows.interfaces.nibabel import MergeSeries
96+
from sdcflows.interfaces.fmap import get_trt
9697
from ...interfaces.images import RescaleB0
9798
wf = Workflow(name=name)
9899

@@ -102,6 +103,10 @@ def init_pepolar_estimate_wf(debug=False, generate_report=True, name="pepolar_es
102103
name="outputnode")
103104

104105
concat_blips = pe.Node(MergeSeries(), name="concat_blips")
106+
readout_time = pe.MapNode(niu.Function(
107+
input_names=["in_meta", "in_file"], function=get_trt), name="readout_time",
108+
iterfield=["in_meta", "in_file"], run_without_submitting=True
109+
)
105110

106111
topup = pe.Node(TOPUP(config=_pkg_fname(
107112
"dmriprep", f"data/flirtsch/b02b0{'_quick' * debug}.cnf")), name="topup")
@@ -113,8 +118,10 @@ def init_pepolar_estimate_wf(debug=False, generate_report=True, name="pepolar_es
113118
name="post_mask")
114119
wf.connect([
115120
(inputnode, concat_blips, [("in_data", "in_files")]),
116-
(inputnode, topup, [(("metadata", _get_ro), "readout_times"),
117-
(("metadata", _get_pedir), "encoding_direction")]),
121+
(inputnode, readout_time, [("in_data", "in_file"),
122+
("metadata", "in_meta")]),
123+
(inputnode, topup, [(("metadata", _get_pedir), "encoding_direction")]),
124+
(readout_time, topup, [("out", "readout_times")]),
118125
(concat_blips, topup, [("out_file", "in_file")]),
119126
(topup, pre_mask, [("out_corrected", "in_file")]),
120127
(pre_mask, rescale_corrected, [("out_file", "mask_file")]),
@@ -128,15 +135,11 @@ def init_pepolar_estimate_wf(debug=False, generate_report=True, name="pepolar_es
128135
return wf
129136

130137

131-
def _get_ro(metadata):
132-
return [m["TotalReadoutTime"] for m in metadata]
133-
134-
135138
def _get_pedir(metadata):
136139
return [m["PhaseEncodingDirection"].replace("j", "y").replace("i", "x").replace("k", "z")
137140
for m in metadata]
138141

139142

140-
def _fname2outname(in_file):
141-
from pathlib import Path
142-
return Path(in_file).name.rstrip(".gz").rstrip(".nii").replace("-", "_")
143+
# def _fname2outname(in_file):
144+
# from pathlib import Path
145+
# return Path(in_file).name.rstrip(".gz").rstrip(".nii").replace("-", "_")

0 commit comments

Comments
 (0)