if has_pending_jobs(fw, other_exam['fw_id']): pending_jobs = True break if pending_jobs: print('Gears have not finished on this scanid. Skipping . . .') continue #Download data according to template #path information for data to be downloaded pid = exam['scanid'].split('_')[0] visit = 'visit' + exam['scanid'].split('_')[1] session = 'session' + exam['scanid'].split('_')[2] downloaded_scanids.append([pid, visit, session, exam['study']]) scanidpath = pjoin(rawdata_root, pid, visit, session) #gen list of acquisitions associated with this exam fw_acqs = fw.get_session_acquisitions(exam['fw_id']) study_template = studies_template[exam['study']] for acquisition in study_template: for fw_acq in fw_acqs: #download acquisition files from study template if fw_acq['label'] == acquisition or fw_acq[ 'label'] == acquisition + '_func': for download_pair in study_template[acquisition]: for file in fw_acq['files']: #modify file types if '.7' in file['name'] and (file['name'][0] == 'E' or file['name'][0] == 'P'): fw.modify_acquisition_file(fw_acq['_id'], file['name'], body={'type': 'pfile'}) #download files
# add behavioral to rawdata call('cp -r %s %s' % (pjoin(root, folder), root.replace(lucas_scanid_path, rawdatapath)), shell=True) #add behavioral to flywheel found_run_on_fw = False run = False if '/fmri/' in root: folder_list = pjoin(root, folder).split('/') for i in range(len(folder_list)): if folder_list[i] == 'fmri': run = folder_list[i + 1] break for exam in flywheel_exams: fw_acqs = fw.get_session_acquisitions( exam['fw_id']) for fw_acq in fw_acqs: if fw_acq['label'] == run: found_run_on_fw = True for behav_path in files_under_behavioral: print('uploading %s' % behav_path) fw.upload_file_to_acquisition( fw_acq['_id'], behav_path) if not found_run_on_fw: if run: print( 'run %s not found, creating acquisition behavioral under flywheel exam id %s' % (run, flywheel_exams[0]['fw_id'])) else: print( 'creating acquisition behavioral under flywheel exam id %s'