@pimms.calc('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>def calc_initial_state(cortex, model, empirical_retinotopy, resample=Ellipsis, prior=None):
model_reg = model.map_projection.registration<EOL>model_reg = '<STR_LIT>' if model_reg is None else model_reg<EOL>model_chirality = None if model_reg == '<STR_LIT>' else model.map_projection.chirality<EOL>ch = '<STR_LIT>' if model_chirality is None else model_chirality<EOL>if model_chirality is not None and cortex.chirality != model_chirality:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if model_reg not in cortex.registrations:<EOL><INDENT>raise ValueError('<STR_LIT>' % model_reg)<EOL><DEDENT>native_mesh = cortex.registrations[model_reg].with_prop(empirical_retinotopy)<EOL>preregmesh = native_mesh <EOL>if prior is not None:<EOL><INDENT>try:<EOL><INDENT>mdl_ctx = getattr(nyfs.subject(model_reg), ch)<EOL>nativ = mdl_ctx.registrations['<STR_LIT>']<EOL>prior = mdl_ctx.registrations[prior]<EOL><DEDENT>except Exception: raise ValueError('<STR_LIT>' % prior)<EOL>addr = nativ.address(native_mesh)<EOL>preregmesh = native_mesh.copy(coordinates=prior.unaddress(addr))<EOL><DEDENT>if resample is Ellipsis:<EOL><INDENT>resample = model_reg if model_reg == '<STR_LIT>' or model_reg == '<STR_LIT>' else None<EOL><DEDENT>if resample is not None and resample is not False:<EOL><INDENT>preregmesh = getattr(nyfs.subject(resample), ch).registrations['<STR_LIT>']<EOL>preregmesh = preregmesh.with_prop(native_mesh.interpolate(preregmesh.coordinates, '<STR_LIT:all>'))<EOL><DEDENT>preregmap = model.map_projection(preregmesh)<EOL>return {'<STR_LIT>':          native_mesh,<EOL>'<STR_LIT>': preregmesh,<EOL>'<STR_LIT>':  preregmap}<EOL>
calc_initial_state is a calculator that prepares the initial state of the registration process.
The initial state consists of a flattened 2D mesh ('native_map') that has been made from the
initial cortex, and a 'registration_map', on which registration is to be performed. The former
of these two meshes will always share vertex labels with the cortex argument, and the latter
mesh this mesh may be identical to the native mesh or may be a resampled version of it.

Optional afferent parameters:
  @ resample May specify that the registration_map should be resampled to the 'fsaverage' or the
    'fsaverage_sym' map; the advantage of this is that the resampling prevents angles already
    distorted by inflation, registration, and flattening from being sufficiently small to
    dominate the registration initially. The default value is Ellipsis, which specifies that the
    'fsaverage' or 'fsaverage_sym' resampling should be applied if the model is registered to
    either of those, and otherwise no resampling should be applied.
  @ prior May specify an alternate registration to which the native mesh should be projected
    prior to flattening and registration. The default value, None, indicates that the model's
    default registration should just be used. Generally models will be registered to either the 
    fsaverage or fsaverage_sym atlases; if your fsaverage subject has a geometry file matching
    the pattern ?h.*.sphere.reg, such as lh.retinotopy.sphere.reg, you can use that file as a
    registration (with registration/prior name 'retinotopy') in place of the fsaverage's native
    lh.sphere from which to start the overall retinotopy registration.

Provided efferent values:
  @ native_mesh Will be the 3D mesh registered to the model's required registration space.
  @ preregistration_mesh Will be the 3D mesh that is ready to be used in registration; this may
    be identical to native_mesh if there is no resampling.
  @ preregistration_map Will be the 2D flattened mesh for use in registration; this mesh is
    a flattened version of preregistration_mesh.