Skip to content

ndr.format.whitematter.header

 HEADER Reads header information embedded within a WhiteMatter LLC binary filename.
    H = ndr.format.whitematter.header(FILENAME)

    Parses a WhiteMatter LLC binary data filename to extract metadata about
    the recording session. The filename is expected to follow a specific
    convention, typically including format, date, time, duration, device type,
    channel count, and sampling rate, separated by double underscores ('__').

    Expected Filename Format Examples:
        HSW_2025_01_14__12_43_33__03min_46sec__hsamp_64ch_20000sps.bin
        HSW_2025_01_14__12_43_33__03min_46sec__mmx_imu_10ch_20000sps.bin

    Inputs:
        FILENAME  - The full path or relative path to the WhiteMatter LLC
                    binary data file (e.g., ending in '.bin').
                    (char row vector). The file must exist.

    Outputs:
        H         - A structure containing the extracted header information:
            .filename         : The base name of the input file (string).
            .filepath         : The directory path of the input file (string).
            .file_format      : The format identifier (e.g., 'HSW') (string).
            .start_time_iso   : The recording start date and time in ISO 8601
                                format ('YYYY-MM-DDTHH:MM:SS') (string).
            .duration_seconds : The recording duration in seconds (double).
            .device_type      : The identifier for the recording device
                                (e.g., 'hsamp', 'mmx_imu') (string).
            .num_channels     : The number of channels recorded (double).
            .sampling_rate    : The sampling rate in samples per second (Hz)
                                (double).

    Errors:
        - Throws an error if the input filename does not exist.
        - Throws an error if the filename does not conform to the expected
          parsing format (e.g., incorrect number of '__' separators or
          unparsable components).

    See also: fileparts, strsplit, regexp, sscanf, datetime