3. Internals#

Functions that are meant for use within the pipeline, not for public use.

is_valid_group(x)#
write_metadata_h5(metadata, h5_fullfile, loc)#

Write scanimage metadata fields to HDF5 attributes, taking care of flattening structured arrays to their key:value pairs.

Parameters:
metadatastruct

The metadata structure containing the fields to be written as attributes.

h5_fullfilechar

The full file path to the HDF5 file.

locchar

The path within the HDF5 file where the attributes will be written.

Notes

This function handles nested structures by flattening the fields and converting them into a format that is compatible with HDF5 attributes.

Examples

metadata = struct(‘name’, ‘LBM_guru’, ‘age’, ‘young_enough’); h5_fullfile = ‘guru.h5’; loc = ‘/young_guru’; write_metadata_h5(metadata, h5_fullfile, loc);

is_valid_dataset(filename, location, num_samples)#

Check if the HDF5 dataset contains valid data.

Query random indexes of dataset to ensure it contains valid data.

Parameters:
filenamechar

The path to the HDF5 file.

locationchar

The dataset location within the HDF5 file.

num_samplesint, optional

Number of random samples to check from the dataset. Defaults to 5.

Returns:
validlogical

Returns true if the dataset contains valid (non-zero) data, otherwise false.

Notes

The function checks if the dataset has at least 2 rows and 2 columns. It then randomly samples data from the dataset to check for non-zero values. If any sample contains a non-zero value, the dataset is considered valid. Catches any errors during the process and returns false if an error occurs.

log_struct(fid, in_struct, struct_name, log_full_path)#

log_struct Log the contents of a structure to a log file and the command window.

Parameters:
fidfile identifier (optional)

The file identifier for the log file. If not provided, logs only to the command window.

in_structstruct

The structure to log.

struct_namechar

The name of the structure.

log_full_pathchar

The path to the log file.

log_message(fid, msg, varargin)#

log_message Log a message to both a file and the command window.

Parameters:
fidfile identifier (optional)

The file identifier for the log file. If not provided, logs only to the command window.

msgchar

The message to log, with formatting placeholders.

vararginany

Additional arguments to format the message.