From 4563a319ac09e7762686f69a3c24fdf7c83931b8 Mon Sep 17 00:00:00 2001 From: Gab-D-G Date: Mon, 2 Oct 2023 10:51:23 -0400 Subject: [PATCH] Raise an error if MELODIC fails during AROMA --- rabies/confound_correction_pkg/confound_correction.py | 3 --- .../mod_ICA_AROMA/ICA_AROMA_functions.py | 5 ++--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/rabies/confound_correction_pkg/confound_correction.py b/rabies/confound_correction_pkg/confound_correction.py index bf259426..a4245543 100755 --- a/rabies/confound_correction_pkg/confound_correction.py +++ b/rabies/confound_correction_pkg/confound_correction.py @@ -316,9 +316,6 @@ def _run_interface(self, runtime): df.to_csv(mc_file) cleaned_file, aroma_out = exec_ICA_AROMA(inFile, mc_file, brain_mask_file, CSF_mask_file, TR, cr_opts.ica_aroma['dim'], random_seed=cr_opts.ica_aroma['random_seed']) - # if AROMA failed, returns empty outputs - if cleaned_file is None: - return runtime setattr(self, 'aroma_out', aroma_out) data_img = sitk.ReadImage(cleaned_file, sitk.sitkFloat32) diff --git a/rabies/confound_correction_pkg/mod_ICA_AROMA/ICA_AROMA_functions.py b/rabies/confound_correction_pkg/mod_ICA_AROMA/ICA_AROMA_functions.py index c7f6e40a..493cf4c6 100644 --- a/rabies/confound_correction_pkg/mod_ICA_AROMA/ICA_AROMA_functions.py +++ b/rabies/confound_correction_pkg/mod_ICA_AROMA/ICA_AROMA_functions.py @@ -105,9 +105,8 @@ def run_ICA_AROMA(outDir,inFile,mc,TR,mask="",mask_csf="",denType="nonaggr",melD try: aromafunc.runICA(fslDir, inFile, outDir, melDir, mask, dim, TR, random_seed=random_seed) melIC = os.path.join(outDir, 'melodic_IC_thr.nii.gz') - except: - print('MELODIC FAILED. RETURNING EMPTY FILES.') - return False, False + except Exception as e: + raise ValueError(f"MELODIC FAILED DURING ICA-AROMA: {e}") print('Step 2) Automatic classification of the components')