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
986dff65
Commit
986dff65
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Some probabiliistic atlas descriptions refer to probabilistic files with more
labels than in the description (the striatum ones).
parent
f3f8988e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/atlases.py
+30
-17
30 additions, 17 deletions
fsl/data/atlases.py
with
30 additions
and
17 deletions
fsl/data/atlases.py
+
30
−
17
View file @
986dff65
...
...
@@ -719,22 +719,30 @@ class LabelAtlas(Atlas):
vals
=
self
[
boolmask
]
weights
=
mask
[
boolmask
]
weightsum
=
weights
.
sum
()
labels
=
np
.
unique
(
vals
)
gotLabels
=
np
.
unique
(
vals
)
labels
=
[]
props
=
[]
for
label
in
labels
:
# Only consider labels that
# this atlas is aware of
for
label
in
self
.
desc
.
labels
:
# Figure out the number of all voxels
# in the mask with this label, weighted
# by the mask.
prop
=
weights
[
vals
==
label
].
sum
()
label
=
label
.
index
+
1
# Normalise it to be a proportion
# of all voxels in the mask. We
# multiply by 100 because the FSL
# probabilistic atlases store their
# probabilities as percentages.
props
.
append
(
100
*
prop
/
weightsum
)
if
label
in
gotLabels
:
# Figure out the number of all voxels
# in the mask with this label, weighted
# by the mask.
prop
=
weights
[
vals
==
label
].
sum
()
# Normalise it to be a proportion
# of all voxels in the mask. We
# multiply by 100 because the FSL
# probabilistic atlases store their
# probabilities as percentages.
labels
.
append
(
label
)
props
.
append
(
100
*
prop
/
weightsum
)
return
labels
,
props
...
...
@@ -812,7 +820,11 @@ class ProbabilisticAtlas(Atlas):
loc
[
2
]
>=
self
.
shape
[
2
]:
return
[]
return
self
[
loc
[
0
],
loc
[
1
],
loc
[
2
],
:]
# We only return labels for this atlas
props
=
self
[
loc
[
0
],
loc
[
1
],
loc
[
2
],
:]
props
=
[
props
[
l
.
index
]
for
l
in
self
.
desc
.
labels
]
return
props
def
maskProportions
(
self
,
mask
):
...
...
@@ -841,11 +853,12 @@ class ProbabilisticAtlas(Atlas):
weights
=
mask
[
boolmask
]
weightsum
=
weights
.
sum
()
for
label
in
range
(
self
.
shape
[
3
])
:
for
label
in
self
.
desc
.
labels
:
vals
=
self
[...,
label
]
vals
=
vals
[
boolmask
]
*
weights
prop
=
vals
.
sum
()
/
weightsum
label
=
label
.
index
vals
=
self
[...,
label
]
vals
=
vals
[
boolmask
]
*
weights
prop
=
vals
.
sum
()
/
weightsum
if
not
np
.
isclose
(
prop
,
0
):
labels
.
append
(
label
)
...
...
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