zea.data.convert.echonetlvh

Script to convert the EchoNet-LVH database to zea format.

Each video is cropped so that the scan cone is centered without padding, such that it can be converted to polar domain.

Note

This cropping requires first computing scan cone parameters using zea.data.convert.echonetlvh.precompute_crop, which are then passed to this script.

For more information about the dataset, resort to the following links:

  • The original dataset can be found at this link.

Functions

convert_echonetlvh(args)

Conversion script for the EchoNet-LVH dataset.

convert_measurements_csv(source_csv, output_csv)

Convert measurements CSV file with updated coordinates using cone parameters.

crop_frame_with_params(frame, cone_params)

Crop a single frame using predetermined cone parameters.

crop_sequence_with_params(sequence, cone_params)

Apply cropping to a sequence of frames using predetermined parameters.

find_avi_file(source_dir, hashed_filename[, ...])

Find AVI file in the specified batch directory or any batch if not specified.

load_cone_parameters(csv_path)

Load cone parameters from CSV file into a dictionary.

load_splits(source_dir)

Load splits from MeasurementsList.csv and return avi filenames

overwrite_splits(source_dir[, rejection_path])

Overwrite MeasurementsList.csv splits based on manual_rejections.txt or another txt file specifying which hashes to reject.

transform_measurement_coordinates_with_cone_params(...)

Transform measurement coordinates using cone parameters from fit_scan_cone.

Classes

LVHProcessor(*args[, cone_params])

Modified H5Processor for EchoNet-LVH dataset.

class zea.data.convert.echonetlvh.LVHProcessor(*args, cone_params=None, **kwargs)[source]

Bases: H5Processor

Modified H5Processor for EchoNet-LVH dataset.

__call__(avi_file)[source]

Takes a single avi_file and generates a zea dataset

Parameters:

avi_file – String or path to avi_file to be processed

Returns:

zea dataset

get_split(avi_file, sequence)[source]

Get the split (train/val/test) for a given AVI file.

Parameters:
  • avi_file (str) – Path to the AVI file

  • sequence – Video sequence (unused)

Returns:

String indicating the split (‘train’, ‘val’, or ‘test’)

zea.data.convert.echonetlvh.convert_echonetlvh(args)[source]

Conversion script for the EchoNet-LVH dataset. Unzips, overwrites splits if needed, precomputes cone parameters, and converts images and/or measurements to zea format and saves dataset. Is called with argparse arguments through zea/zea/data/convert/__main__.py

Parameters:

args (argparse.Namespace) – Command-line arguments

zea.data.convert.echonetlvh.convert_measurements_csv(source_csv, output_csv, cone_params_csv=None)[source]

Convert measurements CSV file with updated coordinates using cone parameters.

Parameters:
  • source_csv – Path to source CSV file

  • output_csv – Path to output CSV file

  • cone_params_csv – Path to CSV file with cone parameters

zea.data.convert.echonetlvh.crop_frame_with_params(frame, cone_params)[source]

Crop a single frame using predetermined cone parameters.

Parameters:
  • frame – Input frame as numpy array

  • cone_params – Dictionary containing cropping parameters

Returns:

Cropped and padded frame

zea.data.convert.echonetlvh.crop_sequence_with_params(sequence, cone_params)[source]

Apply cropping to a sequence of frames using predetermined parameters.

Parameters:
  • sequence – Input sequence as numpy array of shape (frames, height, width)

  • cone_params – Dictionary containing cropping parameters

Returns:

Cropped and padded sequence

zea.data.convert.echonetlvh.find_avi_file(source_dir, hashed_filename, batch=None)[source]

Find AVI file in the specified batch directory or any batch if not specified.

Parameters:
  • source_dir – Source directory containing BatchX subdirectories

  • hashed_filename – Hashed filename (with or without .avi extension)

  • batch – Specific batch directory to search in (e.g., “Batch2”), or None to search all batches

Returns:

Path to the AVI file if found, else None

zea.data.convert.echonetlvh.load_cone_parameters(csv_path)[source]

Load cone parameters from CSV file into a dictionary.

Parameters:

csv_path – Path to the CSV file containing cone parameters

Returns:

Dictionary mapping avi_filename to cone parameters

zea.data.convert.echonetlvh.load_splits(source_dir)[source]

Load splits from MeasurementsList.csv and return avi filenames

Parameters:

source_dir – Source directory containing MeasurementsList.csv

Returns:

Dictionary with keys ‘train’, ‘val’, ‘test’, ‘rejected’ and values as lists of avi filenames

zea.data.convert.echonetlvh.overwrite_splits(source_dir, rejection_path=None)[source]

Overwrite MeasurementsList.csv splits based on manual_rejections.txt or another txt file specifying which hashes to reject.

Parameters:
  • source_dir – Source directory containing MeasurementsList.csv and manual_rejections.txt

  • rejection_path – Path to the rejection txt file. If None, defaults to ./manual_rejections.txt

Returns:

None

zea.data.convert.echonetlvh.transform_measurement_coordinates_with_cone_params(row, cone_params)[source]

Transform measurement coordinates using cone parameters from fit_scan_cone.

Parameters:
  • row – A dict containing measurement data with X1,X2,Y1,Y2 coordinates

  • cone_params – Dictionary containing cone parameters from fit_scan_cone

Returns:

A new row with transformed coordinates, or None if cone_params is None

Modules

precompute_crop

Script to precompute cone parameters for the EchoNet-LVH dataset.