ExtractSegments (FPScript)

21.09.2021

Extracts segments of different lengths from a data set and returns them as a list.

Syntax

ExtractSegments(Data, BeginningsEnds [ , NameTemplate = "%1Segment%2" ])
or
ExtractSegments(Data, Beginnings, Ends [ , NameTemplate = "%1Segment%2" ])

 

The syntax of the ExtractSegments function consists of the following parts:

Part

Description

Data

The data set to be segmented.

Permitted data structures are data series, data matrix, signal, signal series, signal series with two-dimensional X-component und space curve. All data types are permitted.

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

BeginningsEnds

On an alternating basis, the indices of the positions at which the segments to be extracted begin and end.

Permitted data structures are data series. All numeric data types are permitted.

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

Beginnings

The indices of the positions where the segments to be extracted start.

Permitted data structures are data series. All numeric data types are permitted.

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

Ends

The indices of the positions where the segments to be extracted end.

Permitted data structures are data series. All numeric data types are permitted.

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

NameTemplate

A template used to form the element names of the segments. Use "%1" to insert the name of the data set to be segmented and "%2" to insert the segment number.

Permitted data structures are scalar value. Supported data types are string.

If this argument is omitted, it will be set to the default value %1Segment%2.

Remarks

The first variant of the function uses a common data series for the start and end positions of the segments. Two indices that define the beginning and the end of a segment are extracted from BeginningsEnds. If the second index from BeginningsEnds denotes a position that lies before the first index, then this is ignored and the next index from BeginningsEnds is read. Any excess index at the end is ignored.

The second variant of the function uses separate data series for the start and end positions. From the indices in Beginnings and Ends pairs are formed, which define the beginning and the end of a segment. If the next index from Ends denotes a position that lies before the current index from Beginnings, then this is ignored and the next index from Ends is read. Segments are formed until no more index pairs can be formed. Excess indices are ignored.

The values lying on the index positions are included in the segment. The indices are counted starting from zero. Negative indices count from the end, i.e. the index -1 corresponds to the last value in Data, -2 corresponds to the next to last and so on.

If Data is a signal series, then it is segmented in the X direction. In the case of a data matrix, this corresponds to segmentation in the row direction. This corresponds to the index operation Data[][Beginning, End].

Available in

FlexPro Basic, Professional, Developer Suite

Examples

ExtractSegments(Signal, Bursts(Signal, 0.1, 1.2, EVENT_BEGINNING), Bursts(Signal, 0.1, 1.2, EVENT_END))

Extracts a series of bursts from a signal.

ExtractSegments(Signal, Bursts(Signal, 0.1, 1.2, EVENT_BOTH))

Corresponds to the first example.

Dim Segments = ExtractSegments(Signal, Bursts(Signal, 0.1, 1.2, EVENT_BOTH))
XScale(Segments, -Segments.X[0])

The X components of the segments are corrected in this example so that they all start with 0.

ExtractSegments(Signal, SearchValue(Signal, {1.5 s, 3 s}), SearchValue(Signal, {1.8 s, 3.4 s}))

Extracts two segments from a time signal. The first contains the signal section from 1.5 s to 1.8 s and the second the signal section from 3 s to 3.4 s.

See Also

SplitIntoSegments Function

XOffsetScale Function

SearchValue Function

Event Isolation Analysis Object

Data Structures

Index Operator

Share article or send as email:

You might be interested in these articles