zea.data.convert.utils

Functions

download_from_girder(collection_id, ...[, ...])

Download a dataset from the Girder server.

load_avi(file_path[, mode])

Load a .avi file and return a numpy array of frames.

sitk_load(filepath[, squeeze])

Load a NIfTI/medical image using SimpleITK and return the array and metadata.

unzip(src, dataset)

Checks if data folder exist in src.

zea.data.convert.utils.download_from_girder(collection_id, destination, dataset_name, patients=None, top_folder_name='dataset')[source]

Download a dataset from the Girder server.

Navigates the Girder collection to find patient folders and downloads all files for each patient. Existing files are skipped.

Parameters:
  • collection_id (str) – Girder collection ID for the dataset.

  • destination (str | Path) – Directory where the dataset will be downloaded.

  • dataset_name (str) – Human-readable name used in log messages (e.g. "CAMUS" or "CETUS").

  • patients (list[int] | None) – Optional list of patient IDs to download. If None, all patients in the collection are downloaded.

  • top_folder_name (str) – Name of the top-level folder inside the collection that contains patient subfolders. Defaults to "dataset".

Return type:

Path

Returns:

Path to the downloaded dataset directory.

zea.data.convert.utils.load_avi(file_path, mode='L')[source]

Load a .avi file and return a numpy array of frames.

Parameters:
  • filename (str) – The path to the video file.

  • mode (str, optional) – Color mode: “L” (grayscale) or “RGB”. Defaults to “L”.

Returns:

Array of frames (num_frames, H, W) or (num_frames, H, W, C)

Return type:

numpy.ndarray

zea.data.convert.utils.sitk_load(filepath, squeeze=False)[source]

Load a NIfTI/medical image using SimpleITK and return the array and metadata.

Parameters:
  • filepath (str | Path) – Path to the image file.

  • squeeze (bool) – If True, squeeze singleton dimensions from the array. Defaults to False.

Returns:

  • Image array. Shape depends on the input and the squeeze parameter.

  • Dictionary of metadata: origin, spacing, direction, size, dimension, and a metadata sub-dict with all image metadata keys.

Return type:

Tuple of

zea.data.convert.utils.unzip(src, dataset)[source]

Checks if data folder exist in src. Otherwise, unzip dataset.zip in src.

Parameters:
  • src (str | Path) – The source directory containing the zip file or unzipped folder.

  • dataset (str) – The name of the dataset to unzip. Options are “picmus”, “camus”, “echonet”, “echonetlvh”.

Returns:

The path to the unzipped dataset directory.

Return type:

Path