Skip to content

Commit 0d09cc0

Browse files
effigiesmgxd
andauthored
Apply suggestions from code review
Co-authored-by: Mathias Goncalves <[email protected]>
1 parent 26d141f commit 0d09cc0

File tree

2 files changed

+45
-41
lines changed

2 files changed

+45
-41
lines changed

fmriprep/interfaces/resampling.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ async def resample_series_async(
372372

373373
semaphore = asyncio.Semaphore(max_concurrent)
374374

375+
# Order F ensures individual volumes are contiguous in memory
376+
# Also matches NIfTI, making final save more efficient
375377
out_array = np.zeros(coordinates.shape[1:] + data.shape[-1:], dtype=output_dtype, order='F')
376378

377379
tasks = [

fmriprep/workflows/bold/apply.py

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
def init_bold_volumetric_resample_wf(
3030
*,
3131
metadata: dict,
32-
fieldmap_id: ty.Optional[str] = None,
32+
fieldmap_id: str | None = None,
3333
omp_nthreads: int = 1,
3434
name: str = 'bold_volumetric_resample_wf',
3535
) -> pe.Workflow:
@@ -84,46 +84,48 @@ def init_bold_volumetric_resample_wf(
8484
(resample, outputnode, [('out_file', 'bold_file')]),
8585
]) # fmt:skip
8686

87-
if fieldmap_id:
88-
fmap_select = pe.Node(
89-
KeySelect(fields=["fmap_ref", "fmap_coeff"], key=fieldmap_id),
90-
name="fmap_select",
91-
run_without_submitting=True,
92-
)
93-
distortion_params = pe.Node(
94-
DistortionParameters(metadata=metadata),
95-
name="distortion_params",
96-
run_without_submitting=True,
97-
)
98-
fmap2target = pe.Node(niu.Merge(2), name='fmap2target')
99-
inverses = pe.Node(niu.Function(function=_gen_inverses), name='inverses')
100-
101-
fmap_recon = pe.Node(ReconstructFieldmap(), name="fmap_recon")
102-
103-
workflow.connect([
104-
(inputnode, fmap_select, [
105-
("fmap_ref", "fmap_ref"),
106-
("fmap_coeff", "fmap_coeff"),
107-
("fmap_id", "keys"),
108-
]),
109-
(inputnode, distortion_params, [('bold_file', 'in_file')]),
110-
(inputnode, fmap2target, [('boldref2fmap_xfm', 'in1')]),
111-
(gen_ref, fmap_recon, [('out_file', 'target_ref_file')]),
112-
(boldref2target, fmap2target, [('out', 'in2')]),
113-
(boldref2target, inverses, [('out', 'inlist')]),
114-
(fmap_select, fmap_recon, [
115-
("fmap_coeff", "in_coeffs"),
116-
("fmap_ref", "fmap_ref_file"),
117-
]),
118-
(fmap2target, fmap_recon, [('out', 'transforms')]),
119-
(inverses, fmap_recon, [('out', 'inverse')]),
120-
# Inject fieldmap correction into resample node
121-
(distortion_params, resample, [
122-
("readout_time", "ro_time"),
123-
("pe_direction", "pe_dir"),
124-
]),
125-
(fmap_recon, resample, [('out_file', 'fieldmap')]),
126-
]) # fmt:skip
87+
if not fieldmap_id:
88+
return workflow
89+
90+
fmap_select = pe.Node(
91+
KeySelect(fields=["fmap_ref", "fmap_coeff"], key=fieldmap_id),
92+
name="fmap_select",
93+
run_without_submitting=True,
94+
)
95+
distortion_params = pe.Node(
96+
DistortionParameters(metadata=metadata),
97+
name="distortion_params",
98+
run_without_submitting=True,
99+
)
100+
fmap2target = pe.Node(niu.Merge(2), name='fmap2target')
101+
inverses = pe.Node(niu.Function(function=_gen_inverses), name='inverses')
102+
103+
fmap_recon = pe.Node(ReconstructFieldmap(), name="fmap_recon")
104+
105+
workflow.connect([
106+
(inputnode, fmap_select, [
107+
("fmap_ref", "fmap_ref"),
108+
("fmap_coeff", "fmap_coeff"),
109+
("fmap_id", "keys"),
110+
]),
111+
(inputnode, distortion_params, [('bold_file', 'in_file')]),
112+
(inputnode, fmap2target, [('boldref2fmap_xfm', 'in1')]),
113+
(gen_ref, fmap_recon, [('out_file', 'target_ref_file')]),
114+
(boldref2target, fmap2target, [('out', 'in2')]),
115+
(boldref2target, inverses, [('out', 'inlist')]),
116+
(fmap_select, fmap_recon, [
117+
("fmap_coeff", "in_coeffs"),
118+
("fmap_ref", "fmap_ref_file"),
119+
]),
120+
(fmap2target, fmap_recon, [('out', 'transforms')]),
121+
(inverses, fmap_recon, [('out', 'inverse')]),
122+
# Inject fieldmap correction into resample node
123+
(distortion_params, resample, [
124+
("readout_time", "ro_time"),
125+
("pe_direction", "pe_dir"),
126+
]),
127+
(fmap_recon, resample, [('out_file', 'fieldmap')]),
128+
]) # fmt:skip
127129

128130
return workflow
129131

0 commit comments

Comments
 (0)