From 7621cfbce754b81c811910306c60bd169c93084c Mon Sep 17 00:00:00 2001 From: oesteban Date: Thu, 3 May 2018 12:53:13 -0700 Subject: [PATCH 1/2] [FIX] ValueError: invalid literal for int() While creating the ICA-AROMA reports. --- niworkflows/viz/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/niworkflows/viz/utils.py b/niworkflows/viz/utils.py index 52b5b3be387..3554de9d7ab 100644 --- a/niworkflows/viz/utils.py +++ b/niworkflows/viz/utils.py @@ -538,9 +538,10 @@ def plot_melodic_components(melodic_dir, in_file, tr=None, width_ratios=[1, 1, 1, 4, 0.001, 1, 1, 1, 4, ], height_ratios=[1.1, 1] * n_rows) + noise_components = None if noise_components_file: - with open(noise_components_file) as cf: - noise_components = [int(c) for c in cf.read().split(",")] + noise_components = np.loadtxt(noise_components_file, + dtype=int, delimiter=',', ndmin=1) for i, img in enumerate( iter_img(os.path.join(melodic_dir, "melodic_IC.nii.gz"))): @@ -549,7 +550,7 @@ def plot_melodic_components(melodic_dir, in_file, tr=None, row = int(i / 2) l_row = row * 2 - if noise_components_file: + if noise_components: if (i + 1) in noise_components: color_title = color_time = color_power = 'r' else: From a477b1752c59ecfa9e92e4b5e3427dee8f092161 Mon Sep 17 00:00:00 2001 From: oesteban Date: Thu, 3 May 2018 13:13:48 -0700 Subject: [PATCH 2/2] avoid deprecation warning --- niworkflows/viz/utils.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/niworkflows/viz/utils.py b/niworkflows/viz/utils.py index 3554de9d7ab..15561685f68 100644 --- a/niworkflows/viz/utils.py +++ b/niworkflows/viz/utils.py @@ -550,15 +550,15 @@ def plot_melodic_components(melodic_dir, in_file, tr=None, row = int(i / 2) l_row = row * 2 - if noise_components: - if (i + 1) in noise_components: - color_title = color_time = color_power = 'r' - else: - color_title = color_time = color_power = 'g' - else: - color_title = 'k' - color_time = current_palette[0] - color_power = current_palette[1] + # Set default colors + color_title = 'k' + color_time = current_palette[0] + color_power = current_palette[1] + + if noise_components.size > 0: + # If a noise components list is provided, assign red/green + color_title = color_time = color_power = ( + 'r' if (i + 1) in noise_components else 'g') data = img.get_data() for j in range(3):