glhmm.io

Input/output functions - Gaussian Linear Hidden Markov Model @author: Diego Vidaurre 2023

glhmm.io.load_files(files, I=None, do_only_indices=False)[source]

Loads data from files and returns the loaded data, indices, and individual indices for each file.

glhmm.io.load_hmm(filename, directory=None)[source]

Load a glhmm object from the specified file.

Parameters:

filename (str):

Name of the file containing the glhmm object.

directory (str, optional), default=None:

Directory where the file is located. If None, searches in the current working directory.

Returns:

glhmmobject

Loaded glhmm object.

glhmm.io.load_statistics(filename, directory=None)[source]

Load statistics data from a file.

Parameters:
  • filename (str) – The name of the file containing the saved statistics data, with or without extension.

  • (str (load_directory) – The directory path where the file is located (default is the current working directory).

  • optional) – The directory path where the file is located (default is the current working directory).

  • default=None – The directory path where the file is located (default is the current working directory).

Returns:

data_dict – The dictionary containing the loaded statistics data.

Return type:

dict

glhmm.io.read_flattened_hmm_mat(file)[source]

Reads a MATLAB file containing hidden Markov model (HMM) parameters, and initializes a Gaussian linear hidden Markov model (GLHMM) using those parameters.

glhmm.io.save_hmm(hmm, filename, directory=None)[source]

Save a glhmm object in the specified directory with the given filename.

Parameters:

hmm (object)

The glhmm object to be saved.

filename (str)

The name of the file to which the object will be saved.

directory (str, optional), default=None:

The directory where the file will be saved. If None, saves in the current working directory.

glhmm.io.save_statistics(data_dict, filename='statistics', directory=None, format='npy')[source]

Save statistics data to a file in the specified directory with optional format (npy or npz).

Parameters:
  • (dict) (data_dict) – Dictionary containing statistics data to be saved.

  • (str (format) – Name of the file.

  • optional) – Name of the file.

  • default='statistics' – Name of the file.

  • (str – Directory path where the file will be saved (default is the current working directory).

  • optional) – Directory path where the file will be saved (default is the current working directory).

  • default=None – Directory path where the file will be saved (default is the current working directory).

  • (str – Serialization format (‘npy’ or ‘npz’).

  • optional) – Serialization format (‘npy’ or ‘npz’).

  • default='npy' – Serialization format (‘npy’ or ‘npz’).