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:
NotifierThe
VolumeLabelsclass is a convenience class for managing a collection of classification labels for the volumes of anImage.The
VolumeLabelsclass 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
VolumeLabelsinstance:Removes all labels from all components.
Loads component labels from the specified file.
Saves the component classifications stored by this
VolumeLabelsinstance to the specified file.Returns the number of components (a.k.a.
Returns
Trueif the specified component has the specified label,Falseotherwise.Returns
Trueif the given compoennt has the given label,Falseotherwise.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
VolumeLabelsclass uses theNotifierinterface 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
VolumeLabelsinstance.- 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
VolumeLabelsinstance 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
VolumeLabelsinstance. 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
VolumeLabelsinstance to the specified file. See thefixlabels.saveLabelFile()function.
- hasLabel(component, label)[source]
Returns
Trueif the specified component has the specified label,Falseotherwise.
- 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 theVolumeLabelsclass.- Returns:
Trueif the label was added,Falseif the label was already present.
- removeLabel(component, label, notify=True)[source]
Removes the given label from the given component.
- Returns:
Trueif the label was removed,Falseif the component did not have this label.
- hasComponent(label, component)[source]
Returns
Trueif the given compoennt has the given label,Falseotherwise.
- removeComponent(label, component, notify=True)[source]
Removes the given label from the given component.
- __annotations__ = {}
- __module__ = 'fsl.data.volumelabels'