Skip to content

Trim boundary NaN samples

What it does

This utility removes missing samples at the beginning and end of a signal while preserving missing samples inside the retained span.

When to use it

Use it to remove boundary padding before processing a signal whose internal gaps must remain explicit.

Canonical ID: tools.trimnans

Inputs

Name Meaning Type Unit Requirements
signal Signal whose leading and trailing missing samples will be removed. real vector a.u. NaN allowed; finite

Outputs

Name Meaning Type Unit
trimmed_signal Unchanged span from the first through the last finite sample, preserving internal gaps. real vector a.u.

How it works

The method locates the first and last finite samples and copies the inclusive span between them. It performs no interpolation and changes no retained amplitudes.

Interpretation and limitations

Trimming changes the signal length and discards its original starting offset. Preserve the corresponding time origin separately when aligning the result with other recordings.

Implementations and technical resources

Python source | MATLAB source

Normative JSON | Validation cases