feat: read sessions.tsv files + pytest - #46
Conversation
work in progress! For issue bids-standard#35 Still need to test everything together for ses and non-ses versions Strategy is to merge participants.tsv and any sessions.tsv sex and age can come from either but prefers session.tsv (for all sessions if exists for any) can omit scans.tsv file if acq_time column is in sessions but will use scans.tsv regardless when it exists Created many empty nii.gz and .json files for testing. Refactored reading scan file (`read_scan_date`) and created a few new functions for testing and __init__.py imports main for easy pytest python3 -m pytest tests/ Makefile documents call, only runs on change; 'make test' writes .test
eb2dcfb to
43d5954
Compare
Moved arg parsing and csv write out of run
Still writes metadata zip files inside run
examples/bids-* files now non-empty
* '{}' for most json, '{"TaskName": "rest"}' for task-rest
* AFNI 3dUndump to create minimal nifti files
* fix example tsv errors
- sub-a_ses-1_scans.tsv gets session in filename column
- sub-b_scans.tsv references sub-b instead of sub-a (prev unmodded copy)
Initial tests for `run()`. Formatted with black.
Confirm `ses` and `noses` pulls `acq_times` from scans.tsv or sessions.tsv
For ses, scans.tsv can overwrite session.tsv
|
this seems to be like a dump also of examples, some scripts there etc... could this may be shrunk to specifically what was desribed? (get rid of examples?) |
|
Thanks for looking! I'm also uncomfortable with how large the change set is. Tests for the new session parsing code (tests/test_session.py) currently use Alternatives:
Case for keeping:
|
|
I lean somewhat towards Here, fixtures would allow for flexible configuration of various setups to try against, so hardcoding to one specific IMHO would be inefficient... since python, indeed creating some fixture and generate on the fly likely would be best for now (I bet |
For issue #35 - sessions.tsv can handle age changes across session
Sorry for the large diff. I wanted tests to confirm I didn't add obvious regressions. Doing so included some light refactoring. Would seem reasonable to reject for that reason alone -- too much changed.
This commit creates
read_participant_infoto read in all session.tsv files and merge with participants.tsvFor testing
{}and{"TaskName":..})participant.tsv,session.tsvandscans.tsvexamples/Also for testing, some of
runwas refactored into dedicated functionsreading scan file (
read_scan_date)parse_argsargument parsing__init__.pyimportsmainfor easy pytestThe session reading strategy is to merge
participants.tsvand anysessions.tsvfiles.sexandagecan come from either butsession.tsvcolumns are preferred for all sessions if any column exists in any session.tsv.The
scans.tsvfile can now be omitted ifacq_timecolumn is insessions.tsvbutacq_timematches inscans.tsvwill be used oversessoin.tsvwhen the former file exists.