improve visual appearance of warning
@@ -544,21 +544,36 @@ def plot_melodic_components(melodic_dir, in_file, tr=None,
dtype=int, delimiter=',', ndmin=1)
n_rows = int((n_components + (n_components % 2)) / 2)
- fig = plt.figure(figsize=(6.5 * 1.5, n_rows * 0.85))
- gs = GridSpec(n_rows * 2, 9,
+ warning_row = int(noise_components is None or
+ noise_components.size == 0 or
+ noise_components.size == n_components)
+ fig = plt.figure(figsize=(6.5 * 1.5, (n_rows + warning_row) * 0.85))
+ gs = GridSpec(n_rows * 2 + warning_row, 9,
width_ratios=[1, 1, 1, 4, 0.001, 1, 1, 1, 4, ],
- height_ratios=[1.1, 1] * n_rows)
- if noise_components is None or noise_components.size == 0:
- fig.suptitle("WARNING: NO COMPONENTS CLASSIFIED AS NOISE", color='r')
- elif noise_components.size == n_components:
- fig.suptitle("WARNING: ALL COMPONENTS CLASSIFIED AS NOISE", color='r')
+ height_ratios=[5] * warning_row + [1.1, 1] * n_rows)
+
+ if warning_row:
+ ax = fig.add_subplot(gs[0, :])
+ ncomps = 'NONE of the'
+ if noise_components is not None and noise_components.size == n_components:
+ ncomps = 'ALL'
+ ax.annotate(
+ 'WARNING: {} components were classified as noise'.format(ncomps),
+ xy=(0.0, 0.5), xycoords='axes fraction',
+ xytext=(0.01, 0.5), textcoords='axes fraction',
+ size=12, color='#ea8800',
+ bbox=dict(boxstyle="round",
+ fc='#f7dcb7',
+ ec='#FC990E'))
+ ax.axes.get_xaxis().set_visible(False)
+ ax.axes.get_yaxis().set_visible(False)
for i, img in enumerate(
iter_img(os.path.join(melodic_dir, "melodic_IC.nii.gz"))):
col = i % 2
row = int(i / 2)
- l_row = row * 2
+ l_row = row * 2 + warning_row
# Set default colors
color_title = 'k'
