Skip to content

Commit e6bda71

Browse files
authored
FIX: Raise RuntimeError at build if echos have mismatched shapes (#3028)
## Changes proposed in this pull request Checks shapes of multiecho images on workflow build and errors rather than waiting for it to become an issue. Closes #3005.
2 parents 4f9a1f2 + d5fdba0 commit e6bda71

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fmriprep/workflows/bold/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
247247
*sorted([(layout.get_metadata(bf)["EchoTime"], bf) for bf in bold_file])
248248
)
249249
ref_file = bold_file[0] # Reset reference to be the shortest TE
250+
shapes = [nb.load(echo).shape for echo in bold_file]
251+
if len(set(shapes)) != 1:
252+
diagnostic = "\n".join(
253+
f"{os.path.basename(echo)}: {shape}" for echo, shape in zip(bold_file, shapes)
254+
)
255+
raise RuntimeError(f"Multi-echo images found with mismatching shapes\n{diagnostic}")
250256

251257
if os.path.isfile(ref_file):
252258
bold_tlen, mem_gb = _create_mem_gb(ref_file)

0 commit comments

Comments
 (0)