Skip to content

Commit 0f3c1de

Browse files
committed
feat: Add workflow arguments for metadata estimates and fallback TRT
1 parent 5a55a81 commit 0f3c1de

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

sdcflows/workflows/apply/correction.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
def init_unwarp_wf(
3030
*,
3131
jacobian=True,
32+
use_metadata_estimates=False,
33+
fallback_total_readout_time=None,
3234
free_mem=None,
3335
omp_nthreads=1,
3436
debug=False,
@@ -117,8 +119,16 @@ def init_unwarp_wf(
117119
name="outputnode",
118120
)
119121

120-
rotime = pe.Node(GetReadoutTime(), name="rotime")
122+
rotime = pe.Node(
123+
GetReadoutTime(
124+
use_estimate=use_metadata_estimates,
125+
),
126+
name="rotime",
127+
run_without_submitting=True,
128+
)
121129
rotime.interface._always_run = debug
130+
if fallback_total_readout_time is not None:
131+
rotime.inputs.fallback = fallback_total_readout_time
122132

123133
# resample is memory-hungry; choose a smaller number of threads
124134
# if we know how much memory we have to work with

sdcflows/workflows/base.py

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def init_fmap_preproc_wf(
3636
omp_nthreads,
3737
output_dir,
3838
subject,
39+
use_metadata_estimates=False,
40+
fallback_total_readout_time=None,
3941
sloppy=False,
4042
debug=False,
4143
name="fmap_preproc_wf",
@@ -107,6 +109,8 @@ def init_fmap_preproc_wf(
107109

108110
for n, estimator in enumerate(estimators, 1):
109111
est_wf = estimator.get_workflow(
112+
use_metadata_estimates=use_metadata_estimates,
113+
fallback_total_readout_time=fallback_total_readout_time,
110114
omp_nthreads=omp_nthreads,
111115
debug=debug,
112116
sloppy=sloppy,

sdcflows/workflows/fit/fieldmap.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@
2929
INPUT_FIELDS = ("magnitude", "fieldmap")
3030

3131

32-
def init_fmap_wf(omp_nthreads=1, sloppy=False, debug=False, mode="phasediff", name="fmap_wf"):
32+
def init_fmap_wf(
33+
omp_nthreads=1,
34+
sloppy=False,
35+
debug=False,
36+
mode="phasediff",
37+
name="fmap_wf",
38+
**kwargs, # Soak up unused keyword args
39+
):
3340
"""
3441
Estimate the fieldmap based on a field-mapping MRI acquisition.
3542

sdcflows/workflows/fit/pepolar.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
def init_topup_wf(
3838
grid_reference=0,
39+
use_metadata_estimates=False,
40+
fallback_total_readout_time=None,
3941
omp_nthreads=1,
4042
sloppy=False,
4143
debug=False,
@@ -122,11 +124,15 @@ def init_topup_wf(
122124

123125
# Calculate the total readout time of each run
124126
readout_time = pe.MapNode(
125-
GetReadoutTime(),
127+
GetReadoutTime(
128+
use_estimate=use_metadata_estimates,
129+
),
126130
name="readout_time",
127131
iterfield=["metadata", "in_file"],
128132
run_without_submitting=True,
129133
)
134+
if fallback_total_readout_time is not None:
135+
readout_time.inputs.fallback = fallback_total_readout_time
130136
# Average each run so that topup is not overwhelmed (see #279)
131137
runwise_avg = pe.MapNode(
132138
RobustAverage(num_threads=omp_nthreads),

sdcflows/workflows/fit/syn.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
def init_syn_sdc_wf(
4343
*,
4444
atlas_threshold=3,
45+
use_metadata_estimates=False,
46+
fallback_total_readout_time=None,
4547
sloppy=False,
4648
debug=False,
4749
name="syn_sdc_wf",
@@ -160,10 +162,14 @@ def init_syn_sdc_wf(
160162
outputnode.inputs.method = 'FLB ("fieldmap-less", SyN-based)'
161163

162164
readout_time = pe.Node(
163-
GetReadoutTime(),
165+
GetReadoutTime(
166+
use_estimate=use_metadata_estimates,
167+
),
164168
name="readout_time",
165169
run_without_submitting=True,
166170
)
171+
if fallback_total_readout_time is not None:
172+
readout_time.inputs.fallback = fallback_total_readout_time
167173

168174
warp_dir = pe.Node(
169175
niu.Function(function=_warp_dir),

0 commit comments

Comments
 (0)