Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

utils.data_loaders

utils.data_loaders

Functions

NameDescription
load_mat_fileLoad a .mat file and return its contents as a dictionary.
load_raw_fidsLoad raw FIDs for a series, reading from a cached HDF5 file when available.

load_mat_file

utils.data_loaders.load_mat_file(file_path)

Load a .mat file and return its contents as a dictionary.

Transparently falls back from scipy.io.loadmat (plain v5/v7 files) to mat73 (v7.3, HDF5-based files) when the former can’t read the file.

Parameters

NameTypeDescriptionDefault
file_pathPath or strPath to the .mat file.required

Returns

NameTypeDescription
dictContents of the .mat file.

Raises

NameTypeDescription
FileNotFoundErrorIf file_path does not exist or is not a file.
ValueErrorIf file_path does not have a .mat extension.
RuntimeErrorIf the file can’t be loaded by either scipy or mat73.

load_raw_fids

utils.data_loaders.load_raw_fids(
    DATA_FOLDER,
    series_id,
    load_most_recent=True,
    force_override=False,
)

Load raw FIDs for a series, reading from a cached HDF5 file when available.

Parameters

NameTypeDescriptionDefault
DATA_FOLDERPath or strPath to the exam’s data folder.required
series_idintSeries number to load raw FIDs for.required
load_most_recentboolIf True, return the most recently created cached *_raw_fids.h5 file instead of re-reading the scan archive.True
force_overrideboolIf True, delete and regenerate an existing output HDF5 file rather than returning its cached contents.False

Returns

NameTypeDescription
tuple[np.ndarray, Path]The complex raw FIDs array and the path to the HDF5 file it was loaded from (or written to).