fsl.data.volumelabels
This module provides the VolumeLabels
class, which is used to
manage labels associated with the volumes of an Image
. This class
is primarily used for managing component classifications of a
MelodicImage
.
See also the fixlabels()
module for loading/saving melodic label files.
- class fsl.data.volumelabels.VolumeLabels(*args, **kwargs)[source]
Bases:
Notifier
The
VolumeLabels
class is a convenience class for managing a collection of classification labels for the volumes of anImage
.The
VolumeLabels
class refers to volumes as components, because it was originally written to manage classification labels associated wirh the components of a Melodic analysis.The following methods are available on a
VolumeLabels
instance:Removes all labels from all components.
Loads component labels from the specified file.
Saves the component classifications stored by this
VolumeLabels
instance to the specified file.Returns the number of components (a.k.a.
Returns
True
if the specified component has the specified label,False
otherwise.Returns
True
if the given compoennt has the given label,False
otherwise.Returns all labels of the specified component.
Returns all labels that are currently associated with any component.
Returns the display name for the given label.
Returns a list of all components which have the given label.
Adds the given label to the given component.
Adds the given label to the given component.
Removes the given label from the given component.
Removes the given label from the given component.
Removes all labels from the given component.
Removes the given label from all components.
The
VolumeLabels
class uses theNotifier
interface to notify listeners about changes to the labels. Listeners can be registered to be notified on the following topics:added
: A new label was added to a component.removed
: A label was removed from a component.
When either of these events occur, the value passed to registered listeners will contain a list of
(component, label)
) tuples, which specify the labels that were added/removed.Note
All component labels are internally stored as lower case; however, their cased version (whatever is initially used) is accessible via the
getDisplayLabel()
method.- __init__(nvolumes)[source]
Create a
VolumeLabels
instance.- Parameters:
nvolumes – Number of volumes to be classified. This cannot be changed.
- numComponents()[source]
Returns the number of components (a.k.a. volumes) that this
VolumeLabels
instance is managing.
- load(filename)[source]
Loads component labels from the specified file. See the
fixlabels.loadLabelFile()
function.Note
This method adds to, but does not replace, any existing component classifications stored by this
VolumeLabels
instance. Call theclear()
method, before callingload
, if you want to discard any existing classifications.
- save(filename, dirname=None)[source]
Saves the component classifications stored by this
VolumeLabels
instance to the specified file. See thefixlabels.saveLabelFile()
function.
- hasLabel(component, label)[source]
Returns
True
if the specified component has the specified label,False
otherwise.
- addLabel(component, label, notify=True)[source]
Adds the given label to the given component.
- Parameters:
notify – If
True
(the default), theNotifier.notify()
method will be called, with the'added'
topic. This parameter is only intended for uses interal to theVolumeLabels
class.- Returns:
True
if the label was added,False
if the label was already present.
- removeLabel(component, label, notify=True)[source]
Removes the given label from the given component.
- Returns:
True
if the label was removed,False
if the component did not have this label.
- hasComponent(label, component)[source]
Returns
True
if the given compoennt has the given label,False
otherwise.
- removeComponent(label, component, notify=True)[source]
Removes the given label from the given component.
- __annotations__ = {}
- __module__ = 'fsl.data.volumelabels'