def as_retinotopy(data, output_style='<STR_LIT>', units=Ellipsis, prefix=None, suffix=None):
<EOL>output_style = output_style.lower()<EOL>if output_style not in _retinotopy_style_fns:<EOL><INDENT>raise ValueError('<STR_LIT>' % output_style)<EOL><DEDENT>if is_tuple(data) and len(data) == <NUM_LIT:2>:<EOL><INDENT>data = {'<STR_LIT>': data[<NUM_LIT:0>], '<STR_LIT>': data[<NUM_LIT:1>]}<EOL><DEDENT>if isinstance(data, list):<EOL><INDENT>data = np.asarray(data)<EOL><DEDENT>if pimms.is_nparray(data):<EOL><INDENT>if pimms.is_vector(data, np.complexfloating):<EOL><INDENT>data = {'<STR_LIT>': data}<EOL><DEDENT>else:<EOL><INDENT>if data.shape[<NUM_LIT:0>] != <NUM_LIT:2>: data = data.T<EOL>data = {'<STR_LIT>': data[<NUM_LIT:0>], '<STR_LIT>': data[<NUM_LIT:1>]}<EOL><DEDENT><DEDENT>if isinstance(data, geo.VertexSet):<EOL><INDENT>pnames = {k.lower():k for k in six.iterkeys(data.properties)}<EOL>mem_dat = lambda k: k in pnames<EOL>get_dat = lambda k: data.prop(pnames[k])<EOL><DEDENT>else:<EOL><INDENT>def _make_lambda(data,k): return lambda:data[k]<EOL>data = pimms.lazy_map({k.lower():_make_lambda(data,k) for k in six.iterkeys(data)})<EOL>mem_dat = lambda k: k in data<EOL>get_dat = lambda k: data[k]<EOL><DEDENT>suffix = '<STR_LIT>' if suffix is None else suffix.lower()<EOL>prefix = '<STR_LIT>' if prefix is None else prefix.lower()<EOL>(angle_key, eccen_key, x_key, y_key, z_key) = [<EOL>next((k for k in aliases if mem_dat(prefix + k + suffix)), None)<EOL>for aliases in [['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'],<EOL>['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'],<EOL>['<STR_LIT:x>', '<STR_LIT>', '<STR_LIT>'], ['<STR_LIT:y>', '<STR_LIT>', '<STR_LIT>'],<EOL>['<STR_LIT:z>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']]]<EOL>rad2deg = <NUM_LIT> / np.pi<EOL>deg2rad = np.pi / <NUM_LIT><EOL>(hpi, dpi) = (np.pi / <NUM_LIT>, np.pi * <NUM_LIT>)<EOL>if angle_key and eccen_key:<EOL><INDENT>akey = prefix + angle_key + suffix<EOL>ekey = prefix + eccen_key + suffix<EOL>theta = np.asarray(get_dat(akey))<EOL>rho   = np.asarray(get_dat(ekey))<EOL>theta = theta * (deg2rad if _default_polar_angle_units[angle_key]  == '<STR_LIT>' else <NUM_LIT:1>)<EOL>rho   = rho   * (rad2deg if _default_eccentricity_units[eccen_key] == '<STR_LIT>' else <NUM_LIT:1>)<EOL>if _default_polar_angle_axis[angle_key] == '<STR_LIT>': theta = theta - hpi<EOL>if _default_polar_angle_dir[angle_key] == '<STR_LIT>':   theta = -theta<EOL>ok = np.where(np.isfinite(theta))[<NUM_LIT:0>]<EOL>theta[ok[theta[ok] < -np.pi]] += dpi<EOL>theta[ok[theta[ok] >  np.pi]] -= dpi<EOL><DEDENT>elif x_key and y_key:<EOL><INDENT>(x,y) = [np.asarray(get_dat(prefix + k + suffix)) for k in [x_key, y_key]]<EOL>if _default_x_units[x_key] == '<STR_LIT>': x *= rad2deg<EOL>if _default_y_units[y_key] == '<STR_LIT>': y *= rad2deg<EOL>theta = np.arctan2(y, x)<EOL>rho   = np.sqrt(x*x + y*y)<EOL><DEDENT>elif z_key:<EOL><INDENT>z = get_dat(prefix + z_key + suffix)<EOL>theta = np.angle(z)<EOL>rho   = np.abs(z)<EOL>if _default_z_units[z_key] == '<STR_LIT>': rho *= rad2deg<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>f = _retinotopy_style_fns[output_style]<EOL>return f(theta, rho)<EOL>
as_retinotopy(data) converts the given data, if possible, into a 2-tuple, (polar_angle, eccen),
  both in degrees, with 0 degrees of polar angle corresponding to the upper vertical meridian
  and negative values corresponding to the left visual hemifield.
as_retinotopy(data, output_style) yields the given retinotopy data in the given output_style;
  as_retinotopy(data) is equivalent to as_retinotopy(data, 'visual').

This function is intended as a general conversion routine between various sources of retinotopy
data. All lookups are done in a case insensitive manner. Data may be specified in any of the
following ways:
  * A cortical mesh containing recognized properties (such as 'polar_angle' and 'eccentricity'
    or 'latitude' and 'longitude'.
  * A dict with recognized fields.
  * A tuple of (polar_angle, eccentricity) (assumed to be in 'visual' style).
  * A numpy vector of complex numbers (assumed in 'complex' style).
  * An n x 2 or 2 x n matrix whose rows/columns are (polar_angle, eccentricity) values (assumed
    in 'visual' style).

The following output_styles are accepted:
  * 'visual':       polar-axis:         upper vertical meridian
                    positive-direction: clockwise
                    fields:             ['polar_angle' (degrees), 'eccentricity' (degrees)]
  * 'spherical':    polar-axis:         right horizontal meridian
                    positive-direction: counter-clockwise
                    fields:             ['theta' (radians), 'rho' (radians)]
  * 'standard':     polar-axis:         right horizontal meridian
                    positive-direction: counter-clockwise
                    fields:             ['angle' (radians), 'eccentricity' (degrees)]
  * 'cartesian':    axes:               x/y correspond to RHM/UVM
                    positive-direction: left/up
                    fields:             ('x' (degrees), 'y' (degrees))
  * 'geographical': axes:               x/y correspond to RHM/UVM
                    positive-direction: left/up
                    fields:             ('longitude' (degrees), 'latitude' (degrees))
  * 'complex':      axes:               x/y correspond to RHM/UVM
                    positive-direction: left/up
                    fields:             longitude (degrees) + I*latitude (degrees)
  * 'complex-rad':  axes:               x/y correspond to RHM/UVM
                    positive-direction: left/up
                    fields:             longitude (radians) + I*latitude (radians)
  * 'visual-rad':   polar-axis:         upper vertical meridian
                    positive-direction: clockwise
                    fields:             ['angle' (radians), 'eccentricity' (radians)]

The following options may be given:
  * units (Ellipsis) specifies the unit that should be assumed (degrees or radians);
    if Ellipsis is given, then auto-detect the unit if possible. This may be a map whose keys
    are 'polar_angle' and 'eccentricity' (or the equivalent titles in data) and whose keys are
    the individual units.
  * prefix (None) specifies a prefix that is required for any keys or property names.
  * suffix (None) specifies a suffix that is required for any keys or property names.