@@ -538,9 +538,10 @@ def plot_melodic_components(melodic_dir, in_file, tr=None,
538538 width_ratios = [1 , 1 , 1 , 4 , 0.001 , 1 , 1 , 1 , 4 , ],
539539 height_ratios = [1.1 , 1 ] * n_rows )
540540
541+ noise_components = None
541542 if noise_components_file :
542- with open (noise_components_file ) as cf :
543- noise_components = [ int ( c ) for c in cf . read (). split ( "," )]
543+ noise_components = np . loadtxt (noise_components_file ,
544+ dtype = int , delimiter = ',' , ndmin = 1 )
544545
545546 for i , img in enumerate (
546547 iter_img (os .path .join (melodic_dir , "melodic_IC.nii.gz" ))):
@@ -549,15 +550,15 @@ def plot_melodic_components(melodic_dir, in_file, tr=None,
549550 row = int (i / 2 )
550551 l_row = row * 2
551552
552- if noise_components_file :
553- if ( i + 1 ) in noise_components :
554- color_title = color_time = color_power = 'r'
555- else :
556- color_title = color_time = color_power = 'g'
557- else :
558- color_title = 'k'
559- color_time = current_palette [ 0 ]
560- color_power = current_palette [ 1 ]
553+ # Set default colors
554+ color_title = 'k'
555+ color_time = current_palette [ 0 ]
556+ color_power = current_palette [ 1 ]
557+
558+ if noise_components . size > 0 :
559+ # If a noise components list is provided, assign red/green
560+ color_title = color_time = color_power = (
561+ 'r' if ( i + 1 ) in noise_components else 'g' )
561562
562563 data = img .get_data ()
563564 for j in range (3 ):
0 commit comments