diff --git a/circle.yml b/circle.yml index bb1757c..586adfa 100644 --- a/circle.yml +++ b/circle.yml @@ -2,6 +2,7 @@ general: artifacts: - "~/outputs1" - "~/outputs2" + - "~/outputs2_session_label" machine: services: @@ -41,6 +42,9 @@ test: # participant level tests for a longitudinal dataset - docker run -ti --rm --read-only -v /tmp:/tmp -v /var/tmp:/var/tmp -v ${HOME}/data/ds114_test2:/bids_dataset -v ${HOME}/outputs2:/outputs -v ${HOME}/data/ds114_test2_freesurfer:/freesurfer bids/${CIRCLE_PROJECT_REPONAME,,} /bids_dataset /outputs participant --participant_label 01 --license_key="~/test.key" --freesurfer_dir /freesurfer --stages prep && cat ${HOME}/outputs2/sub-01_ses-test.long.sub-01/scripts/trac-preproc.done : timeout: 21600 + # participant level tests for a longitudinal dataset (test session_label flag) + - docker run -ti --rm --read-only -v /tmp:/tmp -v /var/tmp:/var/tmp -v ${HOME}/data/ds114_test2:/bids_dataset -v ${HOME}/outputs2_session_label:/outputs -v ${HOME}/data/ds114_test2_freesurfer:/freesurfer bids/${CIRCLE_PROJECT_REPONAME,,} /bids_dataset /outputs participant --participant_label 01 --session_label retest --license_key="~/test.key" --freesurfer_dir /freesurfer --stages prep && cat ${HOME}/outputs2_session_label/sub-01_ses-retest.long.sub-01/scripts/trac-preproc.done : + timeout: 21600 # group level test for a longitudinal dataset: group1 - docker run -ti --rm --read-only -v /tmp:/tmp -v /var/tmp:/var/tmp -v ${HOME}/data/ds114_test2:/bids_dataset -v ${HOME}/data/ds114_test2_tracula_precomp:/outputs -v ${HOME}/data/ds114_test2_freesurfer:/freesurfer bids/${CIRCLE_PROJECT_REPONAME,,} /bids_dataset /outputs group1 --license_key="~/test.key" --freesurfer_dir /freesurfer && mkdir -p ${HOME}/outputs2/ && sudo mv ${HOME}/data/ds114_test2_tracula_precomp/00_group* ${HOME}/outputs2/ && cat ${HOME}/outputs2/00_group1_motion_stats/group_motion.tsv : timeout: 21600 diff --git a/run.py b/run.py index f2001e1..3486b62 100644 --- a/run.py +++ b/run.py @@ -31,6 +31,13 @@ '(so it does not include "sub-"). If this parameter is not ' 'provided all subjects should be analyzed. Multiple ' 'participants can be specified with a space separated list.', nargs="+") +parser.add_argument('--session_label', + help='The label of the sessions that should be analyzed. The label ' + 'corresponds to ses- from the BIDS spec ' + '(so it does not include "ses-"). If this parameter is not ' + 'provided all sessions should be analyzed. Multiple ' + 'sessions can be specified with a space separated list.', nargs="+") + parser.add_argument('--freesurfer_dir', help='The directory with the freesurfer data. If not specified, ' 'output_dir is assumed to be populated with freesurfer data.') parser.add_argument('--stages', help='Participant-level trac-all stages to run. Passing' @@ -66,7 +73,7 @@ subjects_to_analyze = layout.get_subjects() if args.analysis_level == "participant": - participant_level(args, layout, subjects_to_analyze) + participant_level(args, layout, subjects_to_analyze, args.session_label) elif args.analysis_level == "group1": group_level_motion_stats(args, subjects_to_analyze) diff --git a/tracula.py b/tracula.py index 5589ec4..511e78f 100644 --- a/tracula.py +++ b/tracula.py @@ -227,13 +227,19 @@ def calculate_tmi(df): return df -def participant_level(args, layout, subjects_to_analyze): +def participant_level(args, layout, subjects_to_analyze, sessions_to_analyze): global subject_label, sessions, session_label for subject_label in subjects_to_analyze: subject_session_info = OrderedDict() valid_sessions = [] sessions = layout.get_sessions(subject=subject_label) + if sessions_to_analyze: + sessions_not_found = list(set(sessions_to_analyze) - set(sessions)) + sessions = list(set(sessions) & set(sessions_to_analyze)) + if sessions_not_found: + print("requested sessions %s not found for subject %s" % (" ".join(sessions_not_found), subject_label)) + if sessions: # long for session_label in sessions: