def proc_func(config, args):
refs = dict()<EOL>for scan in iterconfig(config, '<STR_LIT>'):<EOL><INDENT>ref = scan.get('<STR_LIT:id>', None)<EOL>templ = '<STR_LIT>'<EOL>if '<STR_LIT>' in scan:<EOL><INDENT>templ += '<STR_LIT>'<EOL><DEDENT>if '<STR_LIT>' in scan:<EOL><INDENT>templ += '<STR_LIT>'<EOL><DEDENT>if '<STR_LIT>' in scan:<EOL><INDENT>templ += '<STR_LIT>'<EOL><DEDENT>templ += '<STR_LIT>'<EOL>templ = string.Template(templ)<EOL>fbase = templ.safe_substitute(<EOL>sub=legal.sub('<STR_LIT>', args.subject),<EOL>ses=legal.sub('<STR_LIT>', args.session),<EOL>task=scan.get('<STR_LIT>', None),<EOL>acquisition=scan.get('<STR_LIT>', None),<EOL>run=scan.get('<STR_LIT>', None),<EOL>direction=scan.get('<STR_LIT>', None),<EOL>modality=scan.get('<STR_LIT>', None),<EOL>)<EOL>sourcedata_dir = os.path.join(args.sourcedata, scan['<STR_LIT:type>'])<EOL>if not os.path.exists(sourcedata_dir):<EOL><INDENT>os.makedirs(sourcedata_dir)<EOL><DEDENT>dicom_dir = os.path.join(sourcedata_dir, '<STR_LIT>'.format(fbase))<EOL>logger.info('<STR_LIT>', args.session, scan['<STR_LIT>'], dicom_dir)<EOL>args.xnat.download(args.session, [scan['<STR_LIT>']], out_dir=dicom_dir)<EOL>fname = '<STR_LIT>'.format(fbase)<EOL>refs[ref] = os.path.join(scan['<STR_LIT:type>'], fname)<EOL>fullfile = os.path.join(args.bids, scan['<STR_LIT:type>'], fname)<EOL>logger.info('<STR_LIT>', dicom_dir, fullfile)<EOL>convert(dicom_dir, fullfile)<EOL><DEDENT>return refs<EOL>
Download functional data and convert to BIDS