Skip to content

Commit

Permalink
Allows to select more than one session.
Browse files Browse the repository at this point in the history
  • Loading branch information
pvelasco committed Oct 7, 2019
1 parent 1c8ac24 commit 0a8ae7b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def run(command, env={}):
print("INFO: Starting pydeface")
print("INFO: Loading bids directory")
layout = BIDSLayout(args.bids_dir)
session_to_analyze = ""
sessions_to_analyze = []
if args.session_label:
session_to_analyze = args.session_label[0]
sessions_to_analyze = args.session_label

subjects_to_analyze = []
# only for a subset of subjects
Expand Down Expand Up @@ -100,18 +100,20 @@ def run(command, env={}):
# 'T1w', 'T2w', 'bold', ... are "suffixes". ('dwi' is both).
# So we need to make sure we call layout.get with the correct argument names:
myKwarg = {"datatype" : modality} if modality in ['anat','func','fmap'] else {"suffix" : modality}
# get filenames matching:
if session_to_analyze is not "":
print("Session: %s"% session_to_analyze)
myKwarg['session']=session_to_analyze
if sessions_to_analyze:
print("Sessions: %s"% sessions_to_analyze)
myKwarg['session']=sessions_to_analyze

# get filenames matching:
myImages = layout.get(subject=subject_label,
**myKwarg,
extensions=["nii.gz", "nii"],
return_type='file')

if (len(myImages) == 0):
print("No {0} images found for subject {1}".format(modality, subject_label))
if sessions_to_analyze:
print(" for session(s) {0}".format(sessions_to_analyze))

toBeProcessed.update(myImages)

Expand Down

0 comments on commit 0a8ae7b

Please sign in to comment.