diff --git a/fsl/data/melodicresults.py b/fsl/data/melodicresults.py index 3338b063536265bd41c8965489dad8b4d6bf0956..6117e9005bbe090f78c8a082877cea16b4e864df 100644 --- a/fsl/data/melodicresults.py +++ b/fsl/data/melodicresults.py @@ -429,8 +429,8 @@ class MelodicClassification(props.HasProperties): def loadMelodicLabelFile(filename): """Loads component labels from the specified file. The file is assuemd - to be of the format generated by FIX or Melview; such a file should - have a structure resembling the following:: + to be of the format generated by FIX, Melview or ICA-AROMA; such a file + should have a structure resembling the following:: filtered_func_data.ica @@ -473,6 +473,11 @@ def loadMelodicLabelFile(filename): [2, 5, 6, 7] + The square brackets may or may not be present, i.e. the + following format is also accepted:: + + 2, 5, 6, 7 + In this case, the returned melodic directory path will be ``None``. """ @@ -491,11 +496,16 @@ def loadMelodicLabelFile(filename): # If the file contains a single # line, we assume that it is just - # a list of noise components. + # a comma-separated list of noise + # components. if len(lines) == 1: + # Remove any leading/trailing + # whitespace or brackets. + line = lines[0].strip(' []') + melDir = None - noisyComps = map(int, lines[0][1:-1].split(', ')) + noisyComps = [int(i) for i in line.split(',')] allLabels = [] for i in range(max(noisyComps)): @@ -507,7 +517,7 @@ def loadMelodicLabelFile(filename): else: melDir = lines[0] - noisyComps = map(int, lines[-1][1:-1].split(', ')) + noisyComps = map(int, lines[-1].strip(' []').split(', ')) # The melodic directory path should # either be an absolute path, or