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 name

  • prefix (str) – Key prefix to match files

  • target_dir (Path) – Local directory to download files to

  • strip_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:

list[Path]

Returns:

List of downloaded file paths

Raises:

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/"
... )