Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
9b2d3b1f
Commit
9b2d3b1f
authored
5 years ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
ENH: create string representations
makes the output
parent
e2d72e42
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/data/atlases.py
+16
-1
16 additions, 1 deletion
fsl/data/atlases.py
tests/test_atlases.py
+2
-0
2 additions, 0 deletions
tests/test_atlases.py
with
18 additions
and
1 deletion
fsl/data/atlases.py
+
16
−
1
View file @
9b2d3b1f
...
@@ -366,6 +366,15 @@ class AtlasLabel(object):
...
@@ -366,6 +366,15 @@ class AtlasLabel(object):
"""
"""
return
self
.
index
<
other
.
index
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
):
class
AtlasDescription
(
object
):
"""
An ``AtlasDescription`` instance parses and stores the information
"""
An ``AtlasDescription`` instance parses and stores the information
...
@@ -574,7 +583,7 @@ class AtlasDescription(object):
...
@@ -574,7 +583,7 @@ class AtlasDescription(object):
self
.
labels
=
list
(
sorted
(
self
.
labels
))
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``.
"""
Find an :class:`.AtlasLabel` either by ``index``, or by ``value``.
Exactly one of ``index`` or ``value`` may be specified - a
Exactly one of ``index`` or ``value`` may be specified - a
...
@@ -612,6 +621,12 @@ class AtlasDescription(object):
...
@@ -612,6 +621,12 @@ class AtlasDescription(object):
"""
"""
return
self
.
name
.
lower
()
<
other
.
name
.
lower
()
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
):
class
Atlas
(
fslimage
.
Image
):
"""
This is the base class for the :class:`LabelAtlas` and
"""
This is the base class for the :class:`LabelAtlas` and
...
...
This diff is collapsed.
Click to expand it.
tests/test_atlases.py
+
2
−
0
View file @
9b2d3b1f
...
@@ -99,6 +99,8 @@ def test_AtlasDescription():
...
@@ -99,6 +99,8 @@ def test_AtlasDescription():
tal
=
registry
.
getAtlasDescription
(
'
talairach
'
)
tal
=
registry
.
getAtlasDescription
(
'
talairach
'
)
cort
=
registry
.
getAtlasDescription
(
'
harvardoxford-cortical
'
)
cort
=
registry
.
getAtlasDescription
(
'
harvardoxford-cortical
'
)
assert
str
(
tal
)
==
'
AtlasDescription(talairach)
'
assert
str
(
cort
)
==
'
AtlasDescription(harvardoxford-cortical)
'
assert
tal
.
atlasID
==
'
talairach
'
assert
tal
.
atlasID
==
'
talairach
'
assert
tal
.
name
==
'
Talairach Daemon Labels
'
assert
tal
.
name
==
'
Talairach Daemon Labels
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment