zea.data.file_operationsΒΆ
This module provides some utilities to edit zea data files.
Available operationsΒΆ
sum: Sum multiple raw data files into one.
compound_frames: Compound frames in a raw data file to increase SNR.
compound_transmits: Compound transmits in a raw data file to increase SNR.
resave: Resave a zea data file. This can be used to change the file format version.
extract: extract frames and transmits in a raw data file.
Functions
|
Compounds frames in a raw data file by averaging them. |
|
Compounds transmits in a raw data file by averaging them. |
|
extracts frames and transmits in a raw data file. |
Command line argument parser with subcommands |
|
|
Resaves a zea data file to a new location. |
|
Saves data to a zea data file (h5py file). |
|
Sums multiple raw data files and saves the result to a new file. |
- zea.data.file_operations.compound_frames(input_path, output_path, overwrite=False)[source]ΒΆ
Compounds frames in a raw data file by averaging them.
- Parameters:
input_path (
Path) β Path to the input raw data file.output_path (
Path) β Path to the output file where the compounded data will be saved.overwrite (bool, optional) β Whether to overwrite the output file if it exists. Defaults to False.
- zea.data.file_operations.compound_transmits(input_path, output_path, overwrite=False)[source]ΒΆ
Compounds transmits in a raw data file by averaging them.
Note
This function assumes that all transmits are identical. If this is not the case the function will result in incorrect scan parameters.
- Args:
input_path (Path): Path to the input raw data file. output_path (Path): Path to the output file where the compounded data will be saved. overwrite (bool, optional): Whether to overwrite the output file if it exists. Defaults to False.
- zea.data.file_operations.extract_frames_transmits(input_path, output_path, frame_indices=slice(None, None, None), transmit_indices=slice(None, None, None), overwrite=False)[source]ΒΆ
extracts frames and transmits in a raw data file.
Note that the frame indices cannot both be lists. At least one of them must be a slice. Please refer to the documentation of
zea.data.file.load_file_all_data_types()for more information on the supported index types.- Parameters:
input_path (
Path) β Path to the input raw data file.output_path (
Path) β Path to the output file where the extracted data will be saved.frame_indices (list, array-like, or slice) β Indices of the frames to keep.
transmit_indices (list, array-like, or slice) β Indices of the transmits to keep.
overwrite (bool, optional) β Whether to overwrite the output file if it exists. Defaults to False.
- zea.data.file_operations.resave(input_path, output_path, overwrite=False)[source]ΒΆ
Resaves a zea data file to a new location.
- Parameters:
input_path (
Path) β Path to the input zea data file.output_path (
Path) β Path to the output file where the data will be saved.overwrite (bool, optional) β Whether to overwrite the output file if it exists. Defaults to False.
- zea.data.file_operations.save_file(path, scan, probe, raw_data=None, aligned_data=None, beamformed_data=None, envelope_data=None, image=None, image_sc=None, description='', custom_maps=None, metadata=None, **kwargs)[source]ΒΆ
Saves data to a zea data file (h5py file).
- Parameters:
path (str, pathlike) β The path to the hdf5 file.
raw_data (
ndarray) β The data to save.scan (
Scan) β The scan object containing the parameters of the acquisition.probe (
Probe) β The probe object containing the parameters of the probe.description (str) β A description for the dataset.
beamformed_data (
dict) β Beamformed data as a dict with"values"and"extent"keys (validated asBeamformedData).envelope_data (
dict) β Envelope-detected data as a dict with"values"and"extent"keys (validated asEnvelopeData).image_sc (
dict) β Scan-converted image data as a dict with"values"and"extent"keys (validated asImageSc).image (
dict) β Reconstructed (log-compressed) image data as a dict with"values"and"extent"keys (validated asImage).custom_maps (
dict|None) βCustom spatial map entries to include in the
datagroup. Each key maps to a dict with"values"(np.ndarray, uint8) and"extent"(np.ndarray, float32, shape(6,)) fields, plus optional"labels","description", and"unit"fields. Example:custom_maps = { "my_overlay": { "values": values_array, # (n_frames, x, z, y[, n_ch]), uint8 "extent": extent_array, # (6,) float32 } }
metadata (
dict|None) βMetadata to store in the
metadatagroup, validated againstMetadataSpec. Standard keys include"subject","credit","annotations","text_report","ecg","probe_pose", and"voice_narration". Custom signal keys are also accepted and stored asSignalNDentries. Example:metadata = { "credit": "My Lab, 2024", "annotations": {"label": np.array(["healthy", "healthy"])}, }
- zea.data.file_operations.sum_data(input_paths, output_path, overwrite=False)[source]ΒΆ
Sums multiple raw data files and saves the result to a new file.
For images, this will actually average the images. If the images are uint8, it will average directly. If the images are float32, we assume they are in the log-domain and we will do the averaging in the linear domain.
- Parameters:
input_paths (
list[Path]) β List of paths to the input raw data files.output_path (
Path) β Path to the output file where the summed data will be saved.overwrite (bool, optional) β Whether to overwrite the output file if it exists. Defaults to False.