def bids_from_config(sess, scans_metadata, config, out_base):
    '''
    Create a BIDS output directory from configuration file
    '''
    # get session and subject labels from scan metadata
    _item = next(iter(scans_metadata))
    session,subject = _item['session_label'],_item['subject_label']
    # bids and sourcedata base directories
    sourcedata_base = os.path.join(
        out_base,
        'sourcedata',
        'sub-{0}'.format(legal.sub('', subject)),
        'ses-{0}'.format(legal.sub('', session))
    )
    bids_base = os.path.join(
        out_base,
        'sub-{0}'.format(legal.sub('', subject)),
        'ses-{0}'.format(legal.sub('', session))
    )
    # put arguments in a struct
    args = commons.struct(
        xnat=sess,
        subject=subject,
        session=session,
        bids=bids_base,
        sourcedata=sourcedata_base
    )
    # process func, anat, and fmap
    func_refs = proc_func(config, args)
    anat_refs = proc_anat(config, args)
    fmap_refs = proc_fmap(config, args, func_refs)
Create a BIDS output directory from configuration file