load_mat

Contents

load_mat#

ptyrad.load.load_mat(file_path, key=None, delimiter='.', squeeze_me=True, simplify_cells=True)[source]#

Load dataset(s) from a MATLAB .mat file, handling both default and v7.3 (HDF5) formats. The version is used to switch between scipy.io.loadmat or h5py.

Parameters:
  • file_path (str) – Path to the .mat file.

  • key (str | list[str] | None) – Name(s) of the dataset(s) to load. - If None, ‘’, or []: Load all datasets, preserving the original nested structure. - If str: Load a single dataset or group. Supports hierarchical keys (e.g., ‘group1.dataset1’). - If list[str]: Load multiple datasets. The returned dictionary will have a flattened structure.

  • delimiter (str) – Delimiter for hierarchical keys (default: “.”).

  • squeeze_me (bool) – Whether to squeeze unit matrix dimensions (scipy.io.loadmat parameter).

  • simplify_cells (bool) – Whether to simplify cell arrays (scipy.io.loadmat parameter).

Returns:

The loaded dataset(s) with the same structure as load_hdf5.

Return type:

data (np.ndarray or dict)

Raises:
  • FileNotFoundError – If the specified file does not exist.

  • KeyError – If provided key(s) are not found in the file.

  • TypeError – If the key is not None, a string, or a list of strings.