Skip to content

matlab/matlab-agentic-toolkit / skills-catalog/signal-processing/matlab-prepare-signal-data

matlab-prepare-signal-data

Verified

Use this skill when conditioning, loading, preparing, or labeling signal data for analysis or ML training. Covers: cleaning a single signal (fill gaps, remove drift, deoutlier, denoise, resample/align a time base) BEFORE analysis; building a `signalDatastore` pipeline; creating a `labeledSignalSet` for Signal Labeler; deriving labels (filename, folder, in-file, ROI, time-frequency ROI); stratified train/val/test splits; framing long signals; parallel processing; and shaping datastore output for `trainnet`. Triggers include "clean up this signal", "remove drift / detrend", "fill gaps", "remove spikes / outliers", "denoise", "resample to a uniform rate", "align channels", "labels from filenames", "stratified split", "prepare for Signal Labeler", and function names like `fillgaps`, `fillmissing`, `detrend`, `filloutliers`, `smoothdata`, `resample`, `synchronize`, `signalDatastore`, `labeledSignalSet`, `filenames2labels`, `folders2labels`, `splitlabels`, `framesig`, `framelbl`, `createDatastores`.

FileKindSize
SKILL.mdskill md9.5 KB
manifest.yamlconfig650 B
references/fn-countlabels.mdmarkdown2.1 KB
references/fn-detrend.mdmarkdown4.6 KB
references/fn-filenames2labels.mdmarkdown4.8 KB
references/fn-fillgaps.mdmarkdown3.3 KB
references/fn-fillmissing.mdmarkdown4.2 KB
references/fn-filloutliers.mdmarkdown5.0 KB
references/fn-folders2labels.mdmarkdown3.4 KB
references/fn-framelbl.mdmarkdown7.1 KB
references/fn-framesig.mdmarkdown4.1 KB
references/fn-hampel.mdmarkdown3.3 KB
references/fn-labeledsignalset.mdmarkdown9.1 KB
references/fn-labelspectrogramoptions.mdmarkdown4.6 KB
references/fn-medfilt1.mdmarkdown3.3 KB
references/fn-partition.mdmarkdown4.6 KB
references/fn-resample.mdmarkdown4.6 KB
references/fn-retime.mdmarkdown4.7 KB
references/fn-sgolayfilt.mdmarkdown3.5 KB
references/fn-signaldatastore.mdmarkdown11.9 KB
references/fn-signallabeldefinition.mdmarkdown5.9 KB
references/fn-signalmask-getmask.mdmarkdown8.6 KB
references/fn-smoothdata.mdmarkdown4.8 KB
references/fn-splitlabels.mdmarkdown5.3 KB
references/fn-subset.mdmarkdown3.9 KB
references/fn-synchronize.mdmarkdown4.7 KB
references/fn-wdenoise.mdmarkdown5.2 KB
references/wf-align-channels.mdmarkdown6.6 KB
references/wf-custom-readfcn.mdmarkdown5.0 KB
references/wf-denoise.mdmarkdown2.6 KB
references/wf-detrend-smooth-deoutlier.mdmarkdown6.6 KB
references/wf-envelope.mdmarkdown5.3 KB
references/wf-frame-and-label.mdmarkdown4.7 KB
references/wf-handoff-to-dl.mdmarkdown9.1 KB
references/wf-label-and-export.mdmarkdown8.7 KB
references/wf-load-and-split.mdmarkdown4.6 KB
references/wf-parallel-process.mdmarkdown4.8 KB
references/wf-repair-missing.mdmarkdown6.7 KB
references/wf-uniform-rate.mdmarkdown4.2 KB

references/fn-signallabeldefinition.md

View on GitHub
# Function: `signalLabelDefinition`

> Used in: wf-label-and-export.md
> Toolbox: Signal Processing Toolbox
> Since: R2018b (roiTimeFrequency since R2025a)

Create signal label definitions for use with `labeledSignalSet`.

## Signatures

```matlab
sld = signalLabelDefinition(name)
sld = signalLabelDefinition(name, Name=Value)
```

## Label types (`LabelType`)

| Type | Describes | ROI limits | Freq limits | Example |
|---|---|---|---|---|
| `"attribute"` (default) | Whole-signal characteristic | — | — | Signal class, patient ID |
| `"roi"` | Time-domain region of interest | Nx2 `[start end]` (seconds or samples) | — | Moan region, QRS complex |
| `"point"` | Time-domain point of interest | Scalar locations | — | R-peak, onset |
| `"roiTimeFrequency"` | Time-frequency bounding box | Nx2 `[tStart tEnd]` (seconds) | Nx2 `[fLow fHigh]` (Hz) | Wireless burst, spectral event |
| `"attributeFeature"` | Signal-level feature (auto-extracted) | — | — | RMS, spectral centroid |
| `"roiFeature"` | Per-frame feature over ROI | Frame-level | — | Per-window energy |

## Properties

| Property | Applies to | Type | Default | Notes |
|---|---|---|---|---|
| `Name` | all | string | (required) | Unique within a labeledSignalSet |
| `LabelType` | all | string | `"attribute"` | See table above |
| `LabelDataType` | all | string | `"logical"` | `"logical"` \| `"categorical"` \| `"numeric"` \| `"string"` \| `"table"` \| `"timetable"` |
| `Categories` | categorical only | string array | — | Required when `LabelDataType="categorical"` |
| `DefaultValue` | all | matches LabelDataType | `[]` | Must be in `Categories` if categorical |
| `ValidationFunction` | logical/numeric/table/timetable | function_handle | — | `@(x) x > 0` etc. |
| `Description` | all | string | `""` | Free text |
| `Tag` | all | string | `""` | Cross-reference identifier |
| `Sublabels` | attribute, roi, point, roiTimeFrequency | signalLabelDefinition vector | — | Children; sublabels cannot have sublabels |
| `ROILimitsDataType` | roi, roiFeature | `"double"` \| `"duration"` | `"double"` | Do NOT set for roiTimeFrequency |
| `PointLocationsDataType` | point | `"double"` \| `"duration"` | `"double"` | |
| `TimeFrequencyOptions` | roiTimeFrequency | `labelSpectrogramOptions` | — | See fn-labelspectrogramoptions.md |
| `MemberChannel` | roiTimeFrequency | positive integer | — | Which channel for TF map (R2025a) |
| `FrameSize` | roiFeature | positive integer | — | Required for roiFeature |
| `FrameOverlapLength` | roiFeature | nonneg integer | `0` | Cannot combine with FrameRate |
| `FrameRate` | roiFeature | positive scalar | `0` | Cannot combine with FrameOverlapLength |

## Object functions

| Function | Returns |
|---|---|
| `labelDefinitionsHierarchy(lss)` | Hierarchical text listing labels and sublabels |
| `labelDefinitionsSummary(lss)` | Table summarizing all definitions |

## Canonical patterns

### Attribute (whole-signal class)

```matlab
lblClass = signalLabelDefinition("SignalClass", ...
    LabelType="attribute", ...
    LabelDataType="categorical", ...
    Categories=["normal" "anomaly" "artifact"]);
```

### ROI (time-domain region)

```matlab
lblRegion = signalLabelDefinition("BurstRegion", ...
    LabelType="roi", ...
    LabelDataType="logical");
```

### ROI with categorical values

```matlab
lblSegment = signalLabelDefinition("Segment", ...
    LabelType="roi", ...
    LabelDataType="categorical", ...
    Categories=["speech" "music" "silence"]);
```

### Point (time-domain event)

```matlab
lblPeak = signalLabelDefinition("RPeak", ...
    LabelType="point", ...
    LabelDataType="numeric", ...
    Description="R-peak amplitude");
```

### Time-frequency ROI (R2025a)

```matlab
opts = labelSpectrogramOptions("leakage", ...
    Leakage=32, Overlap=90, ...
    TimeResolutionMode="specify", TimeResolution=0.05);

lblTF = signalLabelDefinition("Signal", ...
    LabelType="roiTimeFrequency", ...
    LabelDataType="categorical", ...
    Categories=["WLAN" "BT" "LTE"], ...
    TimeFrequencyOptions=opts);
```

### Sublabels

```matlab
lblPeaks = signalLabelDefinition("Peaks", ...
    LabelType="point", LabelDataType="numeric");
lblTrill = signalLabelDefinition("Trill", ...
    LabelType="roi", LabelDataType="logical", ...
    Sublabels=lblPeaks);
```

## `setLabelValue` call signatures by type

| LabelType | Syntax |
|---|---|
| attribute | `setLabelValue(lss, memberIdx, "Name", value)` |
| roi | `setLabelValue(lss, memberIdx, "Name", roiLimits, values)` |
| point | `setLabelValue(lss, memberIdx, "Name", locations, values)` |
| roiTimeFrequency | `setLabelValue(lss, memberIdx, "Name", timeLimits, freqLimits, values)` |
| sublabel | `setLabelValue(lss, memberIdx, ["Parent" "Child"], ..., LabelRowIndex=k)` |

Where:
- `roiLimits` — Nx2 `[start end]` in seconds (or samples if no SampleRate)
- `timeLimits` — Nx2 `[tStart tEnd]` in seconds
- `freqLimits` — Nx2 `[fLow fHigh]` in Hz
- `values` — scalar, vector, or array matching N

## Gotchas

- **`roiTimeFrequency` requires `TimeFrequencyOptions`.** Omitting it
  creates the definition but labels won't render correctly in Signal
  Labeler.
- **Don't set `ROILimitsDataType` for `roiTimeFrequency`.** It's only for
  time-domain `"roi"` and `"roiFeature"`.
- **Sublabels cannot have sublabels.** Only one level of nesting.
- **`Categories` must be unique strings.** Duplicate categories error at
  construction time.
- **`createDatastores` with `TimeFrequencyMaskPriority=true` requires
  `LabelDataType="logical"`.** For categorical TF labels, omit that
  option and use `TimeFrequencyLabelFormat="mask"` alone.
- **Label names must be valid MATLAB identifiers.** They become table
  variable names in `lss.Labels`.

## See also

- `fn-labeledsignalset.md` — container that holds these definitions.
- `fn-labelspectrogramoptions.md` — TF spectrogram options.
- `wf-label-and-export.md` — end-to-end labeling workflow.

----

Copyright 2026 The MathWorks, Inc.

----
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall