def map_projection(name=None, chirality=Ellipsis,<EOL>center=Ellipsis, center_right=Ellipsis, radius=Ellipsis,<EOL>method=Ellipsis, registration=Ellipsis, sphere_radius=Ellipsis,<EOL>pre_affine=Ellipsis, post_affine=Ellipsis, meta_data=Ellipsis, remember=False):
global map_projections <EOL>kw = dict(center=center, center_right=center_right, radius=radius,<EOL>method=method, registration=registration, sphere_radius=sphere_radius,<EOL>pre_affine=pre_affine, post_affine=post_affine, meta_data=meta_data)<EOL>kw = {k:v for (k,v) in six.iteritems(kw) if v is not Ellipsis}<EOL>hemi = chirality<EOL>if hemi is None or hemi is Ellipsis:<EOL><INDENT>hemi = '<STR_LIT>'<EOL>topo = None<EOL>mesh = None<EOL><DEDENT>if pimms.is_str(hemi):<EOL><INDENT>hemi = to_hemi_str(hemi)<EOL>topo = None<EOL>mesh = None<EOL><DEDENT>elif is_topo(hemi):<EOL><INDENT>topo = hemi<EOL>hemi = hemi.chirality<EOL>mesh = None<EOL><DEDENT>elif is_mesh(hemi):<EOL><INDENT>mesh = hemi<EOL>hemi = deduce_chirality(hemi)<EOL>topo = None<EOL><DEDENT>else: raise ValueError('<STR_LIT>' % hemi)<EOL>hemi = to_hemi_str(hemi)<EOL>try:              aff = to_affine(name)<EOL>except Exception: aff = None<EOL>if pimms.is_matrix(aff):<EOL><INDENT>aff = np.asarray(aff)<EOL>(n,m) = aff.shape<EOL>mtx = None<EOL>if n == <NUM_LIT:2>:<EOL><INDENT>if   m == <NUM_LIT:3>: mtx = np.vstack([np.hstack([mtx, [[<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>],[<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>]]]), [[<NUM_LIT:0>],[<NUM_LIT:0>],[<NUM_LIT:0>],[<NUM_LIT:1>]]])<EOL>elif m == <NUM_LIT:4>: mtx = np.vstack([mtx, [[<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>], [<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:1>]]])<EOL><DEDENT>elif n == <NUM_LIT:3>:<EOL><INDENT>if   m == <NUM_LIT:3>: mtx = np.vstack([np.hstack([mtx, [[<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>]]]), [[<NUM_LIT:0>],[<NUM_LIT:0>],[<NUM_LIT:0>],[<NUM_LIT:1>]]])<EOL>elif m == <NUM_LIT:4>: mtx = np.vstack([mtx, [[<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:1>]]])<EOL><DEDENT>elif n == <NUM_LIT:4>:<EOL><INDENT>if   m == <NUM_LIT:4>: mtx = aff<EOL><DEDENT>if mtx is None: raise ValueError('<STR_LIT>')<EOL>kw['<STR_LIT>'] = mtx if kw.get('<STR_LIT>') is None else mtx.dot(to_affine(pre_affine))<EOL>name = None<EOL><DEDENT>if pimms.is_str(name):<EOL><INDENT>if   name         in map_projections[hemi]: mp = map_projections[hemi][name]<EOL>elif name.lower() in map_projections[hemi]: mp = map_projections[hemi][name.lower()]<EOL>else:<EOL><INDENT>try: mp = load_map_projection(name, chirality=hemi)<EOL>except Exception:<EOL><INDENT>raise ValueError('<STR_LIT>' % (name,hemi))<EOL><DEDENT><DEDENT>if len(kw) > <NUM_LIT:0>: mp = mp.copy(**kw)<EOL><DEDENT>elif name is None:<EOL><INDENT>if chirality is not Ellipsis: kw['<STR_LIT>'] = hemi<EOL>mp = MapProjection(**kw)<EOL><DEDENT>elif is_map_projection(name):<EOL><INDENT>if chirality is not Ellipsis: kw['<STR_LIT>'] = hemi<EOL>mp = name<EOL>if len(kw) > <NUM_LIT:0>: mp = mp.copy(**kw)<EOL><DEDENT>else: raise ValueError('<STR_LIT>')<EOL>if topo is not None: mesh = mp.extract_mesh(topo)<EOL>if mesh is not None: mp   = mp.copy(mesh=mesh)<EOL>mp = mp.persist()<EOL>if remember is True:<EOL><INDENT>if pimms.is_str(name):<EOL><INDENT>name = name.lower()<EOL>hval = map_projections.get(hemi, pyr.m())<EOL>map_projections = map_projections.set(hemi, hval.set(name, mp))<EOL><DEDENT>else: warnings.warn('<STR_LIT>')<EOL><DEDENT>return mp<EOL>
map_projection(name, hemi) yields the map projection with the given name if it exists; hemi must
  be either 'lh', 'rh', or 'lr'/None.
map_projection(name, topo) yields a map projection using the given topology object topo to
  determine the hemisphere and assigning to the resulting projection's 'mesh' parameter the
  appropriate registration from the given topology.
map_projection(name, mesh) uses the given mesh; the mesh's meta-data must specify the hemisphere
  for this to work--otherwise 'lr' is always used as the hemisphere.
map_projection(affine, hemi) creates a map projection from the given affine matrix, which must
  align a set of spherical coordinates to a new set of 3D coordinates that are used as input to
  the method argument (default method 'orthographic' uses the first two of these coordinates as
  the x and y values of the map).
map_projection() creates a new map projection using the optional arguments, if provided.

All options that can be passed to load_map_projection and MapProjection can be passed to
map_projection:
  * name is the first optional parameter appearing as name and affine above.
  * chirality is the second optional parameter, and, if set, will ensure that the resulting
    map projection's chirality is equivalent to the given chirality.
  * center specifies the 3D vector that points toward the center of the map.
  * center_right specifies the 3D vector that points toward any point on the positive x-axis
    of the resulting map.
  * radius specifies the radius that should be assumed by the model in radians of the
    cortical sphere; if the default value (Ellipsis) is given, then pi/3.5 is used.
  * method specifies the projection method used (default: 'equirectangular').
  * registration specifies the registration to which the map is aligned (default: 'native').
  * chirality specifies whether the projection applies to left or right hemispheres.
  * sphere_radius specifies the radius of the sphere that should be assumed by the model.
    Note that in Freesurfer, spheres have a radius of 100.
  * pre_affine specifies the pre-projection affine transform to use on the cortical sphere. Note
    that if the first (name) argument is provided as an affine transform, then that transform is
    applied after the pre_affine but before alignment of the center and center_right points.
  * post_affine specifies the post-projection affine transform to use on the 2D map.
  * meta_data specifies any additional meta-data to attach to the projection.
  * remember may be set to True to indicate that, after the map projection is constructed, the
    map_projection cache of named projections should be updated with the provided name. This
    can only be used when the provided name or first argument is a string.