From 7904d46f0191375f82c1796e6020a33d2b92f1d7 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko <debian@onerussian.com> Date: Thu, 20 Jul 2023 11:56:32 -0400 Subject: [PATCH] ENH: raise exception if dcm2niix returns with non-0 code --- heudiconv/convert.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/heudiconv/convert.py b/heudiconv/convert.py index 8e149bb3..e185955c 100644 --- a/heudiconv/convert.py +++ b/heudiconv/convert.py @@ -827,7 +827,18 @@ def nipype_convert( convertnode.terminal_output = "allatonce" convertnode.inputs.bids_format = bids_options is not None eg = convertnode.run() + if eg.runtime.returncode: + lgr.error( + f"Conversion has failed with exit code {eg.runtime.returncode}.\n" + f" Produced files: {eg.outputs.converted_files}\n" + f" stdout: {eg.runtime.stdout}\n" + f" stderr: {eg.runtime.stderr}" + ) + import pdb + pdb.set_trace() + # TODO: make an option on behavior in such cases -- error or to continue + raise RuntimeError("Conversion has failed. Check the logs for more details") # prov information prov_file = prefix + "_prov.ttl" if with_prov else None if prov_file: