Skip to content

Commit 42b403d

Browse files
authored
Merge pull request #18 from BIDS-Apps/sessid
added session_label flag
2 parents a4fc826 + 75c0a74 commit 42b403d

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

circle.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ general:
22
artifacts:
33
- "~/outputs1"
44
- "~/outputs2"
5+
- "~/outputs2_session_label"
56

67
machine:
78
services:
@@ -41,6 +42,9 @@ test:
4142
# participant level tests for a longitudinal dataset
4243
- 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 :
4344
timeout: 21600
45+
# participant level tests for a longitudinal dataset (test session_label flag)
46+
- 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 :
47+
timeout: 21600
4448
# group level test for a longitudinal dataset: group1
4549
- 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 :
4650
timeout: 21600

run.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131
'(so it does not include "sub-"). If this parameter is not '
3232
'provided all subjects should be analyzed. Multiple '
3333
'participants can be specified with a space separated list.', nargs="+")
34+
parser.add_argument('--session_label',
35+
help='The label of the sessions that should be analyzed. The label '
36+
'corresponds to ses-<session_label> from the BIDS spec '
37+
'(so it does not include "ses-"). If this parameter is not '
38+
'provided all sessions should be analyzed. Multiple '
39+
'sessions can be specified with a space separated list.', nargs="+")
40+
3441
parser.add_argument('--freesurfer_dir', help='The directory with the freesurfer data. If not specified, '
3542
'output_dir is assumed to be populated with freesurfer data.')
3643
parser.add_argument('--stages', help='Participant-level trac-all stages to run. Passing'
@@ -66,7 +73,7 @@
6673
subjects_to_analyze = layout.get_subjects()
6774

6875
if args.analysis_level == "participant":
69-
participant_level(args, layout, subjects_to_analyze)
76+
participant_level(args, layout, subjects_to_analyze, args.session_label)
7077

7178
elif args.analysis_level == "group1":
7279
group_level_motion_stats(args, subjects_to_analyze)

tracula.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,19 @@ def calculate_tmi(df):
227227
return df
228228

229229

230-
def participant_level(args, layout, subjects_to_analyze):
230+
def participant_level(args, layout, subjects_to_analyze, sessions_to_analyze):
231231
global subject_label, sessions, session_label
232232
for subject_label in subjects_to_analyze:
233233
subject_session_info = OrderedDict()
234234
valid_sessions = []
235235

236236
sessions = layout.get_sessions(subject=subject_label)
237+
if sessions_to_analyze:
238+
sessions_not_found = list(set(sessions_to_analyze) - set(sessions))
239+
sessions = list(set(sessions) & set(sessions_to_analyze))
240+
if sessions_not_found:
241+
print("requested sessions %s not found for subject %s" % (" ".join(sessions_not_found), subject_label))
242+
237243
if sessions:
238244
# long
239245
for session_label in sessions:

0 commit comments

Comments
 (0)