rf(schema): Make participants/sessions.tsv content available, add glob() and zip() functions#2359
rf(schema): Make participants/sessions.tsv content available, add glob() and zip() functions#2359effigies wants to merge 6 commits into
Conversation
|
Related validator PR bids-standard/bids-validator#366 |
| additionalProperties: | ||
| type: array | ||
| items: | ||
| type: string |
There was a problem hiding this comment.
FWIW, in
I proposed to extend with sessions attribute here as to follow the summaries like datatypes etc. I wonder if overall it makes sense to have both summaries and then access to particular crucial .tsvs because they seems to be complimentary as it was original subjects which would have sub_dirs and thus relating to actual data folders (thus beyond what is in the _tsv; and caching file system operations like glob).
Or may be, if refactoring already and seems keeping them 'generic' "tsv files", make it into tsv_files thus making it possible to accommodate other files without changes to context schema, e.g. tsv_files["participants.tsv"] and tsv_files["sessions.tsv"] which could be complimented then with tsv_files["participant+sessions.tsv"] ...
btw is intention here to have sessions_tsv appropriate for the folder, as e.g. under sub-X to be the sub-X/sub-X_sessions.tsv (and whatever inheritance brings from the top level sessions.tsv?
There was a problem hiding this comment.
This is specifically a top-level sessions.tsv file, as it goes in the dataset context, which does not change as we walk over the file tree.
Maybe we can talk over the design on some schema call?
BEP36 proposes more extensive checks comparing the contents of
/participants.tsv,/sessions.tsvand/phenotype/*.tsvto one another and other session directories. This PR introduces schema changes to facilitate this.We require access to at least
sessions.tsvcontents, and we (@rwblair and I) proposedataset.sessions_tsvas an object mapping column headers onto column contents.For consistency, and because the
dataset.subjectscontext object is an awkward way of accessing the various lists of subject IDs, we propose to makedataset.participants_tsvalong the same lines, withdataset.participants_tsv.participant_idrendering obsoletedataset.subjects.participant_id.We also need to collate rows across columns. The natural operation in Python is
zip(), so we propose that here. It is not used in any checks, yet.With
dataset.subjects.sub_dirsbeing the only remaining content ofdataset.subjects, a more general way of achieving the same goal was desired. Aglob()function seems to fit the bill, which can be used to create lists of files in selectors/checks. This PR demonstrates the use ofglob()anddataset.participants_tsvto obsoletedataset.subjectsaltogether.Would be interested in people's thoughts on these changes. Open to any alternatives.
Additional thoughts on refactoring the validation context
I think the validation context is due a bit of a rethink after a couple years, and getting rid of
dataset.subjectsI think is a good idea regardless of what happens to BEP36, but I'm not married to this approach. I think we should aim for consistency and get rid ofsubject.sessions(and maybesubject), but that hasn't been thought through, yet.Other things in the context that are as-yet unused:
dataset.tree- Theexists()and here-introducedglob()functions do what we might imagine this object should do. Unclear how it could be used without functions or at least comprehensions and predicates.dataset.ignored- There may be checks to write using this, but until we try, it's unclear if this is the right interface.Things that might be reconsidered:
fileobject that represent the file. Perhaps collating the filepath, and similar general filesystem-level attributes should intofile.pathand so-on would make sense.file?file.nifti_headerorfile.columnsmake sense. That said, I'm inclined to leavefileto just contain the fields that do not need more than astatto establish. The principle could bedatasetis populated at validation start,fileis populated when reading the filesystem metadata,nifti_headerand so on require additional opens or computations to populate.cc @ericearl @surchs