def isoline_vmag(hemi, isolines=None, surface='<STR_LIT>', min_length=<NUM_LIT:2>, **kw):
from neuropythy.util import (curry, zinv)<EOL>from neuropythy.mri import is_cortex<EOL>from neuropythy.vision import visual_isolines<EOL>from neuropythy.geometry import to_mesh<EOL>if isolines is None: isolines = visual_isolines(hemi, **kw)<EOL>if pimms.is_vector(isolines.keys(), '<STR_LIT:int>'):<EOL><INDENT>f = lambda k: isoline_vmag(isolines[k], surface=surface, min_length=min_length)<EOL>return pimms.lazy_map({k:curry(f, k) for k in six.iterkeys(isolines)})<EOL><DEDENT>mesh = to_mesh((hemi, surface))<EOL>if min_length is not None:<EOL><INDENT>isolines = {k: {kk: {kkk: [vvv[ii] for ii in iis] for (kkk,vvv) in six.iteritems(vv)}<EOL>for (kk,vv) in six.iteritems(v)<EOL>for iis in [[ii for (ii,u) in enumerate(vv['<STR_LIT>'])<EOL>if len(u) >= min_length]]<EOL>if len(iis) > <NUM_LIT:0>}<EOL>for (k,v) in six.iteritems(isolines)}<EOL><DEDENT>(rlns,tlns) = [isolines[k] for k in ['<STR_LIT>', '<STR_LIT>']]<EOL>if len(rlns) < <NUM_LIT:2>: raise ValueError('<STR_LIT>')<EOL>if len(tlns) < <NUM_LIT:2>: raise ValueError('<STR_LIT>')<EOL>((rvlns,tvlns),(rslns,tslns)) = [[[u for lns in six.itervalues(xlns) for u in lns[k]]<EOL>for xlns in (rlns,tlns)]<EOL>for k in ('<STR_LIT>','<STR_LIT>')]<EOL>(rslen,tslen) = [[np.sqrt(np.sum((sx[:,:-<NUM_LIT:1>] - sx[:,<NUM_LIT:1>:])**<NUM_LIT:2>, <NUM_LIT:0>)) for sx in slns]<EOL>for slns in (rslns,tslns)]<EOL>(rvlen,tvlen) = [[np.sqrt(np.sum((vx[:,:-<NUM_LIT:1>] - vx[:,<NUM_LIT:1>:])**<NUM_LIT:2>, <NUM_LIT:0>)) for vx in vlns]<EOL>for vlns in (rvlns,tvlns)]<EOL>(rvxy, tvxy)  = [[<NUM_LIT:0.5>*(vx[:,:-<NUM_LIT:1>] + vx[:,<NUM_LIT:1>:]) for vx in vlns] for vlns in (rvlns,tvlns)]<EOL>(rvlen,tvlen,rslen,tslen) = [np.concatenate(u) for u in (rvlen,tvlen,rslen,tslen)]<EOL>(rvxy,tvxy)   = [np.hstack(vxy) for vxy in (rvxy,tvxy)]<EOL>(rvmag,tvmag) = [vlen * zinv(slen) for (vlen,slen) in zip([rvlen,tvlen],[rslen,tslen])]<EOL>return {k: {'<STR_LIT>':vxy, '<STR_LIT>': vmag,<EOL>'<STR_LIT>': vlen, '<STR_LIT>': slen}<EOL>for (k,vxy,vmag,vlen,slen) in zip(['<STR_LIT>','<STR_LIT>'], [rvxy,tvxy],<EOL>[rvmag,tvmag], [rvlen,tvlen], [rslen,tslen])}<EOL>
isoline_vmag(hemi) calculates the visual magnification function f using the default set of
  iso-lines (as returned by neuropythy.vision.visual_isolines()). The hemi argument may
  alternately be a mesh object.
isoline_vmag(hemi, isolns) uses the given iso-lines rather than the default ones.

The return value of this funciton is a dictionary whose keys are 'tangential', 'radial', and
'areal', and whose values are the estimated visual magnification functions. These functions
are of the form f(x,y) where x and y can be numbers or arrays in the visual field.