How to use the pynets.core.utils.as_list function in pynets

To help you get started, we’ve selected a few pynets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dPys / PyNets / pynets / pynets_bids.py View on Github external
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):
github dPys / PyNets / pynets / pynets_bids.py View on Github external
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)
github dPys / PyNets / pynets / pynets_bids.py View on Github external
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}
github dPys / PyNets / pynets / pynets_bids.py View on Github external
# 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))