def predict_retinotopy(sub, template='<STR_LIT>', registration='<STR_LIT>'):
template = template.lower()<EOL>retino_tmpls = predict_retinotopy.retinotopy_templates[registration]<EOL>hemis = ['<STR_LIT>','<STR_LIT>'] if registration == '<STR_LIT>' else ['<STR_LIT>']<EOL>if template not in retino_tmpls:<EOL><INDENT>libdir = os.path.join(library_path(), '<STR_LIT:data>')<EOL>search_paths = [libdir]<EOL>suff = '<STR_LIT>' if registration == '<STR_LIT>' else '<STR_LIT>'<EOL>filenames = {(hname, fnm): ('<STR_LIT>' % (hname,template,fnm,suff))<EOL>for fnm in ['<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT>']<EOL>for hname in hemis}<EOL>tmpl_path = next((os.path.join(path0, registration)<EOL>for path0 in search_paths<EOL>if all(os.path.isfile(os.path.join(path0, registration, '<STR_LIT>', s))<EOL>for s in six.itervalues(filenames))),<EOL>None)<EOL>if tmpl_path is None:<EOL><INDENT>raise ValueError('<STR_LIT>' % template)<EOL><DEDENT>tmpl_sub = nyfs.subject(registration)<EOL>spath = os.path.join(tmpl_path, '<STR_LIT>')<EOL>retino_tmpls[template] = pimms.persist(<EOL>{h:{k: pimms.imm_array(dat)<EOL>for k in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>for dat in [nyio.load(os.path.join(tmpl_path, '<STR_LIT>', filenames[(h,k)]))]}<EOL>for h in hemis})<EOL><DEDENT>tmpl = retino_tmpls[template]<EOL>if not all(s in tmpl for s in hemis):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if registration == '<STR_LIT>':<EOL><INDENT>sym = nyfs.subject('<STR_LIT>')<EOL>if isinstance(sub, mri.Subject):<EOL><INDENT>subj_hems = (sub.lh, sub.hemis['<STR_LIT>'])<EOL>tmpl_hems = (sym.lh, sym.lh)<EOL>chrs_hems = ('<STR_LIT>','<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>subj_hems = (sub,)<EOL>tmpl_hems = (sym.lh,)<EOL>chrs_hems = (sub.chirality,)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>fsa = nyfs.subject('<STR_LIT>')<EOL>if isinstance(sub, mri.Subject):<EOL><INDENT>subj_hems = (sub.lh, sub.rh)<EOL>tmpl_hems = (fsa.lh, fsa.rh)<EOL>chrs_hems = ('<STR_LIT>','<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>subj_hems = (sub,)<EOL>tmpl_hems = ((fsa.lh if sub.chirality == '<STR_LIT>' else fsa.rh),)<EOL>chrs_hems = (sub.chirality,)<EOL><DEDENT><DEDENT>tpl = tuple([th.interpolate(sh, tmpl[h if registration == '<STR_LIT>' else '<STR_LIT>'])<EOL>for (sh,th,h) in zip(subj_hems, tmpl_hems, chrs_hems)])<EOL>return tpl[<NUM_LIT:0>] if len(tpl) == <NUM_LIT:1> else tpl<EOL>
predict_retinotopy(subject) yields a pair of dictionaries each with four keys: angle, eccen,
  sigma, and varea. Each of these keys maps to a numpy array with one entry per vertex.  The
  first element of the yielded pair is the left hemisphere map and the second is the right
  hemisphere map. The values are obtained by resampling the Benson et al. 2014 anatomically
  defined template of retinotopy to the given subject.

The following optional arguments may be given:
  * template (default: 'benson14') specifies the template to use.
  * registration (default: 'fsaverage') specifies the subject registration to use; generally can
    only be 'fsaverage' or 'fsaverage_sym'.