Skip to content

Commit

Permalink
Merge pull request #18 from BIDS-Apps/sessid
Browse files Browse the repository at this point in the history
added session_label flag
  • Loading branch information
fliem authored Jun 8, 2017
2 parents a4fc826 + 75c0a74 commit 42b403d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ general:
artifacts:
- "~/outputs1"
- "~/outputs2"
- "~/outputs2_session_label"

machine:
services:
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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-<session_label> 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'
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion tracula.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 42b403d

Please sign in to comment.