bids-standard/bidsutils

Should this repo get 2nd life as bids-cmdline or smth like that?

yarikoptic opened this issue · 3 comments

For a while I felt the need, and at some point expressed it (but forgot where), to get a command line (or may be eventually some GUI) utility to manipulate a BIDS dataset. Quite often due to inherent redundancy, some trivial operations are not that trivial. E.g.

  • renaming a subject (codename subject-rename for now) requires
    • renaming sub- directory
      • possibly also under sourcedata/ (and who knows -- may be .heudiconv/)
    • renaming every file under that directory since they all carry sub- prefix
      • possibly also under sourcedata/
    • fixing up _scans file as well since that is where those files are listed as well
  • remove a subject[/session]
  • remove a run while shifting all subsequent run indexes
  • rename or fix a filename (just rename) - could be used by subject-rename -- since a file might have a side car file, and then listed in _scans, might come handy
    • some non-BIDS compliant file, e.g. having spurious suffix like a _test
  • renaming a session (session-rename)
  • moving into a session (session-rename '' session) -- whenever dataset (or a specific subject?) was collected without any session'ing, and then multiple sessions decided to be taken
  • merge datasets - implementation might relate to Moving into a session. Take two datasets (possibly without sessions) and then merge them either by
    • just combining subjects (and failing if conflicting)
    • placing each one into a (specified) session
    • using subjects (re)mapping file

Ideally the tool should be aware of git and/or git-annex, i.e. that files might be under VCS and then should use corresponding VCS functions.

Originally I thought to propose this development within pybids, but per-se such utility (bids) does not have to (although likely will) be implemented using pybids. Some functionalities, which operate on BIDS-compliant datasets, could be achieved via re-layouting using pybids, but then it should also become capable to capture those under .heudiconv and sourcedata/ which is not strongly "prescribed" in BIDS (there is only a recommendation to follow BIDS naming there as well)

That would be a great tool. Happy to contribute!

I think this kind of functionality could quite comfortably live inside of pybids. Note that per discussion in bids-standard/pybids#63, it's now possible to re-map entire file structures (both within BIDS and to/from other structures) in a pretty elegant way via grabbids/grabbit. The only thing we're missing is a set of output patterns that define all the valid BIDS paths.

This doesn't preclude a utility of the kind you're proposing, of course. From a UI standpoint, users don't want to have to muck around with project-wide remapping, they just want to call session_rename or something. But implementation-wise, I think it would be very nice from an abstraction and maintainability standpoint to implement these kinds of tools as wrappers around the existing grabbids/grabbit functionality.

YES, definitely pybids/grabbids/grabbit should be used as much as possible!
Although it sounds only logical, and makes many things easier, and precedents exist (nibabel providing nib-* utilites), I didn't dare to suggest it to live inside pybids, to not mud the purity of it:

  • pybids might have its own dev/release cycle
  • some utils might come from different languages (bash?)
  • ideally it should be just a "bids" utility, but then "who is pybids to provide bin/bids"? ;)

but yeah, for a quick start could also be done within pybids -- so "to be decided" I guess ;)