Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
327d4454
Commit
327d4454
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: New "binary" flag to LabelAtlas.get
parent
0f31c949
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/atlases.py
+17
-9
17 additions, 9 deletions
fsl/data/atlases.py
with
17 additions
and
9 deletions
fsl/data/atlases.py
+
17
−
9
View file @
327d4454
...
...
@@ -926,17 +926,20 @@ class LabelAtlas(Atlas):
return
values
,
props
def
get
(
self
,
label
=
None
,
index
=
None
,
value
=
None
,
name
=
None
):
"""
Returns the binary image for given label
def
get
(
self
,
label
=
None
,
index
=
None
,
value
=
None
,
name
=
None
,
binary
=
True
):
"""
Returns the binary image for
the
given label
.
Only one of the arguments should be used to define the label
:arg label: AtlasLabel contained within this atlas
:arg index: index of the label
:arg value: value of the label
:arg name: string of the label
:return: image.Image with the mask
:arg label: :class:`AtlasLabel` contained within this atlas
:arg index: index of the label
:arg value: value of the label
:arg name: string of the label
:arg binary: If ``True`` (the default), the image will contain 1s in
the label region. Otherwise the image will contain the
label value.
:return: :class:`.Image` with the mask
"""
if
((
label
is
not
None
)
+
(
index
is
not
None
)
+
(
value
is
not
None
)
+
(
name
is
not
None
))
!=
1
:
...
...
@@ -945,7 +948,12 @@ class LabelAtlas(Atlas):
label
=
self
.
find
(
index
=
index
,
name
=
name
,
value
=
value
)
elif
label
not
in
self
.
desc
.
labels
:
raise
ValueError
(
"
Unknown label provided
"
)
arr
=
(
self
.
data
==
label
.
value
).
astype
(
int
)
arr
=
(
self
.
data
==
label
.
value
).
astype
(
np
.
int32
)
if
not
binary
:
arr
[
arr
>
0
]
=
label
.
value
return
fslimage
.
Image
(
arr
,
name
=
label
.
name
,
header
=
self
.
header
)
...
...
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