Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
siibra-python-mirror
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EBRAINS RI
Tech Hub
Apps
siibra
siibra-python-mirror
Commits
10d8992e
Commit
10d8992e
authored
7 months ago
by
Ahmet Nihat Simsek
Browse files
Options
Downloads
Patches
Plain Diff
`Map.get_colormap()`: `allow_random_colors` -> `fill_uncolored`. Display colorless regions
parent
9f5cbcf2
No related branches found
No related tags found
No related merge requests found
Pipeline
#59178
failed
7 months ago
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
siibra/volumes/parcellationmap.py
+16
-5
16 additions, 5 deletions
siibra/volumes/parcellationmap.py
with
16 additions
and
5 deletions
siibra/volumes/parcellationmap.py
+
16
−
5
View file @
10d8992e
...
...
@@ -690,7 +690,7 @@ class Map(concept.AtlasConcept, configuration_folder="maps"):
name
=
f
"
Custom colorization of
{
self
}
"
)
def
get_colormap
(
self
,
region_specs
:
Iterable
=
None
,
*
,
allow_random_
color
s
:
bool
=
False
):
def
get_colormap
(
self
,
region_specs
:
Iterable
=
None
,
*
,
fill_un
color
ed
:
bool
=
False
):
"""
Generate a matplotlib colormap from known rgb values of label indices.
...
...
@@ -698,7 +698,8 @@ class Map(concept.AtlasConcept, configuration_folder="maps"):
----------
region_specs: iterable(regions), optional
Optional parameter to only color the desired regions.
allow_random_colors: bool , optional
fill_uncolored: bool , optional
If a region has no preconfigured color, a color will be randomly (reproducible) created.
Returns
-------
...
...
@@ -711,7 +712,7 @@ class Map(concept.AtlasConcept, configuration_folder="maps"):
"
matplotlib not available. Please install matplotlib to create a matplotlib colormap.
"
)
raise
e
if
allow_random_
color
s
:
if
fill_un
color
ed
:
seed
=
len
(
self
.
regions
)
np
.
random
.
seed
(
seed
)
logger
.
info
(
f
"
Random colors are allowed for regions without preconfgirued colors. Random seee:
{
seed
}
.
"
)
...
...
@@ -724,6 +725,7 @@ class Map(concept.AtlasConcept, configuration_folder="maps"):
else
:
include_region_names
=
None
no_predefined_color
=
[]
for
regionname
,
indices
in
self
.
_indices
.
items
():
for
index
in
indices
:
if
index
.
label
is
None
:
...
...
@@ -735,16 +737,25 @@ class Map(concept.AtlasConcept, configuration_folder="maps"):
region
=
self
.
get_region
(
index
=
index
)
if
region
.
rgb
is
not
None
:
colors
[
index
.
label
]
=
region
.
rgb
elif
allow_random_
color
s
:
elif
fill_un
color
ed
:
random_clr
=
[
np
.
random
.
randint
(
0
,
255
)
for
r
in
range
(
3
)]
while
random_clr
in
list
(
colors
.
values
()):
random_clr
=
[
np
.
random
.
randint
(
0
,
255
)
for
r
in
range
(
3
)]
colors
[
index
.
label
]
=
random_clr
else
:
no_predefined_color
.
append
(
region
.
name
)
if
len
(
colors
)
==
0
:
raise
exceptions
.
NoPredifinedColormapException
(
f
"
There is no predefined/preconfigured colormap for
'
{
self
}
'
.
"
"
Set `allow_random_colors=True` to a colormap with random values
"
"
Set `fill_uncolored=True` to get a reproducible colormap.
"
)
if
no_predefined_color
:
logger
.
info
(
f
"
No preconfigured color found for the follwing regions.
"
"
Use `fill_uncolored=True` to display with a non-background color.
\n
"
f
"
{
no_predefined_color
}
"
)
palette
=
np
.
array
(
...
...
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
sign in
to comment