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
be55e454
Commit
be55e454
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
LUT/ColourMap lookup is now case-insensitive. LUTs can be set by their
key on the command line.
parent
82ec1009
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fsl/fslview/colourmaps.py
+31
-7
31 additions, 7 deletions
fsl/fslview/colourmaps.py
fsl/fslview/displaycontext/labelopts.py
+3
-2
3 additions, 2 deletions
fsl/fslview/displaycontext/labelopts.py
fsl/tools/fslview_parseargs.py
+10
-7
10 additions, 7 deletions
fsl/tools/fslview_parseargs.py
with
44 additions
and
16 deletions
fsl/fslview/colourmaps.py
+
31
−
7
View file @
be55e454
...
...
@@ -154,6 +154,28 @@ _cmaps = None
_luts
=
None
def
_caseInsensitiveLookup
(
d
,
k
,
default
=
None
):
"""
Performs a case-insensitive lookup on the dictionary ``d``,
with the key ``k``.
"""
v
=
d
.
get
(
k
,
None
)
if
v
is
not
None
:
return
v
keys
=
d
.
keys
()
lKeys
=
map
(
str
.
lower
,
keys
)
try
:
idx
=
lKeys
.
index
(
k
.
lower
())
except
:
if
default
is
not
None
:
return
default
else
:
raise
KeyError
(
k
)
return
d
[
keys
[
idx
]]
class
_Map
(
object
):
"""
A little class for storing details on each installed/available
colour map/lookup table. This class is only used internally.
...
...
@@ -275,8 +297,9 @@ class LookupTable(props.HasProperties):
saved
=
props
.
Boolean
(
default
=
False
)
def
__init__
(
self
,
name
,
lutFile
=
None
):
def
__init__
(
self
,
key
,
name
,
lutFile
=
None
):
self
.
key
=
key
self
.
name
=
name
if
lutFile
is
not
None
:
...
...
@@ -593,11 +616,12 @@ def registerLookupTable(lut,
log
.
debug
(
'
Loading and registering custom
'
'
lookup table: {}
'
.
format
(
lutFile
))
lut
=
LookupTable
(
name
,
lutFile
)
lut
=
LookupTable
(
key
,
name
,
lutFile
)
else
:
if
key
is
None
:
key
=
lut
.
name
if
name
is
None
:
name
=
key
lut
.
key
=
key
lut
.
name
=
name
# Even though the lut may have been loaded from
...
...
@@ -622,14 +646,14 @@ def registerLookupTable(lut,
lutChoice
=
opts
.
getProp
(
'
lut
'
)
lutChoice
.
addChoice
(
lut
,
label
=
lut
.
name
,
alternate
=
[
key
,
name
],
alternate
=
[
key
],
instance
=
opts
)
# and for any future label overlays
fsldisplay
.
LabelOpts
.
lut
.
addChoice
(
lut
,
label
=
lut
.
name
,
alternate
=
[
key
,
name
])
alternate
=
[
key
])
return
lut
...
...
@@ -641,7 +665,7 @@ def getLookupTables():
def
getLookupTable
(
lutName
):
"""
Returns the :class:`LutTable` instance of the specified name.
"""
return
_luts
[
lutName
]
.
mapObj
return
_caseInsensitiveLookup
(
_luts
,
lutName
)
.
mapObj
def
getColourMaps
():
...
...
@@ -651,7 +675,7 @@ def getColourMaps():
def
getColourMap
(
cmapName
):
"""
Returns the colour map instance of the specified name.
"""
return
_cmaps
[
cmapName
]
.
mapObj
return
_caseInsensitiveLookup
(
_cmaps
,
cmapName
)
.
mapObj
def
isColourMapRegistered
(
cmapName
):
...
...
This diff is collapsed.
Click to expand it.
fsl/fslview/displaycontext/labelopts.py
+
3
−
2
View file @
be55e454
...
...
@@ -13,11 +13,12 @@ import fsl.fslview.colourmaps as fslcm
luts
=
fslcm
.
getLookupTables
()
names
=
[
l
.
name
for
l
in
luts
]
names
=
[
l
.
name
for
l
in
luts
]
alts
=
[[
l
.
key
]
for
l
in
luts
]
class
LabelOpts
(
volumeopts
.
ImageOpts
):
lut
=
props
.
Choice
(
luts
,
name
s
)
lut
=
props
.
Choice
(
luts
,
labels
=
names
,
alternates
=
alt
s
)
outline
=
props
.
Boolean
(
default
=
False
)
outlineWidth
=
props
.
Real
(
minval
=
0
,
maxval
=
1
,
default
=
0.25
,
clamped
=
True
)
showNames
=
props
.
Boolean
(
default
=
False
)
...
...
This diff is collapsed.
Click to expand it.
fsl/tools/fslview_parseargs.py
+
10
−
7
View file @
be55e454
...
...
@@ -346,7 +346,16 @@ EXTRA = td.TypeDict({
'
default
'
:
fsldisplay
.
ALL_OVERLAY_TYPES
[
0
]},
'
LabelOpts.lut
'
:
{
'
choices
'
:
[
l
.
name
for
l
in
colourmaps
.
getLookupTables
()]
# The LabelOpts.lut choice property has
# LookupTable instances as values, which
# obviously cannot be passed in on the
# command line. But the lut property will
# also accept the lut key as an alternate
# value, so we accept these on the command
# line instead. See the colourmaps and
# labelopts modules for more detail.
'
choices
'
:
[],
'
useAlts
'
:
True
}
})
...
...
@@ -362,10 +371,6 @@ EXTRA = td.TypeDict({
def
_imageTrans
(
i
):
if
i
==
'
none
'
:
return
None
else
:
return
i
.
dataSource
def
_lutTrans
(
i
):
if
isinstance
(
i
,
basestring
):
return
colourmaps
.
getLookupTable
(
i
)
else
:
return
i
.
name
TRANSFORMS
=
td
.
TypeDict
({
...
...
@@ -375,8 +380,6 @@ TRANSFORMS = td.TypeDict({
'
OrthoOpts.showZCanvas
'
:
lambda
b
:
not
b
,
'
OrthoOpts.showLabels
'
:
lambda
b
:
not
b
,
'
LabelOpts.lut
'
:
_lutTrans
,
# These properties are handled specially
# when reading in command line arguments -
# the transform function specified here
...
...
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