bachlab / PsPM

A matlab suite for Psycho-Physiological Modelling
GNU General Public License v3.0
43 stars 11 forks source link

Refactor the core functionality of pspm_extract_segments #616

Closed dominikbach closed 9 months ago

dominikbach commented 10 months ago

Feature Description

Inputs

  1. Data Array (data): A cell array where each cell contains a one-dimensional array (vector) of numeric data.
  2. Onsets (onsets): A cell array where each cell contains a one-dimensional vector representing an index of the first value for each each segment.
  3. Segment Length (segment_length): An integer specifying the length (number of data points) of all segments to be extracted.
  4. Missing values (missing): A cell array where each cell contains a one-dimensional vector representing a logical index of whether data points are considered missing or not. Each cell in 'missing' must have the same length as the corresponding cell in 'data'.

The cell arrays 1, 2, 4 must have the same size.

Process

  1. Missing data handling: for each cell of data, set all data points in the vector that are indexed in missing to NaN.
  2. Segment Extraction:
    • Extract segments, the first element of each segment is indexed by onsets, and extracting a vector of the specified length.
    • Segments may overlap.
    • If a segment extends beyond the end of the data vector, fill the remaining part with NaNs to maintain the specified segment_length.

Output

  1. Segments (segments): A matrix containing all the segments. Each row in the matrix represents a segment extracted from the data. All segments are of uniform length as specified by segment_length.
  2. Session index ('sessions'): an index vector specifying for each row of segments from which cell of the input data the segment was extracted.

Additional Notes