From de5013fcf3f4705b7f8305ea2a0cd99ca4fd1f34 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Tue, 5 Dec 2017 14:28:47 +1030 Subject: [PATCH] Small bugfixes in atlasq, which never arose because I assumed that all atlas files have int type, which they don't. Also atlases handles spaces in XML specifications --- fsl/data/atlases.py | 10 +++++----- fsl/scripts/atlasq.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fsl/data/atlases.py b/fsl/data/atlases.py index 6ed038f1a..259b91fdf 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 10acf8ff2..486e2c02a 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 -- GitLab