From c3dde8aa5ff00ec72d2ee4099603cf8c46484466 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Fri, 13 Oct 2023 16:44:53 -0400 Subject: [PATCH] FIX: Sort on echo time --- fmriprep/workflows/bold/fit.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fmriprep/workflows/bold/fit.py b/fmriprep/workflows/bold/fit.py index 34aa1cf2c..730590867 100644 --- a/fmriprep/workflows/bold/fit.py +++ b/fmriprep/workflows/bold/fit.py @@ -521,8 +521,11 @@ def init_bold_native_wf( # Shortest echo first all_metadata, bold_files, echo_times = zip( *sorted( - (md := layout.get_metadata(bold_file), bold_file, md.get("EchoTime")) - for bold_file in listify(bold_series) + ( + (md := layout.get_metadata(bold_file), bold_file, md.get("EchoTime")) + for bold_file in listify(bold_series) + ), + key=lambda _, _, echo_time: echo_time, ) ) multiecho = len(bold_files) > 1