MAT Writer

class gpype.backend.sinks.mat_writer.MatWriter[source]

Bases: FileWriter

MATLAB v7.3 (.mat) file writer for real-time data logging.

Writes multi-channel data as an HDF5-backed MAT-file MATLAB’s own load() opens directly, with a time column plus one column per channel under variable_name. Channel labels, roles and the sampling rate are recorded in a gpype_meta document that MatReader reads back exactly, and a plain sampling_rate variable is written alongside it for a MATLAB user who never asked about g.Pype’s metadata format at all.

MATLAB’s v7.3 format is HDF5: a 128-byte header identifying the file as MAT-file version 2.0 little-endian, in a 512-byte userblock in front of an ordinary HDF5 container. The header is written when the file is created, not at close, so a recording killed mid-run still loads in MATLAB.

__init__(file_name, variable_name='data', edge_id=None, **kwargs)[source]

Initialize the MAT writer core.

Parameters:
  • file_name (str) – Base filename for the .mat output. A timestamp will be automatically appended.

  • variable_name (str) – Name of the HDF5 dataset MATLAB will load the recording as, e.g. load(file); data gives back the array under this name.

  • edge_id (Optional[str]) – Which edge runs this node, matched against the edge process’s –edge-id. None, the default, is every edge; ignored when the pipeline is not distributed.

  • **kwargs – Additional arguments passed to parent FileWriter.

property file_extension

Return the file extension for MAT files.

Returns:

The MAT file extension ‘.mat’.