zea.data.legacy_file¶

Functions

check_focus_distances(scan_parameters)

Warn and auto-convert focus distances stored in wavelengths to metres.

dict_to_sorted_list(dictionary)

Convert a dictionary with sortable keys to a sorted list of values.

infer_n_tx(scan_parameters)

Infer n_tx from n_frames and n_ax.

legacy_data(data)

Format a legacy data dict for DataSpec.

legacy_probe(scan_parameters)

Format probe parameters for legacy file.

legacy_scan(scan_parameters)

Format scan parameters for legacy file.

zea.data.legacy_file.check_focus_distances(scan_parameters)[source]¶

Warn and auto-convert focus distances stored in wavelengths to metres.

Some older files store focus_distances in wavelengths rather than metres. This helper detects the pattern (values ≥ 1 and ≠ inf) and converts them using sound_speed / center_frequency.

Parameters:

scan_parameters (dict) – Raw scan parameter dict loaded from HDF5.

Returns:

The same dict, with focus_distances converted when needed.

Return type:

dict

zea.data.legacy_file.dict_to_sorted_list(dictionary)[source]¶

Convert a dictionary with sortable keys to a sorted list of values.

Note

This function operates on the top level of the dictionary only. If the dictionary contains nested dictionaries, those will not be sorted.

Example

>>> from zea.data.legacy_file import dict_to_sorted_list
>>> input_dict = {"number_000": 5, "number_001": 1, "number_002": 23}
>>> dict_to_sorted_list(input_dict)
[5, 1, 23]
Parameters:

dictionary (dict) – The dictionary to convert. The keys must be sortable.

Returns:

The sorted list of values.

Return type:

list

zea.data.legacy_file.infer_n_tx(scan_parameters)[source]¶

Infer n_tx from n_frames and n_ax.

zea.data.legacy_file.legacy_data(data)[source]¶

Format a legacy data dict for DataSpec.

In old files spatial maps (image, image_sc, envelope_data, …) were stored as plain arrays of shape (n_frames, z, x) rather than groups with values + coordinates. Wrap each such array as {"values": array} so DataSpec accepts it. The plain-array fields raw_data and aligned_data are left untouched.

Return type:

dict

zea.data.legacy_file.legacy_probe(scan_parameters)[source]¶

Format probe parameters for legacy file.

zea.data.legacy_file.legacy_scan(scan_parameters)[source]¶

Format scan parameters for legacy file.