本文整理匯總了Python中joblib.Parallel.pop方法的典型用法代碼示例。如果您正苦於以下問題:Python Parallel.pop方法的具體用法?Python Parallel.pop怎麽用?Python Parallel.pop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類joblib.Parallel
的用法示例。
在下文中一共展示了Parallel.pop方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: load_glm_inputs
# 需要導入模塊: from joblib import Parallel [as 別名]
# 或者: from joblib.Parallel import pop [as 別名]
def load_glm_inputs(study_dirs, hrf_model='canonical', drift_model='cosine',
img_ext='nii.gz', memory=Memory(None), n_jobs=1):
"""Returns data (almost) ready to be used for a GLM.
"""
datasets, structural, functional, conditions, contrasts = \
collect_openfmri(study_dirs, img_ext=img_ext, memory=memory, n_jobs=n_jobs)
main = functional.merge(conditions)
# computing design matrices
print 'Computing models...'
results = Parallel(n_jobs=n_jobs, pre_dispatch='n_jobs')(
delayed(memory.cache(_make_design_matrix))(
run_df, hrf_model, drift_model, orthogonalize=datasets[group_id[0]]['models'][group_id[2]]['orthogonalize'])
for group_id, group_df in main.groupby(['study', 'subject', 'model'])
for run_id, run_df in group_df.groupby(['task', 'run'])
)
# collect results
print 'Collecting...'
glm_inputs = {}
for group_id, group_df in main.groupby(['study', 'subject', 'model']):
study_id, subject_id, model_id = group_id
for session_id, run_df in group_df.groupby(['task', 'run']):
task_id, run_id = session_id
bold_file, dm = results.pop(0)
glm_inputs.setdefault(group_id, {}).setdefault('bold', []).append(bold_file)
glm_inputs.setdefault(group_id, {}).setdefault('design', []).append(dm)
glm_inputs.setdefault(group_id, {}).setdefault(
model_id, _make_contrasts(datasets, study_id, model_id, hrf_model, group_df))
glm_inputs.setdefault(group_id, {}).setdefault(
'%s_per_run' % model_id, _make_contrasts(
datasets, study_id, model_id, hrf_model, group_df, per_run=True))
return glm_inputs