The download.py module#

Summary#

download_case_from_zenodo

Download a case from the remote repository.

unpack_case

Unpack the downloaded tarball file.

download_all_cases

Download all supported cases.

unpack_cases

Unpack a list of TAR files.

Description#

Module containing methods to download cases from public databases.

Module detail#

download.download_case_from_zenodo(database: str, case_number: int, download_folder: pathlib.Path, overwrite: bool = True, validate_hash: bool = True) pathlib.Path | None#

Download a case from the remote repository.

Parameters:
databasestr

name of the database. Options are 'Strocchi2020' or 'Rodero2021'.

case_numberint

Case number to download.

download_folderPath

Path to the folder to download the case to.

Returns:
Path

Path to the tarball that contains the VTK/CASE files.

Examples

Download case 1 from the public repository ('Strocchi2020') of pathological hearts.

>>> path_to_tar_file = download_case_from_zenodo(
    database="Strocchi2020", case_number=1, download_folder="my/download/folder"
    )

Download case 1 from the public repository ('Rodero2021') of healthy hearts.

>>> path_to_tar_file = download_case_from_zenodo(
    database="Rodero2021", case_number=1, download_folder="my/download/folder"
    )
download.unpack_case(tar_path: pathlib.Path, reduce_size: bool = True) str | bool#

Unpack the downloaded tarball file.

Parameters:
tar_pathPath

Path to TAR.GZ file.

reduce_sizebool, default: True

Whether to reduce the size of the unpacked files by removing the VTK file for the Strocchi database.

Returns:
str

Path to the CASE or VTK file.

Examples

>>> from ansys.health.heart.utils.download import unpack_case
>>> path = unpack_case("Rodero2021\\01.tar.gz")
download.download_all_cases(download_dir: str = None) list[str]#

Download all supported cases.

Parameters:
download_dirstr

Base directory to download cases to.

Notes

Note that depending on bandwidth, downloading all cases might take a lot of time.

Examples

>>> from ansys.health.heart.utils.download import download_all_cases
>>> tar_files = download_all_cases("my-downloads")

To unpack all cases, you can use the unpack_cases() method:

>>> from ansys.health.heart.utils.download import unpack_cases
>>> unpack_cases(tar_files)
download.unpack_cases(list_of_tar_files: List) None#

Unpack a list of TAR files.

Parameters:
list_of_tar_filestyping.List

List of TAR files to unpack.

Examples

>>> from ansys.health.heart.utils.download import unpack_cases
>>> unpack_cases(["01.tar.gz", "02.tar.gz"])