Skip to content
Snippets Groups Projects
Commit 9b2d3b1f authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

ENH: create string representations

makes the output
parent e2d72e42
No related branches found
No related tags found
No related merge requests found
......@@ -366,6 +366,15 @@ class AtlasLabel(object):
"""
return self.index < other.index
def __repr__(self):
"""
Represents AtlasLabel as string
"""
return '{}({}, index={}, value={})'.format(
self.__class__.__name__, self.name,
self.index, self.value,
)
class AtlasDescription(object):
"""An ``AtlasDescription`` instance parses and stores the information
......@@ -574,7 +583,7 @@ class AtlasDescription(object):
self.labels = list(sorted(self.labels))
def find(self, index=None, value=None):
def find(self, index=None, value=None, name=None):
"""Find an :class:`.AtlasLabel` either by ``index``, or by ``value``.
Exactly one of ``index`` or ``value`` may be specified - a
......@@ -612,6 +621,12 @@ class AtlasDescription(object):
"""
return self.name.lower() < other.name.lower()
def __repr__(self, ):
"""
String representation of AtlasDescription
"""
return '{}({})'.format(self.__class__.__name__, self.atlasID)
class Atlas(fslimage.Image):
"""This is the base class for the :class:`LabelAtlas` and
......
......@@ -99,6 +99,8 @@ def test_AtlasDescription():
tal = registry.getAtlasDescription('talairach')
cort = registry.getAtlasDescription('harvardoxford-cortical')
assert str(tal) == 'AtlasDescription(talairach)'
assert str(cort) == 'AtlasDescription(harvardoxford-cortical)'
assert tal.atlasID == 'talairach'
assert tal.name == 'Talairach Daemon Labels'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment