download_prefix#

brainsets.utils.s3_utils.download_prefix(bucket, prefix, target_dir, strip_prefix=None, s3_client=None)[source]#

Download all files matching a prefix pattern.

Parameters:
  • bucket – S3 bucket name

  • prefix – Key prefix to match files

  • target_dir – Local directory to download files to

  • strip_prefix – Prefix to strip from keys when creating local paths. If None, uses the first path component (dataset_id).

  • s3_client – Optional pre-configured S3 client

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