diff --git a/fsl/data/atlases.py b/fsl/data/atlases.py index 6ed038f1a15edbe4acd090b7bc4af55f4778d852..259b91fdf41bc84490a6ecf28344d09ce3ce8c19 100644 --- a/fsl/data/atlases.py +++ b/fsl/data/atlases.py @@ -483,8 +483,8 @@ class AtlasDescription(object): self.atlasID = atlasID self.specPath = op.abspath(filename) - self.name = header.find('name').text - self.atlasType = header.find('type').text.lower() + self.name = header.find('name').text.strip() + self.atlasType = header.find('type').text.strip().lower() # Spelling error in some of the atlas.xml files. if self.atlasType == 'probabalistic': @@ -501,8 +501,8 @@ class AtlasDescription(object): for image in images: # Every image must also have a summary image - imagefile = image.find('imagefile') .text - summaryimagefile = image.find('summaryimagefile').text + imagefile = image.find('imagefile') .text.strip() + summaryimagefile = image.find('summaryimagefile').text.strip() # Assuming that the path # names begin with a slash @@ -533,7 +533,7 @@ class AtlasDescription(object): for i, label in enumerate(labels): - name = label.text + name = label.text.strip() index = int( label.attrib['index']) x = float(label.attrib['x']) y = float(label.attrib['y']) diff --git a/fsl/scripts/atlasq.py b/fsl/scripts/atlasq.py index 10acf8ff24c6548f51a7cdb96e4e8dcd43132d6c..486e2c02a719cb93cfe5729285d24e743565a190 100644 --- a/fsl/scripts/atlasq.py +++ b/fsl/scripts/atlasq.py @@ -171,8 +171,8 @@ def queryLongOutput(atlas, sources, types, allLabels, allProps): label = labels[0] name = names[ 0] - if label is None: - label = np.nan + if label is None: label = np.nan + else: label = int(label) fields = ['name', 'index'] values = [name, label] @@ -304,7 +304,7 @@ def ohi(namespace): props, labels = zip(*reversed(sorted(zip(props, labels)))) for label, prop in zip(labels, props): - label = atlasDesc.labels[label].name + label = atlasDesc.labels[int(label)].name labelStrs.append('{:d}% {}'.format(int(round(prop)), label)) if len(labelStrs) == 0: labels = 'No label found!' @@ -331,7 +331,7 @@ def labelNames(atlas, labels): for l in labels: if l is None: names.append('No label') - else: names.append(atlas.desc.labels[l].name) + else: names.append(atlas.desc.labels[int(l)].name) return names