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
4a8aad30
Commit
4a8aad30
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix and documentation to MelodicClassification class.
parent
13c79cb0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/data/melodicresults.py
+34
-3
34 additions, 3 deletions
fsl/data/melodicresults.py
fsl/fsleyes/controls/melodicclassificationgrid.py
+3
-2
3 additions, 2 deletions
fsl/fsleyes/controls/melodicclassificationgrid.py
with
37 additions
and
5 deletions
fsl/data/melodicresults.py
+
34
−
3
View file @
4a8aad30
...
...
@@ -24,6 +24,10 @@ following functions are provided:
getNumComponents
getComponentTimeSeries
getComponentPowerSpectra
The :class:`MelodicClassification` class is also defined in this module. This
class is used to manage component classifications of a :class:`.MelodicImage`.
"""
...
...
@@ -197,6 +201,10 @@ class MelodicClassification(props.HasProperties):
.. autosummary::
:nosignatures:
hasLabel
hasComponent
getLabels
getComponents
addLabel
addComponent
removeLabel
...
...
@@ -214,6 +222,11 @@ class MelodicClassification(props.HasProperties):
labels
=
props
.
List
()
"""
A list of lists, one for each component, which contains the labels that
have been added to that component. Do not modify this list directly.
However, feel free to register a listener to be notified when this list
changes.
"""
def
__init__
(
self
,
ncomps
):
...
...
@@ -234,14 +247,19 @@ class MelodicClassification(props.HasProperties):
def
getLabels
(
self
,
component
):
"""
Returns all labels of the specified component.
"""
return
list
(
self
.
labels
[
component
])
def
hasLabel
(
self
,
component
,
label
):
"""
Returns ``True`` if the specified component has the specified label,
``False`` otherwise.
"""
return
label
in
self
.
labels
[
component
]
def
addLabel
(
self
,
component
,
label
):
"""
Adds the given label to the given component.
"""
labels
=
list
(
self
.
labels
[
component
])
comps
=
list
(
self
.
__components
.
get
(
label
,
[]))
...
...
@@ -252,14 +270,19 @@ class MelodicClassification(props.HasProperties):
labels
.
append
(
label
)
comps
.
append
(
component
)
# Change __components first, so
# any listeners on labels are
# not notified before our intenral
# state becomes consistent
self
.
__components
[
label
]
=
comps
self
.
labels
[
component
]
=
labels
self
.
__components
[
label
]
=
comps
log
.
debug
(
'
Label added to component: {} <-> {}
'
.
format
(
component
,
label
))
def
removeLabel
(
self
,
component
,
label
):
"""
Removes the given label from the given component.
"""
labels
=
list
(
self
.
labels
[
component
])
comps
=
list
(
self
.
__components
.
get
(
label
,
[]))
...
...
@@ -269,15 +292,16 @@ class MelodicClassification(props.HasProperties):
labels
.
remove
(
label
)
comps
.
remove
(
component
)
self
.
__components
[
label
]
=
comps
self
.
labels
[
component
]
=
labels
self
.
__components
[
label
]
=
comps
log
.
debug
(
'
Label removed from component: {} <-> {}
'
.
format
(
component
,
label
))
def
clearLabels
(
self
,
component
):
"""
Removes all labels from the given component.
"""
labels
=
self
.
getLabels
(
component
)
...
...
@@ -293,22 +317,29 @@ class MelodicClassification(props.HasProperties):
def
getComponents
(
self
,
label
):
"""
Returns a list of all components which have the given label.
"""
return
list
(
self
.
__components
.
get
(
label
,
[]))
def
hasComponent
(
self
,
label
,
component
):
"""
Returns ``True`` if the given compoennt has the given label,
``False`` otherwise.
"""
return
component
in
self
.
getComponents
(
label
)
def
addComponent
(
self
,
label
,
component
):
"""
Adds the given label to the given component.
"""
self
.
addLabel
(
component
,
label
)
def
removeComponent
(
self
,
label
,
component
):
"""
Removes the given label from the given component.
"""
self
.
removeLabel
(
component
,
label
)
def
clearComponents
(
self
,
label
):
"""
Removes the given label from all components.
"""
components
=
self
.
getComponents
(
label
)
...
...
This diff is collapsed.
Click to expand it.
fsl/fsleyes/controls/melodicclassificationgrid.py
+
3
−
2
View file @
4a8aad30
...
...
@@ -525,7 +525,6 @@ class LabelGrid(fslpanel.FSLEyesPanel):
colour
=
label
.
colour
()
colour
=
[
int
(
round
(
c
*
255.0
))
for
c
in
colour
]
tags
.
AddTag
(
str
(
comp
),
colour
)
self
.
__grid
.
Layout
()
...
...
@@ -606,6 +605,7 @@ class LabelGrid(fslpanel.FSLEyesPanel):
"""
Called when the :attr:`LookupTable.labels` change. Re-creates and
re-populates the :class:`.WidgetGrid`.
"""
log
.
debug
(
'
Lookup table changed - re-creating label grid
'
)
self
.
__recreateGrid
()
self
.
__refreshTags
()
...
...
@@ -613,5 +613,6 @@ class LabelGrid(fslpanel.FSLEyesPanel):
def
__labelsChanged
(
self
,
*
a
):
"""
Called when the :attr:`.MelodicClassification.labels` change.
Re-populates the :class:`.WidgetGrid`.
"""
"""
log
.
debug
(
'
Melodic classification changed - refreshing tags
'
)
self
.
__refreshTags
()
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