spyrit.misc.load_data.download_girder

spyrit.misc.load_data.download_girder(server_url: str, hex_ids: str | list[str], local_folder: str, file_names: str | list[str] = None)[source]

Downloads data from a Girder server and saves it locally.

This function first creates the local folder if it does not exist. Then, it connects to the Girder server and gets the file names for the files whose name are not provided. For each file, it checks if it already exists by checking if the file name is already in the local folder. If not, it downloads the file.

Args:

server_url (str): The URL of the Girder server.

hex_id (str or list[str]): The hexadecimal id of the file(s) to download. If a list is provided, the files are downloaded in the same order and are saved in the same folder.

local_folder (str): The path to the local folder where the files will be saved. If it does not exist, it will be created.

file_name (str or list[str], optional): The name of the file(s) to save. If a list is provided, it must have the same length as hex_id. Each element equal to None will be replaced by the name of the file on the server. If None, all the names will be obtained from the server. Default is None. All names include the extension.

Raises:

ValueError: If the number of file names provided does not match the number of files to download.

Returns:

list[str]: The absolute paths to the downloaded files.