@pimms.calc('<STR_LIT>')<EOL>def calc_retinotopy(note, error, subject, clean, run_lh, run_rh,<EOL>invert_rh_angle, max_in_eccen, min_in_eccen,<EOL>angle_lh_file, theta_lh_file,<EOL>eccen_lh_file, rho_lh_file,<EOL>weight_lh_file, radius_lh_file,<EOL>angle_rh_file, theta_rh_file,<EOL>eccen_rh_file, rho_rh_file,<EOL>weight_rh_file, radius_rh_file):
ctcs = {}<EOL>for (h,ang,tht,ecc,rho,wgt,rad,run) in [<EOL>('<STR_LIT>', angle_lh_file,theta_lh_file, eccen_lh_file,rho_lh_file,<EOL>weight_lh_file, radius_lh_file, run_lh),<EOL>('<STR_LIT>', angle_rh_file,theta_rh_file, eccen_rh_file,rho_rh_file,<EOL>weight_rh_file, radius_rh_file, run_rh)]:<EOL><INDENT>if not run: continue<EOL>hemi = getattr(subject, h)<EOL>props = {}<EOL>if ang:<EOL><INDENT>try: props['<STR_LIT>'] = _guess_surf_file(ang)<EOL>except Exception: error('<STR_LIT>' % ang)<EOL><DEDENT>elif tht:<EOL><INDENT>try:<EOL><INDENT>tmp = _guess_surf_file(tht)<EOL>props['<STR_LIT>'] = <NUM_LIT> - <NUM_LIT> / np.pi * tmp<EOL><DEDENT>except Exception: error('<STR_LIT>' % tht)<EOL><DEDENT>else:<EOL><INDENT>props['<STR_LIT>'] = empirical_retinotopy_data(hemi, '<STR_LIT>')<EOL><DEDENT>if ecc:<EOL><INDENT>try: props['<STR_LIT>'] = _guess_surf_file(ecc)<EOL>except Exception: error('<STR_LIT>' % ecc)<EOL><DEDENT>elif rho:<EOL><INDENT>try:<EOL><INDENT>tmp = _guess_surf_file(rhp)<EOL>props['<STR_LIT>'] = <NUM_LIT> / np.pi * tmp<EOL><DEDENT>except Exception: error('<STR_LIT>' % rho)<EOL><DEDENT>else:<EOL><INDENT>props['<STR_LIT>'] = empirical_retinotopy_data(hemi, '<STR_LIT>')<EOL><DEDENT>if wgt:<EOL><INDENT>try: props['<STR_LIT>'] = _guess_surf_file(wgt)<EOL>except Exception: error('<STR_LIT>' % wgt)<EOL><DEDENT>else:<EOL><INDENT>props['<STR_LIT>'] = empirical_retinotopy_data(hemi, '<STR_LIT>')<EOL><DEDENT>if rad:<EOL><INDENT>try: props['<STR_LIT>'] = _guess_surf_file(rad)<EOL>except Exception: error('<STR_LIT>' % rad)<EOL><DEDENT>else:<EOL><INDENT>props['<STR_LIT>'] = empirical_retinotopy_data(hemi, '<STR_LIT>')<EOL><DEDENT>if h == '<STR_LIT>' and invert_rh_angle:<EOL><INDENT>props['<STR_LIT>'] = -props['<STR_LIT>']<EOL><DEDENT>props['<STR_LIT>'] = np.array(props['<STR_LIT>'])<EOL>if max_in_eccen is not None:<EOL><INDENT>props['<STR_LIT>'][props['<STR_LIT>'] > max_in_eccen] = <NUM_LIT:0><EOL><DEDENT>if min_in_eccen is not None:<EOL><INDENT>props['<STR_LIT>'][props['<STR_LIT>'] < min_in_eccen] = <NUM_LIT:0><EOL><DEDENT>if clean:<EOL><INDENT>note('<STR_LIT>' % h.upper())<EOL>(ang,ecc) = clean_retinotopy(hemi, retinotopy=props, mask=None, weight='<STR_LIT>')<EOL>props['<STR_LIT>']  = ang<EOL>props['<STR_LIT>'] = ecc<EOL><DEDENT>ctcs[h] = hemi.with_prop(props)<EOL><DEDENT>return {'<STR_LIT>': pyr.pmap(ctcs)}<EOL>
calc_retinotopy extracts the retinotopy options from the command line, loads the relevant files,
and stores them as properties on the subject's lh and rh cortices.