Skip to content

Default-skip stimuli/ and derivatives/ on download and get - #405

Merged
neuromechanist merged 4 commits into
devfrom
feature/issue-402-skip-stimuli-derivatives
May 10, 2026
Merged

neuromechanist merged 4 commits into
devfrom
feature/issue-402-skip-stimuli-derivatives

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Closes #402

Summary

Some NEMAR datasets will soon ship stimuli/ files inside the dataset tree, and derivatives/ folders are already common on existing datasets. Both can be very large and most users don't need them on first download. This PR makes the default behavior of nemar dataset download and nemar dataset get skip annex content under those folders, with new opt-in flags to fetch them.

The git-annex pointer files (symlinks) are still cloned, so the dataset tree is intact and users can fetch the content later with nemar dataset get --stimuli or nemar dataset get --derivatives.

Behavior

  • nemar dataset download nm000104 skips stimuli/** and derivatives/** (top-level and nested).
  • nemar dataset download nm000104 --stimuli includes stimuli/ content.
  • nemar dataset download nm000104 --stimuli --derivatives includes both.
  • nemar dataset get (no arg) follows the same default skip; pass --stimuli/--derivatives to opt in.
  • nemar dataset get stimuli/ (explicit path) bypasses the default skip, so naming a path Just Works.
  • --no-data still skips everything (unchanged).

Implementation

  • src/lib/bids-filter.ts: new excludeStimuli/excludeDerivatives options append the appropriate --exclude glob pairs. They do NOT flip the existing active flag, so the existing --no-data + filters conflict check still only triggers on explicit user filters.
  • src/lib/git-annex.ts: countPendingDownload now accepts an extraArgs parameter so the progress-bar precount applies the same matchers the subsequent git annex get will use.
  • src/commands/dataset.ts: both download and get learn --stimuli and --derivatives. The parent nemar dataset --help now explicitly contrasts the two: download runs OUTSIDE a dataset directory (one-shot clone + fetch), get runs INSIDE an already-cloned dataset directory (fetch only).

Tests

  • 6 new tests in test/bids-filter.test.ts covering default-skip, opt-in, composition with positive filters, ordering of default vs user excludes, and the active flag invariant.
  • Updated test/cli.test.ts to assert the new flags appear in --help and that the parent --help-all spells out the download-vs-get distinction.

Test plan

  • bun test test/bids-filter.test.ts (24 pass)
  • bun test test/git-annex-precount.test.ts (5 pass)
  • bun test test/cli.test.ts -t "Dataset Download" (4 pass, 0 fail)
  • bun run build (clean)
  • Manual smoke test against a dataset with a stimuli/ folder once one exists

Add excludeStimuli/excludeDerivatives options to buildBidsFilterArgs that emit '--exclude' patterns for stimuli/** and derivatives/** (top-level and nested). The defaults do not flip 'active', so callers using --no-data are unaffected.

countPendingDownload now accepts extraArgs so the precount sees the same matchers as the subsequent 'git annex get' run, keeping the progress denominator accurate.

Refs #402
Wire the new exclude options into 'nemar dataset download' and 'nemar dataset get'. Both default-skip stimuli/ and derivatives/; --stimuli and --derivatives opt back in. The pointer files are still cloned, so users can fetch the content later.

For 'get', the default-skip applies only when no explicit paths are given. Naming a path is treated as the user's explicit filter, so 'nemar dataset get stimuli/' does what you'd expect.

Also clarifies the parent 'nemar dataset --help' to spell out that 'download' runs OUTSIDE a dataset directory (one-shot clone+fetch) while 'get' runs INSIDE an already-cloned dataset directory (fetch only).

Closes #402
Document the new --stimuli/--derivatives flags in docs/guides/downloading.md and docs/commands/dataset.md. Also note that explicit paths in 'get' bypass the default-skip.

Refs #402
Three fixes from review:

1. get command was printing the 'skipping stimuli/' summary AFTER the 'All data files already present' early-return, so users with stimuli-only datasets never saw the hint. Move the summary print above the early-return.

2. Help text claimed default-skip applies to 'downloads' generally, but OpenNeuro datasets go through a different code path that ignores the flags. Qualify the wording to NEMAR datasets and explicitly note OpenNeuro behavior.

3. Refine excludeStimuli/excludeDerivatives JSDoc to describe what the function does (emit excludes) rather than describe the surrounding workflow (clone+pointer behavior is true but not a property of this function).

Three new tests, regression guards for review-flagged gaps:

- New chooseGetFilter helper centralizes 'explicit paths bypass default-skip' rule + 6 unit tests so a future refactor can't silently break 'nemar dataset get stimuli/'.
- CLI test asserting 'nemar dataset download <id> --no-data' does NOT trigger the 'filters imply data download' conflict (depends on default excludes not flipping filter.active).
- countPendingDownload extraArgs test: clone with both data.bin and stimuli/sound.bin pending, assert unfiltered=2/300B and stimuli-excluded=1/100B.

Refs #402
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review pass complete. Fixes pushed in 0f09228.

Critical fixes (silent-failure-hunter + comment-analyzer):

  • get command: moved filter.summary print above the pending.fileCount === 0 early-return, so users with stimuli-only datasets see the skip hint before "All data files already present".
  • Help text: qualified default-skip wording to NEMAR datasets and explicitly noted OpenNeuro ds###### downloads ignore the flags (they go through a different code path).
  • JSDoc: refined excludeStimuli/excludeDerivatives descriptions to describe what the function does, not the surrounding workflow.

Test gap fixes (pr-test-analyzer):

  • Extracted chooseGetFilter(paths, options) helper that encapsulates the "explicit paths bypass default-skip" rule; added 6 unit tests so a future refactor can't silently break nemar dataset get stimuli/.
  • New CLI test asserts nemar dataset download <id> --no-data does NOT trigger the "filters imply data download" conflict (regression guard for the filter.active semantics that intentionally exclude default skips).
  • New countPendingDownload test exercises the extraArgs path end-to-end with a real git-annex repo: clone with data.bin + stimuli/sound.bin pending, assert unfiltered count is 2/300B and stimuli-excluded count is 1/100B.

Skipped findings (out of scope or accepted):

  • Pre-existing precount-vs-get mismatch in --update mode (precount uses ., get uses updatePaths) noted by code-reviewer; not introduced here.
  • Cosmetic note about --no-stimuli Commander-auto-negation being a no-op: harmless, undocumented.

All 36 unit tests pass; all 5 Dataset Download CLI tests pass; build clean.

@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR405

Version: 0.8.9-PR405.0f09228
Commit: 0f09228


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 0fcc9bc into dev May 10, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-402-skip-stimuli-derivatives branch May 10, 2026 21:44

This branch was previously deployed

1 inactive deployment
npm — 0f092288 Deployed May 10, 2026 by neuromechanist via publish #709
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant