Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
subjs = as_list(subj)
assert subj in subjs, "subject {} is not in the bids folder".format(subj)
for sub in subjs:
if not sesh:
seshs = layout.get_sessions(subject=sub, derivatives=False)
# in case there are non-session level inputs
seshs += [None]
else:
# make a list so we can iterate
seshs = as_list(sesh)
if not task:
tasks = layout.get_tasks(subject=sub, derivatives=False)
tasks += [None]
else:
tasks = as_list(task)
if not run:
runs = layout.get_runs(subject=sub, derivatives=False)
runs += [None]
else:
runs = as_list(run)
print('\n')
print(sub)
print("%s%s" % ('Subject:', sub))
print("%s%s" % ('Sessions:', seshs))
print("%s%s" % ('Tasks:', tasks))
print("%s%s" % ('Runs:', runs))
print('\n')
# all the combinations of sessions and tasks that are possible
for (ses, tas, ru) in product(seshs, tasks, runs):
if modality == 'dwi':
dwis = []
bvals = []
bvecs = []
elif modality == 'func':
funcs = []
anats = []
# initialize BIDs tree on bdir
layout = bids.layout.BIDSLayout(bdir, validate=False)
# get all files matching the specific modality we are using
if not subj:
# list of all the subjects
subjs = layout.get_subjects()
else:
# make it a list so we can iterate
subjs = as_list(subj)
assert subj in subjs, "subject {} is not in the bids folder".format(subj)
for sub in subjs:
if not sesh:
seshs = layout.get_sessions(subject=sub, derivatives=False)
# in case there are non-session level inputs
seshs += [None]
else:
# make a list so we can iterate
seshs = as_list(sesh)
if not task:
tasks = layout.get_tasks(subject=sub, derivatives=False)
tasks += [None]
else:
tasks = as_list(task)
seshs += [None]
else:
# make a list so we can iterate
seshs = as_list(sesh)
if not task:
tasks = layout.get_tasks(subject=sub, derivatives=False)
tasks += [None]
else:
tasks = as_list(task)
if not run:
runs = layout.get_runs(subject=sub, derivatives=False)
runs += [None]
else:
runs = as_list(run)
print('\n')
print(sub)
print("%s%s" % ('Subject:', sub))
print("%s%s" % ('Sessions:', seshs))
print("%s%s" % ('Tasks:', tasks))
print("%s%s" % ('Runs:', runs))
print('\n')
# all the combinations of sessions and tasks that are possible
for (ses, tas, ru) in product(seshs, tasks, runs):
# the attributes for our modality img
mod_attributes = [sub, ses, tas, ru]
# the keys for our modality img
mod_keys = ['subject', 'session', 'task', 'run']
# our query we will use for each modality img
mod_query = {'datatype': modality}
# get all files matching the specific modality we are using
if not subj:
# list of all the subjects
subjs = layout.get_subjects()
else:
# make it a list so we can iterate
subjs = as_list(subj)
assert subj in subjs, "subject {} is not in the bids folder".format(subj)
for sub in subjs:
if not sesh:
seshs = layout.get_sessions(subject=sub, derivatives=False)
# in case there are non-session level inputs
seshs += [None]
else:
# make a list so we can iterate
seshs = as_list(sesh)
if not task:
tasks = layout.get_tasks(subject=sub, derivatives=False)
tasks += [None]
else:
tasks = as_list(task)
if not run:
runs = layout.get_runs(subject=sub, derivatives=False)
runs += [None]
else:
runs = as_list(run)
print('\n')
print(sub)
print("%s%s" % ('Subject:', sub))