Skip to content

Stop pybids indexing the insides of image containers - #194

Closed
Arshya-Guru wants to merge 1 commit into
plaquesfrom
login-friendly-launch
Closed

Stop pybids indexing the insides of image containers#194
Arshya-Guru wants to merge 1 commit into
plaquesfrom
login-friendly-launch

Conversation

@Arshya-Guru

Copy link
Copy Markdown

pybids walks into directory-based image containers (.ims, .ome.zarr) and indexes every internal chunk file: on a 24-subject dataset that is ~645k of ~645k rows, costing ~8.5 GB RAM and 5+ minutes at every launch, which now exceeds the login node's 1.5 GB hard memory cap. Only the container path itself is a BIDS file, so prune descent into containers by overriding the BIDSLayoutIndexer constructor snakebids uses (it does not expose the indexer's ignore patterns). Dry-run peak memory drops from 8.5 GB to 381 MB and launch overhead from ~5.5 min to ~21 s, with a byte-identical job list.

pybids walks into directory-based image containers (.ims, .ome.zarr) and
indexes every internal chunk file: on a 24-subject dataset that is ~645k
of ~645k rows, costing ~8.5 GB RAM and 5+ minutes at every launch, which
now exceeds the login node's 1.5 GB hard memory cap. Only the container
path itself is a BIDS file, so prune descent into containers by
overriding the BIDSLayoutIndexer constructor snakebids uses (it does not
expose the indexer's ignore patterns). Dry-run peak memory drops from
8.5 GB to 381 MB and launch overhead from ~5.5 min to ~21 s, with a
byte-identical job list.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012437t8NSZLaZAwoAWK6bNT

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses excessive startup time and memory usage caused by pybids recursively indexing directory-based image containers (e.g., .ims, .ome.zarr) as if their internal chunk files were individual BIDS files. It mitigates this within the Snakemake entrypoint by overriding the indexer constructor that snakebids uses, pruning descent into such containers while preserving pybids’ default ignore locations.

Changes:

  • Override snakebids.core.input_generation.BIDSLayoutIndexer at Snakefile import time to inject additional ignore patterns for container directories.
  • Re-include pybids’ DEFAULT_LOCATIONS_TO_IGNORE so the override doesn’t drop the built-in ignore set.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +21 to +26
def _container_pruning_indexer(*args, **kwargs):
kwargs["ignore"] = list(_DEFAULT_IGNORE) + [
_re.compile(r".*\.(ims|ome\.zarr|zarr)/")
]
return _BIDSLayoutIndexer(*args, **kwargs)

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.

2 participants