Main Content

editLabelDefinition

Edit label definition properties

Description

editLabelDefinition(lss,lblname,propname,val) changes the propname property of the label or sublabel definition lblname to val.

The function can edit only the Name, DefaultValue, Tag, Description, and Categories properties. To change any other property of the label definition, remove the definition using removeLabelDefinition and add a definition with the desired property values using addLabelDefinitions.

  • If you edit the DefaultValue property, all existing label values remain unchanged. The new default value applies only to new members, new regions, or new points.

  • You can edit the Categories property only when the LabelDataType of the target label or sublabel definition is 'Categorical'.

New specified categories do not replace any existing categories. They are appended to the existing values.

example

Examples

collapse all

Load a labeled signal set containing recordings of whale songs. Get the names of the labels.

load whales
lss
lss = 
  labeledSignalSet with properties:

             Source: {2x1 cell}
         NumMembers: 2
    TimeInformation: "sampleRate"
         SampleRate: 4000
             Labels: [2x3 table]
        Description: "Characterize wave song regions"

 Use labelDefinitionsHierarchy to see a list of labels and sublabels.
 Use setLabelValue to add data to the set.

getLabelNames(lss)
ans = 3x1 string
    "WhaleType"
    "MoanRegions"
    "TrillRegions"

The first label corresponds to the type of whale. Get the types available in the set.

lbldefs = getLabelDefinitions(lss);
types = lbldefs(1)
types = 
  signalLabelDefinition with properties:

             Name: "WhaleType"
        LabelType: "attribute"
    LabelDataType: "categorical"
       Categories: [3x1 string]
     DefaultValue: []
        Sublabels: [0x0 signalLabelDefinition]
              Tag: ""
      Description: "Whale type"

 Use labeledSignalSet to create a labeled signal set.

types = types.Categories
types = 3x1 string
    "blue"
    "humpback"
    "white"

Modify the label to incorporate sperm whales and killer whales. Verify that the labeled signal set includes the two new whale types.

editLabelDefinition(lss,'WhaleType', ...
    'Categories',{'sperm','killer'})

lbldefs = getLabelDefinitions(lss);
types = lbldefs(1).Categories
types = 5x1 string
    "blue"
    "humpback"
    "white"
    "sperm"
    "killer"

The definition for trill regions has a sublabel that identifies peaks.

lbldefs(3).Sublabels
ans = 
  signalLabelDefinition with properties:

                      Name: "TrillPeaks"
                 LabelType: "point"
             LabelDataType: "numeric"
        ValidationFunction: []
    PointLocationsDataType: "double"
              DefaultValue: []
                 Sublabels: [0x0 signalLabelDefinition]
                       Tag: ""
               Description: "Trill peaks"

 Use labeledSignalSet to create a labeled signal set.

Change the description of the sublabel.

editLabelDefinition(lss,["TrillRegions" "TrillPeaks"], ...
    Description="Peaks of trill regions")

lbldefs = getLabelDefinitions(lss);
lbldefs(3).Sublabels
ans = 
  signalLabelDefinition with properties:

                      Name: "TrillPeaks"
                 LabelType: "point"
             LabelDataType: "numeric"
        ValidationFunction: []
    PointLocationsDataType: "double"
              DefaultValue: []
                 Sublabels: [0x0 signalLabelDefinition]
                       Tag: ""
               Description: "Peaks of trill regions"

 Use labeledSignalSet to create a labeled signal set.

Input Arguments

collapse all

Labeled signal set, specified as a labeledSignalSet object.

Example: labeledSignalSet({randn(100,1) randn(10,1)},signalLabelDefinition('female')) specifies a two-member set of random signals containing the attribute 'female'.

Label or sublabel name. To specify a label, use a character vector or a string scalar. To specify a sublabel, use a two-element cell array of character vectors or a two-element string array:

  • The first element is the name of the parent label.

  • The second element is the name of the sublabel.

Example: signalLabelDefinition("Asleep",'LabelType','roi') specifies a label of name "Asleep" for a region of a signal in which a patient is asleep during a clinical trial.

Example: {'Asleep' 'REM'} or ["Asleep" "REM"] specifies a region of a signal in which a patient undergoes REM sleep.

Property name, specified as 'Name', 'DefaultValue', 'Tag', 'Description', or 'Categories'.

Data Types: char | string

Label values, specified as a numeric or logical value, a character vector or string, a vector of strings, or a cell array of character vectors. val must be of the data type specified for propname.

Version History

Introduced in R2018b