@staticmethod<EOL><INDENT>def _cortex_from_path(subid, chirality, name, surf_path, data_path, data_prefix=Ellipsis):<DEDENT>
<EOL>chirality = chirality.lower()<EOL>if data_prefix is Ellipsis:<EOL><INDENT>if name.lower().endswith('<STR_LIT:x>'): data_prefix = '<STR_LIT>' if chirality == '<STR_LIT>' else '<STR_LIT>'<EOL>else:                          data_prefix = chirality<EOL><DEDENT>def _make_prop_loader(flnm):<EOL><INDENT>def _load_fn():<EOL><INDENT>p = fsio.read_morph_data(flnm)<EOL>p.setflags(write=False)<EOL>return p<EOL><DEDENT>return _load_fn<EOL><DEDENT>def _make_mghprop_loader(flnm):<EOL><INDENT>def _load_fn():<EOL><INDENT>p = fsmgh.load(flnm).get_data().flatten()<EOL>p.setflags(write=False)<EOL>return p<EOL><DEDENT>return _load_fn<EOL><DEDENT>props = {}<EOL>for (k,(a,_)) in six.iteritems(Subject._auto_properties):<EOL><INDENT>f = os.path.join(data_path, data_prefix + '<STR_LIT:.>' + k)<EOL>if os.path.isfile(f):<EOL><INDENT>props[a] = _make_prop_loader(f)<EOL><DEDENT><DEDENT>for flnm in os.listdir(data_path):<EOL><INDENT>if flnm[<NUM_LIT:0>] == '<STR_LIT:.>' or not flnm.startswith(data_prefix + '<STR_LIT:.>'): continue<EOL>if flnm.endswith('<STR_LIT>') or flnm.endswith('<STR_LIT>'):<EOL><INDENT>mid = flnm[<NUM_LIT:3>:-<NUM_LIT:4>]<EOL>loader = _make_mghprop_loader<EOL><DEDENT>else:<EOL><INDENT>mid = flnm[<NUM_LIT:3>:]<EOL>loader = _make_prop_loader<EOL><DEDENT>if mid in Subject._auto_retino_names:<EOL><INDENT>tr = Subject._auto_retino_names[mid]<EOL>props[tr] = loader(os.path.join(data_path, flnm))<EOL><DEDENT><DEDENT>props = pimms.lazy_map(props)<EOL>white_surf_name = os.path.join(surf_path, chirality + '<STR_LIT>')<EOL>tess = geo.Tesselation(fsio.read_geometry(white_surf_name)[<NUM_LIT:1>], properties=props)<EOL>def _make_surf_loader(flnm):<EOL><INDENT>def _load_fn():<EOL><INDENT>x = fsio.read_geometry(flnm)[<NUM_LIT:0>].T<EOL>x.setflags(write=False)<EOL>return x<EOL><DEDENT>return _load_fn<EOL><DEDENT>surfs = {}<EOL>for s in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>surfs[s] = _make_surf_loader(os.path.join(surf_path, chirality + '<STR_LIT:.>' + s))<EOL><DEDENT>surfs = pimms.lazy_map(surfs)<EOL>def _make_midgray():<EOL><INDENT>x = np.mean([surfs['<STR_LIT>'], surfs['<STR_LIT>']], axis=<NUM_LIT:0>)<EOL>x.setflags(write=False)<EOL>return x<EOL><DEDENT>surfs = surfs.set('<STR_LIT>', _make_midgray)<EOL>regs = {'<STR_LIT>': lambda:surfs['<STR_LIT>']}<EOL>surf_paths = [surf_path]<EOL>extra_path = os.path.join(library_path(), '<STR_LIT:data>', subid, '<STR_LIT>')<EOL>regals = Subject._registration_aliases<EOL>if os.path.isdir(extra_path): surf_paths.insert(<NUM_LIT:0>, extra_path)<EOL>for surf_path in surf_paths:<EOL><INDENT>for flnm in os.listdir(surf_path):<EOL><INDENT>if flnm.startswith(chirality + '<STR_LIT:.>') and flnm.endswith('<STR_LIT>'):<EOL><INDENT>mid = flnm[(len(chirality)+<NUM_LIT:1>):-<NUM_LIT:11>]<EOL>if mid == '<STR_LIT>': mid = '<STR_LIT>'<EOL>elif mid in regals: mid = regals[mid]<EOL>regs[mid] = _make_surf_loader(os.path.join(surf_path, flnm))<EOL><DEDENT><DEDENT><DEDENT>regs = pimms.lazy_map(regs)<EOL>return mri.Cortex(chirality, tess, surfs, regs).persist()<EOL>
Subject._cortex_from_path(subid, chirality, name, spath, dpath) yields a Cortex object
  that has been loaded from the given path. The given spath should be the path from which
  to load the structural information (like lh.sphere and rh.white) while the dpath is the
  path from which to load the non-structural information (like lh.thickness or rh.curv).