Skip to content

dataset download: add BIDS entity filters (--subjects, --tasks, --runs, --datatypes, --include, --exclude) #365

Closed

Description

@neuromechanist

Summary

nemar dataset download <id> always pulls the full annex contents. For multi-GB datasets where the user only wants a few subjects or one task, this wastes bandwidth + time. Add BIDS entity filters that pass through to git annex get --include/--exclude so the clone stays a structurally valid BIDS dataset (all symlinks present) but only matching files have content locally.

Inspired by openneuro-py which exposes --include/--exclude. NEMAR upgrade: BIDS-aware shortcuts.

Proposed flags (on nemar dataset download only)

Flag Example Maps to
--subjects sub-01,02 --include='sub-01/**' --include='sub-02/**'
--sessions ses-pre,post --include='**/ses-pre/**' --include='**/ses-post/**'
--tasks rest,nback --include='**/*_task-rest_*' --include='**/*_task-nback_*'
--runs 1,2 expands both padded + unpadded: *_run-1_*, *_run-01_*, *_run-2_*, *_run-02_*
--datatypes eeg,emg --include='**/eeg/**' --include='**/emg/**'
--include 'sub-01/eeg/*.edf' pass-through (repeatable + comma-list)
--exclude 'derivatives/**' pass-through (repeatable + comma-list)

Locked decisions

  • Entity normalization: accept 01 and sub-01; strip prefix if present, re-add when building globs.
  • Run zero-padding: --runs 1 matches both run-1 and run-01 (expand both globs).
  • --no-data mutex: --no-data + any filter is an error (explicit, since they conflict).
  • Essential BIDS files: handled automatically by the existing largefiles config (*.tsv/*.json/README/LICENSE/CHANGES/.bidsignore are not annexed; they land via git clone).
  • Filters apply only to download, not get: keeps nemar dataset get simple; users can re-run git annex get <path> to pull more later.

Why pass-through to git-annex

git-annex already implements glob matching (--include/--exclude). No need for a JS BIDS parser. Each flag becomes a small list of globs appended to the git annex get call. ~50 LOC, not 250.

Files touched

  • src/commands/dataset.ts — download action: parse flags, build glob list, pass to getDatasetData
  • src/lib/git-annex.ts — extend getDatasetData options to accept includes: string[] / excludes: string[]
  • New: src/lib/bids-filter.ts — small flag→glob translator (entity normalization, run-padding expansion)
  • Tests: unit test the translator (pure function), add one --subjects step to test/e2e-test.ts against nm099999

Acceptance

  • nemar dataset download nm000132 --subjects sub-01 clones the full repo (metadata + symlinks intact, valid BIDS) and only pulls annex content for sub-01/**.
  • nemar dataset download nm000132 --subjects 01,02 --tasks rest filters to those subjects ∩ tasks (intersection of include groups).
  • nemar dataset download nm000132 --runs 1 matches both run-1 and run-01.
  • nemar dataset download nm000132 --no-data --subjects sub-01 errors with "cannot combine --no-data with filters".
  • After a filtered download, git annex get <other-path> works to pull more files.

Related

Bundled with #347 (--resume) and #348 (--update) in a single PR (feature/issue-347-348-N-download-ux).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions