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
cf99f6ab
Commit
cf99f6ab
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Atlas mask query methods raise a custom error type if mask is bad
parent
e94616ed
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
+11
-2
11 additions, 2 deletions
fsl/data/atlases.py
with
11 additions
and
2 deletions
fsl/data/atlases.py
+
11
−
2
View file @
cf99f6ab
...
@@ -605,6 +605,14 @@ class Atlas(fslimage.Image):
...
@@ -605,6 +605,14 @@ class Atlas(fslimage.Image):
self
.
desc
=
atlasDesc
self
.
desc
=
atlasDesc
class
MaskError
(
Exception
):
"""
Exception raised by the :meth:`LabelAtlas.maskLabel` and
:meth:`ProbabilisticAtlas.maskProportions` when a mask is provided which
does not match the atlas space.
"""
pass
class
LabelAtlas
(
Atlas
):
class
LabelAtlas
(
Atlas
):
"""
A 3D atlas which contains integer labels for each region.
"""
A 3D atlas which contains integer labels for each region.
...
@@ -714,7 +722,8 @@ class LabelAtlas(Atlas):
...
@@ -714,7 +722,8 @@ class LabelAtlas(Atlas):
mask
,
xform
=
mask
.
resample
(
self
.
shape
[:
3
],
dtype
=
np
.
float32
,
order
=
0
)
mask
,
xform
=
mask
.
resample
(
self
.
shape
[:
3
],
dtype
=
np
.
float32
,
order
=
0
)
if
not
fslimage
.
Image
(
mask
,
xform
=
xform
).
sameSpace
(
self
):
if
not
fslimage
.
Image
(
mask
,
xform
=
xform
).
sameSpace
(
self
):
raise
ValueError
(
'
Mask is not in the same space as atlas
'
)
raise
MaskError
(
'
Mask is not in the same space as atlas
'
)
# Extract the labels that are in
# Extract the labels that are in
...
@@ -858,7 +867,7 @@ class ProbabilisticAtlas(Atlas):
...
@@ -858,7 +867,7 @@ class ProbabilisticAtlas(Atlas):
mask
,
xform
=
mask
.
resample
(
self
.
shape
[:
3
],
dtype
=
np
.
float32
,
order
=
0
)
mask
,
xform
=
mask
.
resample
(
self
.
shape
[:
3
],
dtype
=
np
.
float32
,
order
=
0
)
if
not
fslimage
.
Image
(
mask
,
xform
=
xform
).
sameSpace
(
self
):
if
not
fslimage
.
Image
(
mask
,
xform
=
xform
).
sameSpace
(
self
):
raise
Value
Error
(
'
Mask is not in the same space as atlas
'
)
raise
Mask
Error
(
'
Mask is not in the same space as atlas
'
)
boolmask
=
mask
>
0
boolmask
=
mask
>
0
weights
=
mask
[
boolmask
]
weights
=
mask
[
boolmask
]
...
...
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