download_prefix#
- torch_brain.utils.s3.download_prefix(bucket, prefix, target_dir, strip_prefix=None, s3_client=None)[source]#
Download all files matching a prefix pattern.
- Parameters:
bucket (
str) – S3 bucket nameprefix (
str) – Key prefix to match filestarget_dir (
Path) – Local directory to download files tostrip_prefix (
Optional[str]) – Prefix to strip from keys when creating local paths. If None, uses the first path component (dataset_id).s3_client (
Optional[BaseClient]) – Optional pre-configured S3 client
- Return type:
- Returns:
List of downloaded file paths
- Raises:
RuntimeError – If download fails or no files match
ImportError – If boto3/botocore is not installed.
Examples
>>> # Basic usage >>> download_prefix( ... bucket="openneuro.org", ... prefix="ds005555/sub-1/eeg/sub-1_task-Sleep", ... target_dir=Path("~/data/raw/brainset_ds005555") ... )
>>> # Custom strip_prefix >>> download_prefix( ... bucket="fcp-indi", ... prefix="data/Projects/EEG_Eyetracking_CMI_data/A00054400", ... target_dir=Path("~/data/raw/brainset_ds005555"), ... strip_prefix="data/Projects/" ... )