bids-specification icon indicating copy to clipboard operation
bids-specification copied to clipboard

Implement basic function for inheritance principle support within bidsschematools

Open yarikoptic opened this issue 2 years ago • 0 comments

NB Originally was destined to be posted as reply in https://github.com/bids-standard/bids-specification/issues/102 but then I decided to make it a separate issue.

A single function cannot cover the entirety of the Inheritance Principle (IP below). I see different target needs:

  • need for validation -- formulated in text and implemented within validator(s) in multiple (!) checks:
    • a file path, if not of a known other file type (top level, a known leaf file) can be considered to be a file to be inherited from. IP 1,2 and #1003 by @TheChymera provides that implementation.
    • additional errors: implementations of IP 3,4
    • warning level (REF-WARNINGS):
      • a file path determined to be of "inheritance group" must have at least one file present it gets "inherited from" (I think current IP lacks that RECOMMENDED)
      • common metadata should be stored in a single location following RECOMMENDed IP Corollary 2.
  • need for use:
    • get_metadata_files(path: Path) -> list[Path] - given that data (metadata) input path would provide all (available in the dataset) files in the order to be loaded to establish the metadata record. Such function would also be helpful for a validator mode to operate on a "partial BIDS dataset" (e.g. a single subj/ses) as we might need (per our discussion with @satra and @TheChymera ): IP 2-3.
      • reciprocally to this, for validation of REF-WARNINGS above having get_affected_files(path: Path) -> list[Path] would be of great help to see which files would consider a given metadata file path due to inheritance principle. Such functionality would also be greatly useful for some hypothetical bids move so people could get informed while doing smth like bids move task-1_bold.json task-2_bold.json on the top level and thus affecting files down under.
    • get_metadata(path: Path) -> dict - given the data (or even metadata?) file path, load all pertinent metadata. Internally uses get_metadata_files first to get the list of files and then loads them: IP 5. Yet to be coded AFAIK in bidsschematools.

Given your work on #1003, do you think @TheChymera you could provide such get_metadata_files(path: Path) -> list[Path] implementation of get_metadata_files following the current set of IP rules?

PS also filed #1180 which would eventually relate here as inheritance principle would require querying filesystem for availability of a particular filename.

yarikoptic avatar Aug 03 '22 19:08 yarikoptic