diff --git a/fsl/data/atlases.py b/fsl/data/atlases.py index 6ec39a89701554f55c4a943cdd3315e02cf2b004..e2b89d06b095adba3772d4dd72bac8c9a06b8543 100644 --- a/fsl/data/atlases.py +++ b/fsl/data/atlases.py @@ -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 diff --git a/tests/test_atlases.py b/tests/test_atlases.py index c2d257f601da2eaf61b5de4eb6f4cd3e148d8d7d..a30cb0919f6a7577043e3d0cf4def81a1add5803 100644 --- a/tests/test_atlases.py +++ b/tests/test_atlases.py @@ -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'